Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 1441)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 1442)
@@ -63,10 +63,8 @@
     \param argv array of arguments
  */
-Bool TAppDecCfg::parseCfg( Int argc, Char* argv[] )
+Bool TAppDecCfg::parseCfg( Int argc, TChar* argv[] )
 {
   Bool do_help = false;
-  string cfg_BitstreamFile;
-#if SVC_EXTENSION
-  string cfg_ReconFile [MAX_LAYERS];
+#if SVC_EXTENSION  
   Int layerNum, targetLayerId;
   Int olsIdx;
@@ -74,9 +72,4 @@
   string cfg_confPrefix;
 #endif
-#if AVC_BASE
-  string cfg_BLReconFile;
-#endif
-#else
-  string cfg_ReconFile;
 #endif
 
@@ -90,10 +83,10 @@
 
   ("help",                      do_help,                               false,      "this help text")
-  ("BitstreamFile,b",           cfg_BitstreamFile,                     string(""), "bitstream input file name")
-#if SVC_EXTENSION
-  ("ReconFileL%d,-o%d",                   cfg_ReconFile,   string(""), MAX_LAYERS, "Layer %d reconstructed YUV output file name\n"
+  ("BitstreamFile,b",           m_bitstreamFileName,                   string(""), "bitstream input file name")
+#if SVC_EXTENSION
+  ("ReconFileL%d,-o%d",                 m_reconFileName,   string(""), MAX_LAYERS, "Layer %d reconstructed YUV output file name\n"
                                                                                    "YUV writing is skipped if omitted")
 #if AVC_BASE
-  ("BLReconFile,-ibl",                               cfg_BLReconFile,  string(""), "BL reconstructed YUV input file name")
+  ("BLReconFile,-ibl",                              m_reconFileNameBL, string(""), "BL reconstructed YUV input file name")
 #endif
   ("TargetLayerId,-lid",                                        targetLayerId, -1, "Target layer id")
@@ -105,5 +98,5 @@
 #endif
 #else
-  ("ReconFile,o",               cfg_ReconFile,                         string(""), "reconstructed YUV output file name\n"
+  ("ReconFile,o",               m_reconFileName,                       string(""), "reconstructed YUV output file name\n"
                                                                                    "YUV writing is skipped if omitted")
 #endif
@@ -134,7 +127,7 @@
   po::setDefaults(opts);
   po::ErrorReporter err;
-  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv, err);
-
-  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
+  const list<const TChar*>& argv_unhandled = po::scanArgv(opts, argc, (const TChar**) argv, err);
+
+  for (list<const TChar*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
   {
     fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
@@ -163,6 +156,4 @@
   }
 
-  /* convert std::string to c string for compatability */
-  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
 #if SVC_EXTENSION
   if( targetLayerId < 0 )
@@ -204,23 +195,7 @@
   m_commonDecoderParams.setTargetOutputLayerSetIdx( olsIdx );
   m_commonDecoderParams.setTargetLayerId( targetLayerId );
-
-#if CONFORMANCE_BITSTREAM_MODE
-  for(Int layer = 0; layer < MAX_VPS_LAYER_IDX_PLUS1; layer++ )
-  {
-#else
-  for(UInt layer=0; layer<= m_tgtLayerId; layer++)
-  {
-    assert( layer < MAX_LAYERS );
-#endif
-    m_pchReconFile[layer] = cfg_ReconFile[layer].empty() ? NULL : strdup(cfg_ReconFile[layer].c_str());
-  }
-#if AVC_BASE
-  m_pchBLReconFile = cfg_BLReconFile.empty() ? NULL : strdup(cfg_BLReconFile.c_str());
-#endif
-#else
-  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
-#endif
-
-  if (!m_pchBitstreamFile)
+#endif
+
+  if (m_bitstreamFileName.empty())
   {
     fprintf(stderr, "No input file specified, aborting\n");
Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 1441)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 1442)
@@ -57,9 +57,9 @@
 {
 protected:
-  Char*         m_pchBitstreamFile;                     ///< input bitstream file name
+  std::string   m_bitstreamFileName;                    ///< input bitstream file name
 #if SVC_EXTENSION
-  Char*         m_pchReconFile [MAX_LAYERS];          ///< output reconstruction file name
+  std::string   m_reconFileName[MAX_LAYERS];            ///< output reconstruction file name
 #else
-  Char*         m_pchReconFile;                         ///< output reconstruction file name
+  std::string   m_reconFileName;                        ///< output reconstruction file name
 #endif
   Int           m_iSkipFrame;                           ///< counter for frames prior to the random access point to skip
@@ -84,5 +84,5 @@
 #if SVC_EXTENSION
 #if AVC_BASE
-  Char*         m_pchBLReconFile;                     ///< input BL reconstruction file name
+  std::string   m_reconFileNameBL;                     ///< input BL reconstruction file name
 #endif
   CommonDecoderParams             m_commonDecoderParams;
@@ -99,13 +99,15 @@
 public:
   TAppDecCfg()
-  : m_pchBitstreamFile(NULL)
+  : m_bitstreamFileName()
 #if !SVC_EXTENSION
-  , m_pchReconFile(NULL)
+  , m_reconFileName()
 #endif
   , m_iSkipFrame(0)
+  // m_outputBitDepth array initialised below
   , m_outputColourSpaceConvert(IPCOLOURSPACE_UNCHANGED)
   , m_iMaxTemporalLayer(-1)
   , m_decodedPictureHashSEIEnabled(0)
   , m_decodedNoDisplaySEIEnabled(false)
+  , m_targetDecLayerIdSet()
 #if Q0074_COLOUR_REMAPPING_SEI
   , m_colourRemapSEIEnabled(0)
@@ -115,4 +117,6 @@
   , m_forceDecodeBitDepth(0)
 #endif
+  , m_outputDecodedSEIMessagesFilename()
+  , m_bClipOutputVideoToRec709Range(false)
   {
     for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
@@ -124,5 +128,5 @@
   virtual ~TAppDecCfg() {}
 
-  Bool  parseCfg        ( Int argc, Char* argv[] );   ///< initialize option class from configuration
+  Bool  parseCfg        ( Int argc, TChar* argv[] );   ///< initialize option class from configuration
 
 #if SVC_EXTENSION
Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1441)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1442)
@@ -90,9 +90,5 @@
 Void TAppDecTop::destroy()
 {
-  if (m_pchBitstreamFile)
-  {
-    free (m_pchBitstreamFile);
-    m_pchBitstreamFile = NULL;
-  }
+  m_bitstreamFileName.clear();
 #if SVC_EXTENSION
 #if CONFORMANCE_BITSTREAM_MODE
@@ -102,9 +98,5 @@
 #endif
   {
-    if( m_pchReconFile[i] )
-    {
-      free ( m_pchReconFile[i] );
-      m_pchReconFile[i] = NULL;
-    }
+    m_reconFileName[i].clear();
 
     if( m_apcTDecTop[i] )
@@ -121,16 +113,8 @@
   }
 #if AVC_BASE
-  if( m_pchBLReconFile )
-  {
-    free ( m_pchBLReconFile );
-    m_pchBLReconFile = NULL;
-  }
-#endif
-#else
-  if (m_pchReconFile)
-  {
-    free (m_pchReconFile);
-    m_pchReconFile = NULL;
-  }
+  m_reconFileNameBL.clear();
+#endif
+#else
+  m_reconFileName.clear();
 #endif
 #if Q0074_COLOUR_REMAPPING_SEI
@@ -160,8 +144,8 @@
   TComList<TComPic*>* pcListPic = NULL;
 
-  ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary);
+  ifstream bitstreamFile(m_bitstreamFileName.c_str(), ifstream::in | ifstream::binary);
   if (!bitstreamFile)
   {
-    fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_pchBitstreamFile);
+    fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_bitstreamFileName.c_str());
     exit(EXIT_FAILURE);
   }
@@ -203,7 +187,7 @@
   TComPic pcBLPic;
   fstream streamYUV;
-  if( m_pchBLReconFile )
-  {
-    streamYUV.open( m_pchBLReconFile, fstream::in | fstream::binary );
+  if( !m_reconFileNameBL.empty() )
+  {
+    streamYUV.open( m_reconFileNameBL, fstream::in | fstream::binary );
   }
   TComList<TComPic*> *cListPic = m_apcTDecTop[0]->getListPic();
@@ -329,5 +313,5 @@
     if( pcListPic )
     {
-      if ( m_pchReconFile[curLayerId] && !openedReconFile[curLayerId] )
+      if ( !m_reconFileName[curLayerId].empty() && !openedReconFile[curLayerId] )
       {
         const BitDepths &bitDepths=pcListPic->front()->getSlice(0)->getBitDepths(); // use bit depths of first reconstructed picture.
@@ -339,5 +323,5 @@
           }
         }
-        m_apcTVideoIOYuvReconFile[curLayerId]->open( m_pchReconFile[curLayerId], true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
+        m_apcTVideoIOYuvReconFile[curLayerId]->open( m_reconFileName[curLayerId], true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
 
         openedReconFile[curLayerId] = true;
@@ -442,8 +426,8 @@
   TComList<TComPic*>* pcListPic = NULL;
 
-  ifstream bitstreamFile(m_pchBitstreamFile, ifstream::in | ifstream::binary);
+  ifstream bitstreamFile(m_bitstreamFileName.c_str(), ifstream::in | ifstream::binary);
   if (!bitstreamFile)
   {
-    fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_pchBitstreamFile);
+    fprintf(stderr, "\nfailed to open bitstream file `%s' for reading\n", m_bitstreamFileName.c_str());
     exit(EXIT_FAILURE);
   }
@@ -548,5 +532,5 @@
     if( pcListPic )
     {
-      if ( m_pchReconFile && !openedReconFile )
+      if ( (!m_reconFileName.empty()) && (!openedReconFile) )
       {
         const BitDepths &bitDepths=pcListPic->front()->getPicSym()->getSPS().getBitDepths(); // use bit depths of first reconstructed picture.
@@ -559,5 +543,5 @@
         }
 
-        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
+        m_cTVideoIOYuvReconFile.open( m_reconFileName, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
         openedReconFile = true;
       }
@@ -648,5 +632,5 @@
 #endif
   {
-    if ( m_pchReconFile[layer] )
+    if ( !m_reconFileName[layer].empty() )
     {
       m_apcTVideoIOYuvReconFile[layer]->close();
@@ -657,7 +641,7 @@
   }
 #else
-  if ( m_pchReconFile )
-  {
-    m_cTVideoIOYuvReconFile. close();
+  if ( !m_reconFileName.empty() )
+  {
+    m_cTVideoIOYuvReconFile.close();
   }
 
@@ -792,5 +776,5 @@
         numPicsNotYetDisplayed = numPicsNotYetDisplayed-2;
 #if SVC_EXTENSION
-        if ( m_pchReconFile[layerId] )
+        if ( !m_reconFileName[layerId].empty() )
         {
           const Window &conf = pcPicTop->getConformanceWindow();
@@ -826,5 +810,5 @@
         m_aiPOCLastDisplay[layerId] = pcPicBottom->getPOC();
 #else
-        if ( m_pchReconFile )
+        if ( !m_reconFileName.empty() )
         {
           const Window &conf = pcPicTop->getConformanceWindow();
@@ -901,5 +885,5 @@
         }
 #if SVC_EXTENSION
-        if( m_pchReconFile[layerId] )
+        if ( !m_reconFileName[layerId].empty() )
         {
           const Window &conf = pcPic->getConformanceWindow();
@@ -920,5 +904,5 @@
         m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
 #else
-        if ( m_pchReconFile )
+        if ( !m_reconFileName.empty() )
         {
           const Window &conf    = pcPic->getConformanceWindow();
@@ -1024,5 +1008,5 @@
         // write to file
 #if SVC_EXTENSION
-        if ( m_pchReconFile[layerId] )
+        if ( !m_reconFileName[layerId].empty() )
         {
           const Window &conf = pcPicTop->getConformanceWindow();
@@ -1043,5 +1027,5 @@
         m_aiPOCLastDisplay[layerId] = pcPicBottom->getPOC();
 #else
-        if ( m_pchReconFile )
+        if ( !m_reconFileName.empty() )
         {
           const Window &conf = pcPicTop->getConformanceWindow();
@@ -1103,5 +1087,5 @@
         // write to file
 #if SVC_EXTENSION
-        if ( m_pchReconFile[layerId] )
+        if ( !m_reconFileName[layerId].empty() )
         {
           const Window &conf = pcPic->getConformanceWindow();
@@ -1123,5 +1107,5 @@
         m_aiPOCLastDisplay[layerId] = pcPic->getPOC();
 #else
-        if ( m_pchReconFile )
+        if ( !m_reconFileName.empty() )
         {
           const Window &conf    = pcPic->getConformanceWindow();
@@ -1234,7 +1218,7 @@
 #if ALIGNED_BUMPING
 // Function outputs a picture, and marks it as not needed for output.
-Void TAppDecTop::xOutputAndMarkPic( TComPic *pic, const Char *reconFile, const Int layerId, Int &pocLastDisplay, DpbStatus &dpbStatus )
-{
-  if ( reconFile )
+Void TAppDecTop::xOutputAndMarkPic( TComPic *pic, std::string& reconFileName, const Int layerId, Int &pocLastDisplay, DpbStatus &dpbStatus )
+{
+  if( !reconFileName.empty() )
   {
     const Window &conf = pic->getConformanceWindow();
@@ -1488,5 +1472,5 @@
       TComPic *pic = *iterPic;
 
-      xOutputAndMarkPic( pic, m_pchReconFile[layerId], layerId, m_aiPOCLastDisplay[layerId], dpbStatus );
+      xOutputAndMarkPic( pic, m_reconFileName[layerId], layerId, m_aiPOCLastDisplay[layerId], dpbStatus );
 
 #if CONFORMANCE_BITSTREAM_MODE
@@ -1961,5 +1945,5 @@
 
     //Write remapped picture in decoding order
-    Char  cTemp[255];
+    TChar  cTemp[255];
     sprintf(cTemp, "seiColourRemappedPic_L%d_%dx%d_%dbits.yuv", layerId, iWidth, iHeight, storeCriSEI[layerId].m_colourRemapBitDepth );
     picColourRemapped.dump( cTemp, true, storeCriSEI[layerId].m_colourRemapBitDepth );
@@ -1974,5 +1958,5 @@
     if (storeCriSEI[layerId].m_colourRemapBitDepth == 8 || storeCriSEI[layerId].m_colourRemapBitDepth == 10)
     {
-      Char  cTemp[255];
+      TChar  cTemp[255];
       sprintf(cTemp, "seiColourRemappedPic_L%d_%dx%d_%dbits.yuv", layerId, pic.getWidth(COMPONENT_Y), pic.getHeight(COMPONENT_Y), storeCriSEI[layerId].m_colourRemapBitDepth );
       pic.dump( cTemp, true, storeCriSEI[layerId].m_colourRemapBitDepth );
Index: branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h	(revision 1441)
+++ branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h	(revision 1442)
@@ -136,5 +136,5 @@
   Void flushAllPictures(Int layerId, Bool outputPictures);
 
-  Void xOutputAndMarkPic( TComPic *pic, const Char *reconFile, const Int layerId, Int &pocLastDisplay, DpbStatus &dpbStatus);
+  Void xOutputAndMarkPic( TComPic *pic, std::string& reconFileName, const Int layerId, Int &pocLastDisplay, DpbStatus &dpbStatus);
   Void outputAllPictures(Int layerId, Bool notOutputCurrAu);
   Void xFindDPBStatus( std::vector<Int> &listOfPocs
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1441)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1442)
@@ -110,10 +110,9 @@
 TAppEncCfg::TAppEncCfg()
 #if AVC_BASE
-: m_nonHEVCBaseLayerFlag(0)
+: m_nonHEVCBaseLayerFlag(false)
 #endif
 , m_maxTidRefPresentFlag(1)
 , m_defaultTargetOutputLayerIdc (-1)
 , m_numOutputLayerSets          (-1)
-, m_pchBitstreamFile()
 , m_inputColourSpaceConvert(IPCOLOURSPACE_UNCHANGED)
 , m_snrInternalColourSpace(false)
@@ -126,12 +125,7 @@
 #else
 TAppEncCfg::TAppEncCfg()
-: m_pchInputFile()
-, m_pchBitstreamFile()
-, m_pchReconFile()
-, m_inputColourSpaceConvert(IPCOLOURSPACE_UNCHANGED)
+: m_inputColourSpaceConvert(IPCOLOURSPACE_UNCHANGED)
 , m_snrInternalColourSpace(false)
 , m_outputInternalColourSpace(false)
-, m_pchdQPFile()
-, m_scalingListFile()
 {
   m_aidQP = NULL;
@@ -164,13 +158,5 @@
     m_targetPivotValue = NULL;
   }
-
-  free(m_pchInputFile);
-#endif
-  free(m_pchBitstreamFile);
-#if !SVC_EXTENSION  
-  free(m_pchReconFile);
-  free(m_pchdQPFile);
-  free(m_scalingListFile);
-#endif
+#endif  
 }
 
@@ -240,5 +226,5 @@
 }
 
-Bool confirmPara(Bool bflag, const Char* message);
+Bool confirmPara(Bool bflag, const TChar* message);
 
 static inline ChromaFormat numberToChromaFormat(const Int val)
@@ -254,33 +240,7 @@
 }
 
-#if SVC_EXTENSION
-void TAppEncCfg::getDirFilename(string& filename, string& dir, const string path)
-{
-  size_t pos = path.find_last_of("\\");
-  if(pos != std::string::npos)
-  {
-    filename.assign(path.begin() + pos + 1, path.end());
-    dir.assign(path.begin(), path.begin() + pos + 1);
-  }
-  else
-  {
-    pos = path.find_last_of("/");
-    if(pos != std::string::npos)
-    {
-      filename.assign(path.begin() + pos + 1, path.end());
-      dir.assign(path.begin(), path.begin() + pos + 1);
-    }
-    else
-    {
-      filename = path;
-      dir.assign("");
-    }
-  }
-}
-#endif
-
 static const struct MapStrToProfile
 {
-  const Char* str;
+  const TChar* str;
   Profile::Name value;
 }
@@ -302,5 +262,5 @@
 static const struct MapStrToExtendedProfile
 {
-  const Char* str;
+  const TChar* str;
   ExtendedProfileName value;
 }
@@ -366,5 +326,5 @@
 static const struct MapStrToTier
 {
-  const Char* str;
+  const TChar* str;
   Level::Tier value;
 }
@@ -377,5 +337,5 @@
 static const struct MapStrToLevel
 {
-  const Char* str;
+  const TChar* str;
   Level::Name value;
 }
@@ -410,5 +370,5 @@
 static const struct MapStrToCostMode
 {
-  const Char* str;
+  const TChar* str;
   CostMode    value;
 }
@@ -423,5 +383,5 @@
 static const struct MapStrToScalingListMode
 {
-  const Char* str;
+  const TChar* str;
   ScalingListMode value;
 }
@@ -526,5 +486,5 @@
   SMultiValueInput<T> &operator=(const SMultiValueInput<T> &userValues) { values=userValues.values; return *this; }
 
-  T readValue(const Char *&pStr, Bool &bSuccess);
+  T readValue(const TChar *&pStr, Bool &bSuccess);
 
   istream& readValues(std::istream &in);
@@ -538,7 +498,7 @@
 
 template<>
-UInt SMultiValueInput<UInt>::readValue(const Char *&pStr, Bool &bSuccess)
+UInt SMultiValueInput<UInt>::readValue(const TChar *&pStr, Bool &bSuccess)
 {
-  Char *eptr;
+  TChar *eptr;
   UInt val=strtoul(pStr, &eptr, 0);
   pStr=eptr;
@@ -548,7 +508,7 @@
 
 template<>
-Int SMultiValueInput<Int>::readValue(const Char *&pStr, Bool &bSuccess)
+Int SMultiValueInput<Int>::readValue(const TChar *&pStr, Bool &bSuccess)
 {
-  Char *eptr;
+  TChar *eptr;
   Int val=strtol(pStr, &eptr, 0);
   pStr=eptr;
@@ -558,7 +518,7 @@
 
 template<>
-Double SMultiValueInput<Double>::readValue(const Char *&pStr, Bool &bSuccess)
+Double SMultiValueInput<Double>::readValue(const TChar *&pStr, Bool &bSuccess)
 {
-  Char *eptr;
+  TChar *eptr;
   Double val=strtod(pStr, &eptr);
   pStr=eptr;
@@ -568,7 +528,7 @@
 
 template<>
-Bool SMultiValueInput<Bool>::readValue(const Char *&pStr, Bool &bSuccess)
+Bool SMultiValueInput<Bool>::readValue(const TChar *&pStr, Bool &bSuccess)
 {
-  Char *eptr;
+  TChar *eptr;
   Int val=strtol(pStr, &eptr, 0);
   pStr=eptr;
@@ -588,5 +548,5 @@
   if (!str.empty())
   {
-    const Char *pStr=str.c_str();
+    const TChar *pStr=str.c_str();
     // soak up any whitespace
     for(;isspace(*pStr);pStr++);
@@ -703,52 +663,18 @@
 // ====================================================================================================================
 
-#if SVC_EXTENSION
 /** \param  argc        number of arguments
     \param  argv        array of arguments
     \retval             true when success
  */
-Bool TAppEncCfg::parseCfgNumLayersAndInit( Int argc, Char* argv[] )
-{
-  po::Options opts;
-  opts.addOptions()
-  ("c",    po::parseConfigFile, "configuration file name")
-  ("NumLayers",                                     m_numLayers,                                             1, "Number of layers to code")
-  ;
-
-  po::setDefaults(opts);
-  po::ErrorReporter err;
-  err.verbose = false;
-  po::scanArgv(opts, argc, (const Char**) argv, err);
-
-  if( m_numLayers <= 0 )
-  {
-    printf("Wrong number of layers %d\n", m_numLayers);
-    return false;
-  }
-
-  for( Int layer = 0; layer < m_numLayers; layer++ )
-  {
-    m_apcLayerCfg[layer] = new TAppEncLayerCfg;
-    m_apcLayerCfg[layer]->setAppEncCfg(this);
-  }
-
-  return true;
-}
-#endif
-
-/** \param  argc        number of arguments
-    \param  argv        array of arguments
-    \retval             true when success
- */
-Bool TAppEncCfg::parseCfg( Int argc, Char* argv[] )
+Bool TAppEncCfg::parseCfg( Int argc, TChar* argv[] )
 {
   Bool do_help = false;
   
-#if SVC_EXTENSION
-  string  cfg_BitstreamFile;
-  string* cfg_InputFile      [MAX_LAYERS];
-  string* cfg_ReconFile      [MAX_LAYERS];
-  Double* cfg_fQP            [MAX_LAYERS];
-  Int*    cfg_layerId        [MAX_LAYERS];
+#if SVC_EXTENSION  
+  string* cfg_InputFile     [MAX_LAYERS];
+  string* cfg_ReconFile     [MAX_LAYERS];
+  string* cfg_dQPFileName   [MAX_LAYERS];
+  Double* cfg_fQP           [MAX_LAYERS];
+  Int*    cfg_layerId       [MAX_LAYERS];
   Int*    cfg_repFormatIdx  [MAX_LAYERS];
   Int*    cfg_SourceWidth   [MAX_LAYERS]; 
@@ -848,5 +774,5 @@
   Int*    cfg_maxTidIlRefPicsPlus1[MAX_LAYERS]; 
 #if Q0074_COLOUR_REMAPPING_SEI
-  string* cfg_colourRemapSEIFileRoot[MAX_LAYERS];
+  string* cfg_colourRemapSEIFileName[MAX_LAYERS];
 #endif
   Int*    cfg_waveFrontSynchro[MAX_LAYERS];
@@ -861,9 +787,10 @@
   for( UInt layer = 0; layer < m_numLayers; layer++ )
   {
-    cfg_InputFile[layer]    = &m_apcLayerCfg[layer]->m_cInputFile;
-    cfg_ReconFile[layer]    = &m_apcLayerCfg[layer]->m_cReconFile;
+    cfg_InputFile[layer]    = &m_apcLayerCfg[layer]->m_inputFileName;
+    cfg_ReconFile[layer]    = &m_apcLayerCfg[layer]->m_reconFileName;
+    cfg_dQPFileName[layer]  = &m_apcLayerCfg[layer]->m_dQPFileName;
     cfg_fQP[layer]          = &m_apcLayerCfg[layer]->m_fQP;
 #if Q0074_COLOUR_REMAPPING_SEI
-    cfg_colourRemapSEIFileRoot[layer] = &m_apcLayerCfg[layer]->m_colourRemapSEIFileRoot;
+    cfg_colourRemapSEIFileName[layer] = &m_apcLayerCfg[layer]->m_colourRemapSEIFileName;
 #endif
     cfg_repFormatIdx[layer]         = &m_apcLayerCfg[layer]->m_repFormatIdx;
@@ -979,18 +906,9 @@
   string* cfg_listOfLayerPTLOfOlss   = new string[MAX_VPS_OUTPUT_LAYER_SETS_PLUS1];
 #if AVC_BASE
-  string  cfg_BLInputFile;
+  string  m_inputFileNameBL;
 #endif
 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
-  string  cfg_tileSets;
-#endif
-#else //SVC_EXTENSION
-  string cfg_InputFile;
-  string cfg_BitstreamFile;
-  string cfg_ReconFile;
-  string cfg_dQPFile;
-#if Q0074_COLOUR_REMAPPING_SEI
-  string cfg_colourRemapSEIFileRoot;
-#endif
-  string cfg_ScalingListFile;
+  string  m_tileSets;
+#endif 
 #endif //SVC_EXTENSION
 
@@ -1121,6 +1039,6 @@
   ("ScalabilityMask3",                              m_scalabilityMask[AUX_ID],                              0, "scalability_mask[3] (auxiliary pictures)" )
 #endif
-  ("BitstreamFile,b",                               cfg_BitstreamFile,                             string(""), "Bitstream output file name")
-  ("NumRefLocationOffsets%d",                       cfg_numRefLayerLocationOffsets,            0, m_numLayers,  "Number of reference layer offset sets ")
+  ("BitstreamFile,b",                               m_bitstreamFileName,                           string(""), "Bitstream output file name")
+  ("NumRefLocationOffsets%d",                       cfg_numRefLayerLocationOffsets,            0, m_numLayers, "Number of reference layer offset sets ")
   ("RefLocationOffsetLayerId%d",                    cfg_refLocationOffsetLayerIdPtr,  string(""), m_numLayers, "Layer ID of reference location offset")
   ("ScaledRefLayerLeftOffset%d",                    cfg_scaledRefLayerLeftOffsetPtr,  string(""), m_numLayers, "Horizontal offset of top-left luma sample of scaled base layer picture with respect to"
@@ -1148,5 +1066,5 @@
   ("PhaseVerChroma%d",                              cfg_phaseVerChromaPtr,            string(""), m_numLayers, "chroma shift in the vertical   direction used in resampling proces")
 #if Q0074_COLOUR_REMAPPING_SEI
-  ("SEIColourRemappingInfoFileRoot%d",              cfg_colourRemapSEIFileRoot,       string(""), m_numLayers, "Colour Remapping Information SEI parameters file name for layer %d")
+  ("SEIColourRemappingInfoFileRoot%d",              cfg_colourRemapSEIFileName,       string(""), m_numLayers, "Colour Remapping Information SEI parameters file name for layer %d")
 #endif
   ("InputBitDepth%d",                                cfg_InputBitDepth[CHANNEL_TYPE_LUMA],     8, m_numLayers, "Bit-depth of input file for layer %d")
@@ -1165,6 +1083,6 @@
   ("InterLayerWeightedPred",                          m_useInterLayerWeightedPred,                      false, "enable IL WP parameters estimation at encoder" )  
 #if AVC_BASE
-  ("NonHEVCBase,-nonhevc",                            m_nonHEVCBaseLayerFlag,                               0, "BL is available but not internal")
-  ("InputBLFile,-ibl",                                cfg_BLInputFile,                             string(""), "Base layer rec YUV input file name")
+  ("NonHEVCBase,-nonhevc",                            m_nonHEVCBaseLayerFlag,                           false, "BL is available but not internal")
+  ("InputBLFile,-ibl",                                m_inputFileNameBL,                           string(""), "Base layer rec YUV input file name")
 #endif
   ("EnableElRapB,-use-rap-b",                         m_elRapSliceBEnabled,                             false, "Set ILP over base-layer I picture to B picture (default is P picture)")
@@ -1172,7 +1090,7 @@
   ("ChromaFormatIDC,-cf",                             tmpChromaFormat,                                      0, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
 #else //SVC_EXTENSION
-  ("InputFile,i",                                     cfg_InputFile,                               string(""), "Original YUV input file name")
-  ("BitstreamFile,b",                                 cfg_BitstreamFile,                           string(""), "Bitstream output file name")
-  ("ReconFile,o",                                     cfg_ReconFile,                               string(""), "Reconstructed YUV output file name")
+  ("InputFile,i",                                     m_inputFileName,                             string(""), "Original YUV input file name")
+  ("BitstreamFile,b",                                 m_bitstreamFileName,                         string(""), "Bitstream output file name")
+  ("ReconFile,o",                                     m_reconFileName,                             string(""), "Reconstructed YUV output file name")
   ("SourceWidth,-wdt",                                m_iSourceWidth,                                       0, "Source picture width")
   ("SourceHeight,-hgt",                               m_iSourceHeight,                                      0, "Source picture height")
@@ -1217,5 +1135,5 @@
   ("FrameRate,-fr",                                   m_iFrameRate,                                         0, "Frame rate")
 #if Q0074_COLOUR_REMAPPING_SEI
-  ("SEIColourRemappingInfoFileRoot",                  cfg_colourRemapSEIFileRoot, string(""), "Colour Remapping Information SEI parameters file name")
+  ("SEIColourRemappingInfoFileRoot",                  m_colourRemapSEIFileName,                    string(""), "Colour Remapping Information SEI parameters file name")
 #endif
 #endif //SVC_EXTENSION
@@ -1362,6 +1280,8 @@
   ("AdaptiveQP,-aq",                                  m_bUseAdaptiveQP,                                 false, "QP adaptation based on a psycho-visual model")
   ("MaxQPAdaptationRange,-aqr",                       m_iQPAdaptationRange,                                 6, "QP adaptation range")
-#if !SVC_EXTENSION
-  ("dQPFile,m",                                       cfg_dQPFile,                                 string(""), "dQP file name")
+#if SVC_EXTENSION
+  ("dQPFile,m",                                       cfg_dQPFileName,                string(""), m_numLayers, "dQP file name")
+#else
+  ("dQPFile,m",                                       m_dQPFileName,                               string(""), "dQP file name")
 #endif
   ("RDOQ",                                            m_useRDOQ,                                         true)
@@ -1452,5 +1372,5 @@
   ("WaveFrontSynchro",                                m_iWaveFrontSynchro,                                  0, "0: no synchro; 1 synchro with top-right-right")
   ("ScalingList",                                     m_useScalingListId,                    SCALING_LIST_OFF, "0/off: no scaling list, 1/default: default scaling lists, 2/file: scaling lists specified in ScalingListFile")
-  ("ScalingListFile",                                 cfg_ScalingListFile,                         string(""), "Scaling list file name. Use an empty string to produce help.")
+  ("ScalingListFile",                                 m_scalingListFileName,                       string(""), "Scaling list file name. Use an empty string to produce help.")
 #endif
   ("SignHideFlag,-SBH",                               m_signHideFlag,                                    true)
@@ -1714,5 +1634,5 @@
   ("SEIInterLayerConstrainedTileSets",       m_interLayerConstrainedTileSetsSEIEnabled, false, "Control generation of inter layer constrained tile sets SEI message")
   ("IlNumSetsInMessage",                     m_ilNumSetsInMessage,                         0u, "Number of inter layer constrained tile sets")
-  ("TileSetsArray",                          cfg_tileSets,                         string(""), "Array containing tile sets params (TopLeftTileIndex, BottonRightTileIndex and ilcIdc for each set) ")
+  ("TileSetsArray",                          m_tileSets,                           string(""), "Array containing tile sets params (TopLeftTileIndex, BottonRightTileIndex and ilcIdc for each set) ")
 #endif
   ("AltOutputLayerFlag",                     m_altOutputLayerFlag,                      false, "Specifies the value of alt_output_layer_flag in VPS extension")
@@ -1753,7 +1673,14 @@
   po::setDefaults(opts);
   po::ErrorReporter err;
-  const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv, err);
-
-#if SVC_EXTENSION
+  const list<const TChar*>& argv_unhandled = po::scanArgv(opts, argc, (const TChar**) argv, err);
+
+#if SVC_EXTENSION
+#if AVC_BASE
+  if( m_nonHEVCBaseLayerFlag )
+  {
+    *cfg_InputFile[0] = m_inputFileNameBL;
+  }
+#endif
+
   for (Int i=1; i<m_numLayers; i++)
   {
@@ -1775,5 +1702,5 @@
 #endif 
   
-  for (list<const Char*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
+  for (list<const TChar*>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
   {
     fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
@@ -1799,27 +1726,4 @@
    * Set any derived parameters
    */
-  /* convert std::string to c string for compatability */
-#if SVC_EXTENSION
-#if AVC_BASE
-  if( m_nonHEVCBaseLayerFlag )
-  {
-    *cfg_InputFile[0] = cfg_BLInputFile;
-  }
-#endif
-#else //SVC_EXTENSION
-  m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str());
-#endif
-  m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
-#if !SVC_EXTENSION
-  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
-  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
-#if Q0074_COLOUR_REMAPPING_SEI
-  if( !cfg_colourRemapSEIFileRoot.empty() )
-  {
-    m_colourRemapSEIFileRoot = strdup(cfg_colourRemapSEIFileRoot.c_str());
-  }
-#endif
-#endif //SVC_EXTENSION
-
 
   m_adIntraLambdaModifier = cfg_adIntraLambdaModifier.values;
@@ -1895,10 +1799,9 @@
     m_tileRowHeight.clear();
   }
-    
-  /* rules for input, output and internal bitdepths as per help text */
+  
 #if SVC_EXTENSION
   for( Int layer = 0; layer < m_numLayers; layer++ )
   {
-    m_apcLayerCfg[layer]->m_scalingListFile = cfg_ScalingListFile[layer].empty() ? NULL : strdup(cfg_ScalingListFile[layer].c_str());
+    m_apcLayerCfg[layer]->m_scalingListFileName = cfg_ScalingListFile[layer].empty() ? NULL : strdup(cfg_ScalingListFile[layer].c_str());
 
     if( m_apcLayerCfg[layer]->m_layerId < 0 )
@@ -2034,6 +1937,4 @@
   }
 #else
-  m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
-
   /* rules for input, output and internal bitdepths as per help text */
   if (m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA  ] == 0)
@@ -2436,5 +2337,5 @@
     }
 
-    Char* pSamplePredRefLayerIds = cfg_samplePredRefLayerIds[layer].empty() ? NULL: strdup(cfg_samplePredRefLayerIds[layer].c_str());
+    TChar* pSamplePredRefLayerIds = cfg_samplePredRefLayerIds[layer].empty() ? NULL: strdup(cfg_samplePredRefLayerIds[layer].c_str());
     if( m_apcLayerCfg[layer]->m_numSamplePredRefLayers > 0 )
     {
@@ -2471,5 +2372,5 @@
     }
 
-    Char* pMotionPredRefLayerIds = cfg_motionPredRefLayerIds[layer].empty() ? NULL: strdup(cfg_motionPredRefLayerIds[layer].c_str());
+    TChar* pMotionPredRefLayerIds = cfg_motionPredRefLayerIds[layer].empty() ? NULL: strdup(cfg_motionPredRefLayerIds[layer].c_str());
     if( m_apcLayerCfg[layer]->m_numMotionPredRefLayers > 0 )
     {
@@ -2506,9 +2407,9 @@
     }
 
-    Char* pPredLayerIds = cfg_predLayerIds[layer].empty() ? NULL: strdup(cfg_predLayerIds[layer].c_str());
+    TChar* pPredLayerIds = cfg_predLayerIds[layer].empty() ? NULL: strdup(cfg_predLayerIds[layer].c_str());
     if( m_apcLayerCfg[layer]->m_numActiveRefLayers > 0 )
     {
-      char *refLayerId;
-      int  i=0;
+      TChar *refLayerId;
+      Int  i=0;
       m_apcLayerCfg[layer]->m_predLayerIds = new Int[m_apcLayerCfg[layer]->m_numActiveRefLayers];
       refLayerId = strtok(pPredLayerIds, " ,-");
@@ -2661,7 +2562,8 @@
     Double& m_fQP                   = m_apcLayerCfg[layer]->m_fQP;
 
-    Char* m_pchdQPFile              = m_apcLayerCfg[layer]->m_pchdQPFile;
+    string& m_dQPFileName           = m_apcLayerCfg[layer]->m_dQPFileName;
     Int* m_internalBitDepth         = m_apcLayerCfg[layer]->m_internalBitDepth;
 #endif //SVC_EXTENSION
+
   switch (m_conformanceWindowMode)
   {
@@ -2778,7 +2680,8 @@
 
   // reading external dQP description from file
-  if ( m_pchdQPFile )
-  {
-    FILE* fpt=fopen( m_pchdQPFile, "r" );
+  if ( !m_dQPFileName.empty() )
+  {
+    FILE* fpt=fopen( m_dQPFileName.c_str(), "r" );
+
     if ( fpt )
     {
@@ -2965,7 +2868,7 @@
       exit( EXIT_FAILURE );
     }
-    Char* pTileSets = cfg_tileSets.empty() ? NULL : strdup(cfg_tileSets.c_str());
+    TChar* pTileSets = m_tileSets.empty() ? NULL : strdup(m_tileSets.c_str());
     int i = 0;
-    char *topLeftTileIndex = strtok(pTileSets, " ,");
+    TChar *topLeftTileIndex = strtok(pTileSets, " ,");
     while(topLeftTileIndex != NULL)
     {
@@ -3161,5 +3064,5 @@
 #define xConfirmPara(a,b) check_failed |= confirmPara(a,b)
 
-  xConfirmPara(m_pchBitstreamFile==NULL, "A bitstream file name must be specified (BitstreamFile)");
+  xConfirmPara(m_bitstreamFileName.empty(), "A bitstream file name must be specified (BitstreamFile)");
   const UInt maxBitDepth=(m_chromaFormatIDC==CHROMA_400) ? m_internalBitDepth[CHANNEL_TYPE_LUMA] : std::max(m_internalBitDepth[CHANNEL_TYPE_LUMA], m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
   xConfirmPara(m_bitDepthConstraint<maxBitDepth, "The internalBitDepth must not be greater than the bitDepthConstraint value");
@@ -4394,5 +4297,5 @@
 }
 
-const Char *profileToString(const Profile::Name profile)
+const TChar *profileToString(const Profile::Name profile)
 {
   static const UInt numberOfProfiles = sizeof(strToProfile)/sizeof(*strToProfile);
@@ -4454,6 +4357,6 @@
     Int& m_iSourceHeight                   = m_apcLayerCfg[layerIdx]->m_iSourceHeight;
 
-    const Char* m_pchInputFile             = m_apcLayerCfg[layerIdx]->m_cInputFile.c_str();
-    const Char* m_pchReconFile             = m_apcLayerCfg[layerIdx]->m_cReconFile.c_str();
+    string& m_inputFileName                = m_apcLayerCfg[layerIdx]->m_inputFileName;
+    string& m_reconFileName                = m_apcLayerCfg[layerIdx]->m_reconFileName;
 
     Int& m_iFrameRate                      = m_apcLayerCfg[layerIdx]->m_iFrameRate;
@@ -4499,5 +4402,5 @@
 #endif
 
-  printf("Input          File                    : %s\n", m_pchInputFile          );
+  printf("Input          File                    : %s\n", m_inputFileName.c_str()          );
 
 #if SVC_EXTENSION
@@ -4507,5 +4410,5 @@
 #endif
 
-  printf("Bitstream      File                    : %s\n", m_pchBitstreamFile      );
+  printf("Bitstream      File                    : %s\n", m_bitstreamFileName.c_str()      );
 
 #if SVC_EXTENSION
@@ -4514,6 +4417,6 @@
     {
 #endif
-
-  printf("Reconstruction File                    : %s\n", m_pchReconFile          );
+  
+  printf("Reconstruction File                    : %s\n", m_reconFileName.c_str()          );
   printf("Real     Format                        : %dx%d %dHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, m_iFrameRate );
   printf("Internal Format                        : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
@@ -4801,5 +4704,5 @@
   }
 
-  printf("\nSHVC TOOL CFG: ");
+  printf("SHVC TOOL CFG: ");
   printf("ElRapSliceType: %c-slice ", m_elRapSliceBEnabled ? 'B' : 'P');
   printf("REF_IDX_ME_ZEROMV: %d ", REF_IDX_ME_ZEROMV);
@@ -4822,5 +4725,5 @@
 }
 
-Bool confirmPara(Bool bflag, const Char* message)
+Bool confirmPara(Bool bflag, const TChar* message)
 {
   if (!bflag)
@@ -4836,8 +4739,8 @@
 Void TAppEncCfg::cfgStringToArray(Int **arr, string const cfgString, Int const numEntries, const char* logString)
 {
-  Char *tempChar = cfgString.empty() ? NULL : strdup(cfgString.c_str());
+  TChar *tempChar = cfgString.empty() ? NULL : strdup(cfgString.c_str());
   if( numEntries > 0 )
   {
-    Char *arrayEntry;
+    TChar *arrayEntry;
     Int i = 0;
     *arr = new Int[numEntries];
@@ -4918,8 +4821,8 @@
 Void TAppEncCfg::cfgStringToArrayNumEntries(Int **arr, string const cfgString, Int &numEntries, const char* logString)
 {
-  Char *tempChar = cfgString.empty() ? NULL : strdup(cfgString.c_str());
+  TChar *tempChar = cfgString.empty() ? NULL : strdup(cfgString.c_str());
   if (numEntries > 0)
   {
-    Char *arrayEntry;
+    TChar *arrayEntry;
     Int i = 0;
     *arr = new Int[numEntries];
@@ -4983,4 +4886,60 @@
   return false;
 }
+
+void TAppEncCfg::getDirFilename(string& filename, string& dir, const string path)
+{
+  size_t pos = path.find_last_of("\\");
+  if(pos != std::string::npos)
+  {
+    filename.assign(path.begin() + pos + 1, path.end());
+    dir.assign(path.begin(), path.begin() + pos + 1);
+  }
+  else
+  {
+    pos = path.find_last_of("/");
+    if(pos != std::string::npos)
+    {
+      filename.assign(path.begin() + pos + 1, path.end());
+      dir.assign(path.begin(), path.begin() + pos + 1);
+    }
+    else
+    {
+      filename = path;
+      dir.assign("");
+    }
+  }
+}
+
+/** \param  argc        number of arguments
+    \param  argv        array of arguments
+    \retval             true when success
+ */
+Bool TAppEncCfg::parseCfgNumLayersAndInit( Int argc, TChar* argv[] )
+{
+  po::Options opts;
+  opts.addOptions()
+  ("c",    po::parseConfigFile, "configuration file name")
+  ("NumLayers",                                     m_numLayers,                                             1, "Number of layers to code")
+  ;
+
+  po::setDefaults(opts);
+  po::ErrorReporter err;
+  err.verbose = false;
+  po::scanArgv(opts, argc, (const TChar**) argv, err);
+
+  if( m_numLayers <= 0 )
+  {
+    printf("Wrong number of layers %d\n", m_numLayers);
+    return false;
+  }
+
+  for( Int layer = 0; layer < m_numLayers; layer++ )
+  {
+    m_apcLayerCfg[layer] = new TAppEncLayerCfg;
+    m_apcLayerCfg[layer]->setAppEncCfg(this);
+  }
+
+  return true;
+}
 #endif //SVC_EXTENSION
 //! \}
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1441)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1442)
@@ -65,5 +65,5 @@
   Int       m_scalabilityMask[MAX_VPS_NUM_SCALABILITY_TYPES]; ///< scalability_mask
 #if AVC_BASE
-  Int       m_nonHEVCBaseLayerFlag;                           ///< non HEVC BL
+  Bool      m_nonHEVCBaseLayerFlag;                           ///< non HEVC BL
 #endif
   Bool      m_maxTidRefPresentFlag; 
@@ -82,9 +82,9 @@
   std::vector< std::vector<Int> > m_listOfOutputLayers;
 #else
-  Char*     m_pchInputFile;                                   ///< source file name
-#endif
-  Char*     m_pchBitstreamFile;                               ///< output bitstream file
-#if !SVC_EXTENSION
-  Char*     m_pchReconFile;                                   ///< output reconstruction file
+  std::string m_inputFileName;                                ///< source file name
+#endif
+  std::string m_bitstreamFileName;                            ///< output bitstream file
+#if !SVC_EXTENSION
+  std::string m_reconFileName;                                ///< output reconstruction file
 #endif
   // Lambda modifiers
@@ -199,5 +199,5 @@
   Double    m_fQP;                                            ///< QP value of key-picture (floating point)
   Int       m_iQP;                                            ///< QP value of key-picture (integer)
-  Char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
+  std::string m_dQPFileName;                                  ///< QP offset for each slice (initialized from external file)
   Int*      m_aidQP;                                          ///< array of slice QP values
 #endif
@@ -419,5 +419,5 @@
 #if !SVC_EXTENSION
   ScalingListMode m_useScalingListId;                         ///< using quantization matrix
-  Char*     m_scalingListFile;                                ///< quantization matrix file name
+  std::string m_scalingListFileName;                          ///< quantization matrix file name
 #endif
 
@@ -495,5 +495,5 @@
 #if Q0074_COLOUR_REMAPPING_SEI
 #if !SVC_EXTENSION
-  string    m_colourRemapSEIFileRoot;
+  string    m_colourRemapSEIFileName;
 #endif
 #endif
@@ -567,8 +567,8 @@
   Void  create    ();                                         ///< create option handling class
   Void  destroy   ();                                         ///< destroy option handling class
-  Bool  parseCfg  ( Int argc, Char* argv[] );                 ///< parse configuration file to fill member variables
+  Bool  parseCfg  ( Int argc, TChar* argv[] );                ///< parse configuration file to fill member variables
   
 #if SVC_EXTENSION
-  Bool parseCfgNumLayersAndInit( Int argc, Char* argv[] );    ///< parse configuration file to to get number of layers and allocate memory
+  Bool parseCfgNumLayersAndInit( Int argc, TChar* argv[] );   ///< parse configuration file to to get number of layers and allocate memory
   Int  getNumFrameToBeEncoded()                               { return m_framesToBeEncoded;                          }
   Int  getNumLayer()                                          { return m_numLayers;                                  }
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 1441)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.cpp	(revision 1442)
@@ -42,14 +42,7 @@
 #if SVC_EXTENSION
 TAppEncLayerCfg::TAppEncLayerCfg()
-: m_cInputFile(string(""))
-, m_cReconFile(string(""))
-, m_conformanceWindowMode(0)
-, m_scalingListFile(NULL)
-, m_pchdQPFile(NULL)
+: m_conformanceWindowMode(0)
 , m_aidQP(NULL)
 , m_repFormatIdx(-1)
-#if Q0074_COLOUR_REMAPPING_SEI
-, m_colourRemapSEIFileRoot(string(""))
-#endif
 {
 #if Q0074_COLOUR_REMAPPING_SEI
@@ -107,5 +100,4 @@
   }
 #endif
-  free(m_scalingListFile);
 }
 
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 1441)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 1442)
@@ -28,6 +28,6 @@
 protected:
   // file I/O0
-  string    m_cInputFile;                                     ///< source file name
-  string    m_cReconFile;                                     ///< output reconstruction file
+  string    m_inputFileName;                                     ///< source file name
+  string    m_reconFileName;                                     ///< output reconstruction file
   Int       m_layerId;                                        ///< layer Id
   Int       m_iFrameRate;                                     ///< source frame-rates (Hz)
@@ -95,5 +95,5 @@
 
   ScalingListMode m_useScalingListId;                         ///< using quantization matrix
-  Char*     m_scalingListFile;                                ///< quantization matrix file name
+  std::string m_scalingListFileName;                          ///< quantization matrix file name
 
   Int       m_maxTidIlRefPicsPlus1;
@@ -102,5 +102,5 @@
 
   Int       m_iQP;                                            ///< QP value of key-picture (integer)
-  Char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
+  std::string m_dQPFileName;                                  ///< QP offset for each slice (initialized from external file)
   Int*      m_aidQP;                                          ///< array of slice QP values
   TAppEncCfg* m_cAppEncCfg;                                   ///< pointer to app encoder config
@@ -130,5 +130,5 @@
   Int       m_repFormatIdx;
 #if Q0074_COLOUR_REMAPPING_SEI
-  string    m_colourRemapSEIFileRoot;                           ///< Colour Remapping Information SEI message parameters file
+  string    m_colourRemapSEIFileName;                         ///< Colour Remapping Information SEI message parameters file
   Int       m_colourRemapSEIId;
   Bool      m_colourRemapSEICancelFlag;
@@ -168,7 +168,7 @@
   Void    setAppEncCfg(TAppEncCfg* p) {m_cAppEncCfg = p;          }
 
-  string  getInputFile()              {return m_cInputFile;       }
-  string  getReconFile()              {return m_cReconFile;       }
-  Double  getFloatQP()                {return m_fQP;              }
+  string& getInputFileName()          {return m_inputFileName;       }
+  string& getReconFileName()          {return m_reconFileName;       }
+  Double  getFloatQP()                {return m_fQP;                 }
   Int     getConfWinLeft()            {return m_confWinLeft;         }
   Int     getConfWinRight()           {return m_confWinRight;        }
Index: branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1441)
+++ branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1442)
@@ -499,6 +499,8 @@
 
     ScalingListMode& m_useScalingListId                         = m_apcLayerCfg[layer]->m_useScalingListId;
-    Char*          m_scalingListFile                            = m_apcLayerCfg[layer]->m_scalingListFile;
+    string&        m_scalingListFileName                        = m_apcLayerCfg[layer]->m_scalingListFileName;
     Bool&          m_bUseSAO                                    = m_apcLayerCfg[layer]->m_bUseSAO;
+
+    string&        m_colourRemapSEIFileName                     = m_apcLayerCfg[layer]->m_colourRemapSEIFileName;
 #endif
 
@@ -785,5 +787,5 @@
   m_cTEncTop.setTMVPModeId                                        ( m_TMVPModeId );
   m_cTEncTop.setUseScalingListId                                  ( m_useScalingListId  );
-  m_cTEncTop.setScalingListFile                                   ( m_scalingListFile   );
+  m_cTEncTop.setScalingListFileName                               ( m_scalingListFileName );
   m_cTEncTop.setSignHideFlag                                      ( m_signHideFlag);
   m_cTEncTop.setUseRateCtrl                                       ( m_RCEnableRateControl );
@@ -843,9 +845,5 @@
 
 #if Q0074_COLOUR_REMAPPING_SEI
-#if SVC_EXTENSION
-  m_cTEncTop.xSetCRISEIFileRoot                                    ( const_cast<Char*>(m_apcLayerCfg[layer]->m_colourRemapSEIFileRoot.c_str()) );
-#else
-  m_cTEncTop.xSetCRISEIFileRoot                                    ( const_cast<Char*>(m_colourRemapSEIFileRoot.c_str()) );
-#endif
+  m_cTEncTop.xSetCRISEIFileRoot                                   ( m_colourRemapSEIFileName );
 #endif
 #if LAYERS_NOT_PRESENT_SEI
@@ -877,10 +875,10 @@
     //2
     // Video I/O
-    m_apcTVideoIOYuvInputFile[layer]->open( (Char *)m_apcLayerCfg[layer]->getInputFile().c_str(),  false, m_apcLayerCfg[layer]->m_inputBitDepth, m_apcLayerCfg[layer]->m_MSBExtendedBitDepth, m_apcLayerCfg[layer]->m_internalBitDepth );  // read  mode
+    m_apcTVideoIOYuvInputFile[layer]->open( m_apcLayerCfg[layer]->getInputFileName(),  false, m_apcLayerCfg[layer]->m_inputBitDepth, m_apcLayerCfg[layer]->m_MSBExtendedBitDepth, m_apcLayerCfg[layer]->m_internalBitDepth );  // read  mode
     m_apcTVideoIOYuvInputFile[layer]->skipFrames(m_FrameSkip, m_apcLayerCfg[layer]->m_iSourceWidth - m_apcLayerCfg[layer]->m_aiPad[0], m_apcLayerCfg[layer]->m_iSourceHeight - m_apcLayerCfg[layer]->m_aiPad[1], m_apcLayerCfg[layer]->m_InputChromaFormatIDC);
 
-    if( !m_apcLayerCfg[layer]->getReconFile().empty() )
-    {
-      m_apcTVideoIOYuvReconFile[layer]->open((Char *)m_apcLayerCfg[layer]->getReconFile().c_str(), true, m_apcLayerCfg[layer]->m_outputBitDepth, m_apcLayerCfg[layer]->m_MSBExtendedBitDepth, m_apcLayerCfg[layer]->m_internalBitDepth );  // write mode
+    if( !m_apcLayerCfg[layer]->getReconFileName().empty() )
+    {
+      m_apcTVideoIOYuvReconFile[layer]->open( m_apcLayerCfg[layer]->getReconFileName(), true, m_apcLayerCfg[layer]->m_outputBitDepth, m_apcLayerCfg[layer]->m_MSBExtendedBitDepth, m_apcLayerCfg[layer]->m_internalBitDepth );  // write mode
     }
 
@@ -890,10 +888,10 @@
 #else //SVC_EXTENSION
   // Video I/O
-  m_cTVideoIOYuvInputFile.open( m_pchInputFile,     false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );  // read  mode
+  m_cTVideoIOYuvInputFile.open( m_inputFileName,     false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth );  // read  mode
   m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC);
 
-  if (m_pchReconFile)
-  {
-    m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth);  // write mode
+  if (!m_reconFileName.empty())
+  {
+    m_cTVideoIOYuvReconFile.open(m_reconFileName, true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth);  // write mode
   }
 
@@ -1439,8 +1437,8 @@
 Void TAppEncTop::encode()
 {
-  fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
+  fstream bitstreamFile(m_bitstreamFileName.c_str(), fstream::binary | fstream::out);
   if (!bitstreamFile)
   {
-    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
+    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_bitstreamFileName.c_str());
     exit(EXIT_FAILURE);
   }
@@ -1801,8 +1799,8 @@
 Void TAppEncTop::encode()
 {
-  fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
+  fstream bitstreamFile(m_bitstreamFileName.c_str(), fstream::binary | fstream::out);
   if (!bitstreamFile)
   {
-    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
+    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_bitstreamFileName.c_str());
     exit(EXIT_FAILURE);
   }
@@ -1973,5 +1971,5 @@
       TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
 
-      if( !m_apcLayerCfg[layer]->getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed() )
+      if( !m_apcLayerCfg[layer]->getReconFileName().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed() )
       {
         m_apcTVideoIOYuvReconFile[layer]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_apcLayerCfg[layer]->getConfWinLeft() * xScal, m_apcLayerCfg[layer]->getConfWinRight() * xScal, 
@@ -1994,5 +1992,5 @@
     {
       TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
-      if( !m_apcLayerCfg[layer]->getReconFile().empty() && pcPicYuvRec->isReconstructed() )
+      if( !m_apcLayerCfg[layer]->getReconFileName().empty() && pcPicYuvRec->isReconstructed() )
       {
         m_apcTVideoIOYuvReconFile[layer]->write( pcPicYuvRec, ipCSC, m_apcLayerCfg[layer]->getConfWinLeft() * xScal, m_apcLayerCfg[layer]->getConfWinRight() * xScal,
@@ -2101,5 +2099,5 @@
       TComPicYuv*  pcPicYuvRecBottom  = *(iterPicYuvRec++);
 
-      if (m_pchReconFile)
+      if (!m_reconFileName.empty())
       {
         m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, NUM_CHROMA_FORMAT, m_isTopFieldFirst );
@@ -2130,5 +2128,5 @@
     {
       TComPicYuv*  pcPicYuvRec  = *(iterPicYuvRec++);
-      if (m_pchReconFile)
+      if (!m_reconFileName.empty())
       {
         m_cTVideoIOYuvReconFile.write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom,
