Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1365)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1366)
@@ -109,5 +109,5 @@
 #if SVC_EXTENSION
 TAppEncCfg::TAppEncCfg()
-: m_pBitstreamFile()
+: m_pchBitstreamFile()
 #if AVC_BASE
 , m_nonHEVCBaseLayerFlag(0)
@@ -148,11 +148,5 @@
 TAppEncCfg::~TAppEncCfg()
 {
-#if SVC_EXTENSION
-  if( m_pBitstreamFile )
-  {
-    free(m_pBitstreamFile);
-    m_pBitstreamFile = NULL;
-  }
-#else  
+#if !SVC_EXTENSION
   if ( m_aidQP )
   {
@@ -176,6 +170,6 @@
 
   free(m_pchInputFile);
+#endif
   free(m_pchBitstreamFile);
-#endif
 #if !SVC_EXTENSION  
   free(m_pchReconFile);
@@ -1772,8 +1766,9 @@
   }
 #endif
-  m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
 #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());
@@ -4341,5 +4336,5 @@
   }
   printf("=== Common configuration settings === \n");
-  printf("Bitstream      File               : %s\n", m_pBitstreamFile      );
+  printf("Bitstream      File               : %s\n", m_pchBitstreamFile      );
 #else //SVC_EXTENSION
   printf("\n");
Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1365)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1366)
@@ -64,9 +64,4 @@
   Int       m_numLayers;                                      ///< number of layers
   Int       m_scalabilityMask[MAX_VPS_NUM_SCALABILITY_TYPES]; ///< scalability_mask
-  Char*     m_pBitstreamFile;                                 ///< output bitstream file
-  Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
-  // source specification
-  UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
-  Int       m_framesToBeEncoded;                              ///< number of encoded frames
 #if AVC_BASE
   Int       m_nonHEVCBaseLayerFlag;                           ///< non HEVC BL
@@ -88,10 +83,16 @@
 #else
   Char*     m_pchInputFile;                                   ///< source file name
+#endif
   Char*     m_pchBitstreamFile;                               ///< output bitstream file
+#if !SVC_EXTENSION
   Char*     m_pchReconFile;                                   ///< output reconstruction file
+#endif
   Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
   // source specification
+#if !SVC_EXTENSION
   Int       m_iFrameRate;                                     ///< source frame-rates (Hz)
+#endif
   UInt      m_FrameSkip;                                   ///< number of skipped frames from the beginning
+#if !SVC_EXTENSION
   Int       m_iSourceWidth;                                   ///< source width in pixel
   Int       m_iSourceHeight;                                  ///< source height in pixel (when interlaced = field height)
@@ -110,5 +111,7 @@
   Int       m_confWinTop;
   Int       m_confWinBottom;
+#endif
   Int       m_framesToBeEncoded;                              ///< number of encoded frames
+#if !SVC_EXTENSION
   Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
 #endif  
Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1365)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1366)
@@ -1680,8 +1680,8 @@
 Void TAppEncTop::encode()
 {
-  fstream bitstreamFile(m_pBitstreamFile, fstream::binary | fstream::out);
+  fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out);
   if (!bitstreamFile)
   {
-    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pBitstreamFile);
+    fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile);
     exit(EXIT_FAILURE);
   }
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1365)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1366)
@@ -2025,5 +2025,5 @@
   Int                        m_iAssociatedIRAP;
   NalUnitType                m_iAssociatedIRAPType;
-  TComReferencePictureSet*   m_pcRPS;
+  const TComReferencePictureSet*   m_pcRPS;
   TComReferencePictureSet    m_LocalRPS;
   Int                        m_iBDidx;
@@ -2170,6 +2170,6 @@
   Void                        setSaoEnabledFlag(ChannelType chType, Bool s)          {m_saoEnabledFlag[chType] =s;                                   }
   Bool                        getSaoEnabledFlag(ChannelType chType) const            { return m_saoEnabledFlag[chType];                              }
-  Void                        setRPS( TComReferencePictureSet *pcRPS )               { m_pcRPS = pcRPS;                                              }
-  TComReferencePictureSet*    getRPS()                                               { return m_pcRPS;                                               }
+  Void                        setRPS( const TComReferencePictureSet *pcRPS )         { m_pcRPS = pcRPS;                                              }
+  const TComReferencePictureSet*    getRPS()                                               { return m_pcRPS;                                               }
   TComReferencePictureSet*    getLocalRPS()                                          { return &m_LocalRPS;                                           }
 
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1365)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1366)
@@ -1162,5 +1162,5 @@
 
               TComSlice *slice = dpbPic->getSlice(i);
-              TComReferencePictureSet *rps = slice->getRPS();
+              TComReferencePictureSet *rps = slice->getLocalRPS();
               slice->setPOC( slice->getPOC() - deltaPocVal );
 
@@ -1170,4 +1170,7 @@
                 rps->setPOC( j, rps->getPOC(j) - deltaPocVal );
               }
+
+              slice->setRPS(rps);
+
               // Also adjust the value of refPOC
               for(Int k = 0; k < 2; k++)  // For List 0 and List 1
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1365)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1366)
@@ -1926,5 +1926,5 @@
 #endif
     m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
-    pcSlice->getRPS()->setNumberOfLongtermPictures(0);
+//    pcSlice->getRPS()->setNumberOfLongtermPictures(0);
     if (!m_pcCfg->getEfficientFieldIRAPEnabled())
     {
@@ -3544,9 +3544,11 @@
 Void TEncGOP::arrangeLongtermPicturesInRPS(TComSlice *pcSlice, TComList<TComPic*>& rcListPic)
 {
-  TComReferencePictureSet *rps = pcSlice->getRPS();
-  if(!rps->getNumberOfLongtermPictures())
+  if(pcSlice->getRPS()->getNumberOfLongtermPictures() == 0)
   {
     return;
   }
+  // we can only modify the local RPS!
+  assert (pcSlice->getRPSidx()==-1);
+  TComReferencePictureSet *rps = pcSlice->getLocalRPS();
 
   // Arrange long-term reference pictures in the correct order of LSB and MSB,
@@ -4013,5 +4015,5 @@
             {
               TComSlice *dpbPicSlice = dpbPic->getSlice( i );
-              TComReferencePictureSet *dpbPicRps = dpbPicSlice->getRPS();
+              TComReferencePictureSet *dpbPicRps = dpbPicSlice->getLocalRPS();
 
               // Decrement POC of slice
@@ -4023,4 +4025,6 @@
                 dpbPicRps->setPOC( j, dpbPicRps->getPOC(j) - deltaPocVal );
               }
+              
+              dpbPicSlice->setRPS(dpbPicRps);
 
               // Decrement value of refPOC
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1365)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1366)
@@ -1512,8 +1512,6 @@
   }
 
-  TComReferencePictureSet *rps=slice->getLocalRPS();
-  (*rps) = *(slice->getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx()));
+  const TComReferencePictureSet *rps = (slice->getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx()));
   slice->setRPS(rps);
-  slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures());
 }
 
