Index: trunk/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/CommonDef.h	(revision 713)
+++ trunk/source/Lib/TLibCommon/CommonDef.h	(revision 815)
@@ -58,5 +58,5 @@
 #if SVC_EXTENSION
 #include <vector>
-#define NV_VERSION        "6.0 (HM-14.0)"                 ///< Current software version
+#define NV_VERSION        "6.1 (HM-14.0)"                 ///< Current software version
 #else
 #define NV_VERSION        "14.0"                ///< Current software version
Index: trunk/source/Lib/TLibCommon/SEI.h
===================================================================
--- trunk/source/Lib/TLibCommon/SEI.h	(revision 713)
+++ trunk/source/Lib/TLibCommon/SEI.h	(revision 815)
@@ -37,4 +37,8 @@
 #include <cstring>
 
+#if Q0078_ADD_LAYER_SETS
+#include "TLibCommon/NAL.h"
+#endif
+
 //! \ingroup TLibCommon
 //! \{
@@ -66,4 +70,7 @@
     POST_FILTER_HINT                     = 22,
     TONE_MAPPING_INFO                    = 23,
+#if P0050_KNEE_FUNCTION_SEI
+    KNEE_FUNCTION_INFO                   = 24,
+#endif
     FRAME_PACKING                        = 45,
     DISPLAY_ORIENTATION                  = 47,
@@ -91,4 +98,14 @@
 #if Q0074_SEI_COLOR_MAPPING
     COLOR_MAPPING_INFO                   = 143,
+#endif
+#if Q0078_ADD_LAYER_SETS
+    OUTPUT_LAYER_SET_NESTING             = 144,
+    VPS_REWRITING                        = 145,
+#endif
+#if Q0189_TMVP_CONSTRAINTS
+    TMVP_CONSTRAINTS                     = 146,
+#endif
+#if Q0247_FRAME_FIELD_INFO
+    FRAME_FIELD_INFO                     = 147,
 #endif
   };
@@ -407,5 +424,25 @@
   Int    m_extendedWhiteLevelLumaCodeValue;
 };
-
+#if P0050_KNEE_FUNCTION_SEI
+class SEIKneeFunctionInfo : public SEI
+{
+public:
+  PayloadType payloadType() const { return KNEE_FUNCTION_INFO; }
+  SEIKneeFunctionInfo() {}
+  virtual ~SEIKneeFunctionInfo() {}
+
+  Int   m_kneeId;
+  Bool  m_kneeCancelFlag;
+  Bool  m_kneePersistenceFlag;
+  Bool  m_kneeMappingFlag;
+  Int   m_kneeInputDrange;
+  Int   m_kneeInputDispLuminance;
+  Int   m_kneeOutputDrange;
+  Int   m_kneeOutputDispLuminance;
+  Int   m_kneeNumKneePointsMinus1;
+  std::vector<Int> m_kneeInputKneePoint;
+  std::vector<Int> m_kneeOutputKneePoint;
+};
+#endif
 #if Q0074_SEI_COLOR_MAPPING
 class SEIColorMappingInfo : public SEI
@@ -486,4 +523,44 @@
 #endif
 
+#if Q0189_TMVP_CONSTRAINTS
+class SEITMVPConstrains : public SEI
+{
+public:
+  PayloadType payloadType() const { return TMVP_CONSTRAINTS; }
+
+  SEITMVPConstrains()
+    : prev_pics_not_used_flag(0),no_intra_layer_col_pic_flag(0)
+    {}
+
+  virtual ~SEITMVPConstrains()
+  {
+  }
+
+  UInt prev_pics_not_used_flag;
+  UInt no_intra_layer_col_pic_flag;
+};
+#endif
+
+#if Q0247_FRAME_FIELD_INFO 
+class SEIFrameFieldInfo: public SEI
+{
+public:
+  PayloadType payloadType() const { return FRAME_FIELD_INFO; }
+
+  SEIFrameFieldInfo()
+    : m_ffinfo_picStruct(0),m_ffinfo_sourceScanType(0), m_ffinfo_duplicateFlag(false)
+    {}
+
+  virtual ~SEIFrameFieldInfo()
+  {
+  }
+
+  UInt  m_ffinfo_picStruct;
+  UInt  m_ffinfo_sourceScanType;
+  Bool  m_ffinfo_duplicateFlag;
+};
+
+#endif
+
 typedef std::list<SEI*> SEIMessages;
 
@@ -583,3 +660,37 @@
 };
 
+#if Q0078_ADD_LAYER_SETS
+class SEIOutputLayerSetNesting : public SEI
+{
+public:
+  PayloadType payloadType() const { return OUTPUT_LAYER_SET_NESTING; }
+
+  SEIOutputLayerSetNesting() {}
+  virtual ~SEIOutputLayerSetNesting()
+  {
+    if (!m_callerOwnsSEIs)
+    {
+      deleteSEIs(m_nestedSEIs);
+    }
+  }
+
+  Bool m_olsFlag;
+  UInt m_numOlsIndicesMinus1;
+  UInt m_olsIdx[1024];
+  Bool  m_callerOwnsSEIs;
+  SEIMessages m_nestedSEIs;
+};
+
+class SEIVPSRewriting : public SEI
+{
+public:
+  PayloadType payloadType() const { return VPS_REWRITING; }
+
+  SEIVPSRewriting() {}
+  virtual ~SEIVPSRewriting() {}
+
+  NALUnit* nalu;
+};
+#endif
+
 //! \}
Index: trunk/source/Lib/TLibCommon/TCom3DAsymLUT.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TCom3DAsymLUT.cpp	(revision 713)
+++ trunk/source/Lib/TLibCommon/TCom3DAsymLUT.cpp	(revision 815)
@@ -44,5 +44,7 @@
 
   if( m_pCuboid != NULL )
+  {
     destroy();
+  }
   xAllocate3DArray( m_pCuboid , m_nYSize , m_nUSize , m_nVSize );
 }
@@ -88,17 +90,6 @@
 
   // alignment padding
-  pU += (nWidth>>1);
-  pV += (nWidth>>1);
-  for( Int y = 0 ; y < (nHeight>>1) ; y ++ )
-  {
-    *pU = pU[-1];
-    *pV = pV[-1];
-    pU += nStrideC;
-    pV += nStrideC;
-  }
-  memcpy(pU-(nWidth>>1), pU-(nWidth>>1)-nStrideC, ((nWidth>>1)+1)*sizeof(Pel));
-  memcpy(pV-(nWidth>>1), pV-(nWidth>>1)-nStrideC, ((nWidth>>1)+1)*sizeof(Pel));
-  pU = pcPic->getCbAddr();
-  pV = pcPic->getCrAddr();
+  pcPic->setBorderExtension( false );
+  pcPic->extendPicBorder();
 
   Pel iMaxValY = (1<<getOutputBitDepthY())-1;
Index: trunk/source/Lib/TLibCommon/TCom3DAsymLUT.h
===================================================================
--- trunk/source/Lib/TLibCommon/TCom3DAsymLUT.h	(revision 713)
+++ trunk/source/Lib/TLibCommon/TCom3DAsymLUT.h	(revision 815)
@@ -100,10 +100,14 @@
   p[0] = new T*[xSize*ySize];
   for( Int x = 1 ; x < xSize ; x++ )
+  {
     p[x] = p[x-1] + ySize;
+  }
   p[0][0] = new T[xSize*ySize*zSize];
   for( Int x = 0 ; x < xSize ; x++ )
   {
     for( Int y = 0 ; y < ySize ; y++ )
+    {
       p[x][y] = p[0][0] + x * ySize * zSize + y * zSize;
+    }
   }
 }
@@ -117,5 +121,7 @@
     {
       if( p[0][0] != NULL )
+      {
         delete [] p[0][0];
+      }
       delete [] p[0];
     }
Index: trunk/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 713)
+++ trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 815)
@@ -3517,10 +3517,21 @@
 #endif
 
-#if N0139_POSITION_ROUNDING_OFFSET
+#if REF_IDX_MFM
+  // offset for collocated block in the motion mapping
   if( iMotionMapping == 1 )
   {
+    Bool unequalPictureSizeFlag = g_posScalingFactor[refLayerIdc][0] != 65536 || g_posScalingFactor[refLayerIdc][1] != 65536; //the condition should be updated according to the WD.
+
     // actually, motion field compression is performed in the Void TComPic::compressMotion() function, but with (+4) the rounding may have effect on the picture boundary check.
-    iBX = ( ( iBX + 4 ) >> 4 ) << 4;
-    iBY = ( ( iBY + 4 ) >> 4 ) << 4;
+    if( unequalPictureSizeFlag )
+    {
+      iBX = ( ( iBX + 4 ) >> 4 ) << 4;
+      iBY = ( ( iBY + 4 ) >> 4 ) << 4;
+    }
+    else
+    {
+      iBX += 4;
+      iBY += 4;
+    }
   }
 #endif
@@ -3637,7 +3648,13 @@
   {
     Int refIdxL0 = cMvFieldL0.getRefIdx();
-    if(getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_layerId))
+    TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_0, refIdxL0);
+
+    if(refPic->isILR(m_layerId))
     {
       checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0);
+
+      // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, 
+      // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
+      checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_layerId, refPic->getLayerId() );
     }
   }
@@ -3645,7 +3662,13 @@
   {
     Int refIdxL1  = cMvFieldL1.getRefIdx();
-    if(getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_layerId))
+    TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_1, refIdxL1);
+
+    if(refPic->isILR(m_layerId))
     {
       checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0);
+
+      // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, 
+      // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
+      checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_layerId, refPic->getLayerId() );
     }
   }
Index: trunk/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 713)
+++ trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 815)
@@ -72,5 +72,5 @@
 {
 }
-#if SVC_UPSAMPLING
+#if SVC_EXTENSION
 #if AUXILIARY_PICTURES
 Void TComPic::create( Int iWidth, Int iHeight, ChromaFormat chromaFormatIDC, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
@@ -184,5 +184,5 @@
   
   deleteSEIs(m_SEIs);
-#if SVC_EXTENSION && SVC_UPSAMPLING
+#if SVC_EXTENSION
   for( Int i = 0; i < MAX_LAYERS; i++ )
   {
Index: trunk/source/Lib/TLibCommon/TComPic.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComPic.h	(revision 713)
+++ trunk/source/Lib/TLibCommon/TComPic.h	(revision 815)
@@ -92,26 +92,24 @@
   Int                   m_nFrameBit;
 #endif
-
+#if POC_RESET_IDC_DECODER
+  Bool                  m_currAuFlag;
+#endif
 public:
   TComPic();
   virtual ~TComPic();
   
+#if SVC_EXTENSION
 #if AUXILIARY_PICTURES
-#if SVC_UPSAMPLING
   Void          create( Int iWidth, Int iHeight, ChromaFormat chromaFormatIDC, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, 
                         Int *numReorderPics, TComSPS* pcSps = NULL, Bool bIsVirtual = false );
 #else
-  Void          create( Int iWidth, Int iHeight, ChromaFormat chromaFormatIDC, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, 
-                        Int *numReorderPics, Bool bIsVirtual = false );                        
-#endif
-#else
-#if SVC_UPSAMPLING
   Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, 
                         Int *numReorderPics, TComSPS* pcSps = NULL, Bool bIsVirtual = false );
+#endif
 #else
   Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, 
-                        Int *numReorderPics, Bool bIsVirtual = false );                        
-#endif
-#endif
+                        Int *numReorderPics, Bool bIsVirtual = false ); 
+#endif //SVC_EXTENSION 
+
   virtual Void  destroy();
   
@@ -202,5 +200,5 @@
   TComPicYuv*   getFullPelBaseRec   (UInt refLayerIdc)  { return  m_pcFullPelBaseRec[refLayerIdc];  }
 #if REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
-  Bool          isILR( UInt currLayerId )   { return ( getIsLongTerm() && m_layerId < currLayerId ); }
+  Bool          isILR( UInt currLayerId )   { return ( m_bIsLongTerm && m_layerId < currLayerId ); }
 #endif
 #if REF_IDX_MFM
@@ -227,4 +225,8 @@
   Int   getFrameBit()         { return m_nFrameBit; }
 #endif
+#if POC_RESET_IDC_DECODER
+  Bool isCurrAu() { return m_currAuFlag; }
+  Void setCurrAuFlag(Bool x) {m_currAuFlag = x; }
+#endif
 };// END CLASS DEFINITION TComPic
 
Index: trunk/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 713)
+++ trunk/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 815)
@@ -67,22 +67,19 @@
 {
 }
+
+#if SVC_EXTENSION
 #if AUXILIARY_PICTURES
-#if SVC_UPSAMPLING
 Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps )
 #else
-Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth )
-#endif
-#else
-#if SVC_UPSAMPLING
 Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps )
+#endif
 #else
 Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth )
 #endif
-#endif
 {
   m_iPicWidth       = iPicWidth;
   m_iPicHeight      = iPicHeight;
   
-#if SVC_UPSAMPLING
+#if SVC_EXTENSION
   if(pcSps != NULL)
   {
@@ -369,4 +366,70 @@
 }
 
+#if SVC_EXTENSION
+Void TComPicYuv::dump( Char* pFileName, Bool bAdd, Int bitDepth )
+{
+  FILE* pFile;
+  if (!bAdd)
+  {
+    pFile = fopen (pFileName, "wb");
+  }
+  else
+  {
+    pFile = fopen (pFileName, "ab");
+  }
+
+  if( bitDepth == 8 )
+  {
+    dump( pFileName, bAdd );
+    return;
+  }
+  
+  Int   x, y;
+  UChar uc;
+  
+  Pel*  piY   = getLumaAddr();
+  Pel*  piCb  = getCbAddr();
+  Pel*  piCr  = getCrAddr();
+  
+  for ( y = 0; y < m_iPicHeight; y++ )
+  {
+    for ( x = 0; x < m_iPicWidth; x++ )
+    {
+      uc = piY[x] & 0xff;      
+      fwrite( &uc, sizeof(UChar), 1, pFile );
+      uc = (piY[x] >> 8) & 0xff;      
+      fwrite( &uc, sizeof(UChar), 1, pFile );
+    }
+    piY += getStride();
+  }
+  
+  for ( y = 0; y < m_iPicHeight >> 1; y++ )
+  {
+    for ( x = 0; x < m_iPicWidth >> 1; x++ )
+    {
+      uc = piCb[x] & 0xff;
+      fwrite( &uc, sizeof(UChar), 1, pFile );
+      uc = (piCb[x] >> 8) & 0xff;
+      fwrite( &uc, sizeof(UChar), 1, pFile );
+    }
+    piCb += getCStride();
+  }
+  
+  for ( y = 0; y < m_iPicHeight >> 1; y++ )
+  {
+    for ( x = 0; x < m_iPicWidth >> 1; x++ )
+    {
+      uc = piCr[x] & 0xff;
+      fwrite( &uc, sizeof(UChar), 1, pFile );
+      uc = (piCr[x] >> 8) & 0xff;
+      fwrite( &uc, sizeof(UChar), 1, pFile );
+    }
+    piCr += getCStride();
+  }
+  
+  fclose(pFile);
+}
+
+#endif
 
 //! \}
Index: trunk/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComPicYuv.h	(revision 713)
+++ trunk/source/Lib/TLibCommon/TComPicYuv.h	(revision 815)
@@ -42,5 +42,5 @@
 #include "CommonDef.h"
 #include "TComRom.h"
-#if SVC_UPSAMPLING
+#if SVC_EXTENSION
 #include "TComSlice.h"
 #endif
@@ -94,7 +94,5 @@
   ChromaFormat m_chromaFormatIDC; ////< Chroma Format
 #endif
-#if SVC_UPSAMPLING
   Window  m_conformanceWindow;
-#endif
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
   Bool    m_isReconstructed;
@@ -112,17 +110,13 @@
   //  Memory management
   // ------------------------------------------------------------------------------------------------
+#if SVC_EXTENSION
 #if AUXILIARY_PICTURES
-#if SVC_UPSAMPLING
   Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
 #else
-  Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
-#endif  
-#else
-#if SVC_UPSAMPLING
   Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
+#endif
 #else
   Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth );
-#endif  
-#endif
+#endif //SVC_EXTENSION
   
   Void  destroy     ();
@@ -187,8 +181,6 @@
 #if SVC_EXTENSION
   Void   setHeight   ( Int iPicHeight )     { m_iPicHeight = iPicHeight; }
-#if SVC_UPSAMPLING
   Window& getConformanceWindow()                           { return  m_conformanceWindow;             }
   Void    setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
-#endif
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
   Void  setReconstructed(Bool x) { m_isReconstructed = x;    }
@@ -199,4 +191,5 @@
   Void convertToMonochrome();
 #endif
+  Void dump( Char* pFileName, Bool bAdd, Int bitDepth );
 #endif //SVC_EXTENSION
 
Index: trunk/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 713)
+++ trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 815)
@@ -487,6 +487,22 @@
   pcCU->clipMv(cMv);
 
+#if SVC_EXTENSION
+  if( pcCU->getLayerId() > 0 )
+  {
+    TComPic* refPic = pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx);
+
+    if( refPic->isILR(pcCU->getLayerId()) )
+    {
+      // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, 
+      // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
+      assert( pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerId(), refPic->getLayerId() ) );
+
 #if REF_IDX_ME_ZEROMV
-  assert( ( pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(pcCU->getLayerId()) && cMv.getHor() == 0 && cMv.getVer() == 0 ) || pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(pcCU->getLayerId()) == false );
+      // It is a requirement of bitstream conformance that the variables mvLX[ 0 ] and mvLX[ 1 ] shall be equal to 0 if the value of refIdxLX corresponds to an inter-layer reference picture. 
+      assert( cMv.getHor() == 0 && cMv.getVer() == 0 );
+#endif
+    }
+
+  }
 #endif
 
@@ -765,5 +781,5 @@
 }
 
-#if SVC_UPSAMPLING
+#if SVC_EXTENSION
 #if O0215_PHASE_ALIGNMENT
 #if O0194_JOINT_US_BITSHIFT
@@ -791,4 +807,4 @@
 #endif
 #endif
-#endif
+#endif //SVC_EXTENSION
 //! \}
Index: trunk/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 713)
+++ trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 815)
@@ -48,5 +48,5 @@
 #include "TComWeightPrediction.h"
 
-#if SVC_UPSAMPLING
+#if SVC_EXTENSION
 #include "TComUpsampleFilter.h"
 #endif
@@ -72,8 +72,4 @@
   
   TComInterpolationFilter m_if;
-  
-#if SVC_UPSAMPLING
-  TComUpsampleFilter      m_cUsf;
-#endif
 
   Pel*   m_pLumaRecBuffer;       ///< array for downsampled reconstructed luma sample 
@@ -94,4 +90,8 @@
   Void xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight );
   Bool xCheckIdenticalMotion    ( TComDataCU* pcCU, UInt PartAddr);
+  
+#if SVC_EXTENSION
+  TComUpsampleFilter      m_cUsf;
+#endif
 
 public:
@@ -118,5 +118,4 @@
 
 #if SVC_EXTENSION
-#if SVC_UPSAMPLING
 #if O0215_PHASE_ALIGNMENT
 #if O0194_JOINT_US_BITSHIFT
@@ -132,5 +131,4 @@
 #endif
 #endif
-#endif
 #endif //SVC_EXTENSION
 };
Index: trunk/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComRom.cpp	(revision 713)
+++ trunk/source/Lib/TLibCommon/TComRom.cpp	(revision 815)
@@ -527,37 +527,42 @@
   {
   case NAL_UNIT_CODED_SLICE_TRAIL_N:
+    return "TRAIL_N";
   case NAL_UNIT_CODED_SLICE_TRAIL_R:
-    return "TRAIL";
+    return "TRAIL_R";
   
   case NAL_UNIT_CODED_SLICE_TSA_N:
+    return "  TSA_N";
   case NAL_UNIT_CODED_SLICE_TSA_R:
-    return "  TSA";
+    return "  TSA_R";
   
   case NAL_UNIT_CODED_SLICE_STSA_N:
+    return " STSA_N";
   case NAL_UNIT_CODED_SLICE_STSA_R:
-    return " STSA";
+    return " STSA_R";
 
   case NAL_UNIT_CODED_SLICE_RADL_N:
+    return " RADL_N";
   case NAL_UNIT_CODED_SLICE_RADL_R:
-    return " RADL";
+    return " RADL_R";
   
   case NAL_UNIT_CODED_SLICE_RASL_N:
+    return " RASL_N";
   case NAL_UNIT_CODED_SLICE_RASL_R:
-    return " RASL";
+    return " RASL_R";
 
   case NAL_UNIT_CODED_SLICE_BLA_W_LP:
   case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
   case NAL_UNIT_CODED_SLICE_BLA_N_LP:
-    return "  BLA";
+    return "    BLA";
 
   case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
   case NAL_UNIT_CODED_SLICE_IDR_N_LP:
-    return "  IDR";
+    return "    IDR";
   
   case NAL_UNIT_CODED_SLICE_CRA:
-    return "  CRA";
+    return "    CRA";
 
   default:
-    return "     ";
+    return "       ";
   };
 }
Index: trunk/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 713)
+++ trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 815)
@@ -125,4 +125,7 @@
 , m_pocMsbValPresentFlag          ( false )
 #endif
+#if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER
+, m_picOrderCntLsb (0)
+#endif
 #endif //SVC_EXTENSION
 {
@@ -200,4 +203,16 @@
   m_numEntryPointOffsets = 0;
   m_enableTMVPFlag = true;
+#if POC_RESET_IDC_SIGNALLING
+  m_pocResetIdc                   = 0;
+  m_pocResetPeriodId              = 0;
+  m_fullPocResetFlag              = false;
+  m_pocLsbVal                     = 0;
+  m_pocMsbVal                     = 0;
+  m_pocMsbValRequiredFlag         = false;
+  m_pocMsbValPresentFlag          = false;
+#endif
+#if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER
+  m_picOrderCntLsb = 0;
+#endif
 }
 
@@ -223,5 +238,47 @@
 }
 #endif
-
+#if POC_RESET_IDC_DECODER
+Bool TComSlice::getRaslPicFlag      ()
+{
+  return  getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R
+  || getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N;
+}
+Bool TComSlice::getRadlPicFlag      ()
+{
+  return  getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R
+  || getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N;
+}
+#endif
+#if POC_RESET_IDC_ENCODER
+Void TComSlice::decrementRefPocValues(Int const decrementValue)
+{
+  for(Int listNum = 0; listNum < 2; listNum++)
+  {
+    RefPicList dpbPicSliceList = (listNum == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
+    for(Int listIdx = 0; listIdx < getNumRefIdx( dpbPicSliceList ); listIdx++)
+    {
+      setRefPOC( getRefPOC(dpbPicSliceList, listIdx) - decrementValue, 
+                  dpbPicSliceList,
+                  listIdx
+                  );
+    }
+  }
+}
+Int TComSlice::getCurrMsb( Int currLsb, Int prevLsb, Int prevMsb, Int maxLsbVal )
+{
+  if( prevLsb - currLsb >= (maxLsbVal >> 1) )
+  {
+    return prevMsb + maxLsbVal;
+  }
+  else if( currLsb - prevLsb > (maxLsbVal >> 1) )
+  {
+    return prevMsb - maxLsbVal;
+  }
+  else
+  {
+    return prevMsb;
+  }
+}
+#endif
 /**
  - allocate table to contain substream sizes to be written to the slice header.
@@ -279,5 +336,9 @@
   while ( iterPic != rcListPic.end() )
   {
+#if POC_RESET_IDC_ENCODER
+    if( (pcPic->getPOC() == poc) && (pcPic->getSlice(0)->isReferenced()) )
+#else
     if(pcPic->getPOC() == poc)
+#endif
     {
       break;
@@ -293,5 +354,5 @@
     pcPic = *(iterPic);
   }
-#if POC_RESET_FLAG
+#if POC_RESET_FLAG || POC_RESET_IDC_DECODER
   assert( pcPic->getSlice(0)->isReferenced() );
 #endif
@@ -512,9 +573,5 @@
     }
 #if MAX_ONE_RESAMPLING_DIRECT_LAYERS
-#if SCALABILITY_MASK_E0104
-    if( m_pcVPS->getScalabilityMask(2) )
-#else
-    if( m_pcVPS->getScalabilityMask(1) )
-#endif
+    if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) )
     {
       Int numResampler = 0;
@@ -550,7 +607,7 @@
 #endif
 #if O0194_DIFFERENT_BITDEPTH_EL_BL
-        Int sameBitDepth = g_bitDepthYLayer[m_layerId] - g_bitDepthYLayer[refLayerId] + g_bitDepthCLayer[m_layerId] - g_bitDepthCLayer[refLayerId];
-
-        if( !( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || !scalingOffset || !sameBitDepth 
+        Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
+
+        if( !( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || !scalingOffset || !sameBitDepths 
 #if Q0048_CGS_3D_ASYMLUT
           || getPPS()->getCGSFlag()
@@ -775,21 +832,19 @@
 #endif
 
-#if N0147_IRAP_ALIGN_FLAG
   assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 0);
   assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 0);
-#else
-  assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 1);
-  assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 1);
-#endif
 
   //set L0 inter-layer reference picture modification
 #if RPL_INIT_N0316_N0082
   Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true;
+
+  if( m_activeNumILRRefIdx > 1 )
+  {
+    hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] >= (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true;
+  }
 #else
   Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true;
 #endif
-#if N0147_IRAP_ALIGN_FLAG
   hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_0] > 1 );
-#endif
   refPicListModification->setRefPicListModificationFlagL0(hasModification);
   if(hasModification)
@@ -799,7 +854,8 @@
       refPicListModification->setRefPicSetIdxL0(i, i);
     }
+
     if(m_aiNumRefIdx[REF_PIC_LIST_0] > numberOfRpsCurrTempList)
     {
-        // repeat last ref pic when the number of active ref idx are more than RPS entries
+      // repeat last ref pic when the number of active ref idx are more than RPS entries
       for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_0]; i ++)
       {
@@ -809,17 +865,21 @@
     else
     {
-      for(Int i = m_activeNumILRRefIdx; i > 0; i-- )
+      // number of ILRPs included into the reference picture list with the list modification
+      Int includeNumILRP = min( max(1, m_aiNumRefIdx[REF_PIC_LIST_0]-numberOfPocBeforeCurr), m_activeNumILRRefIdx);
+
+      for(Int i = includeNumILRP; i > 0; i-- )
       {
 #if RPL_INIT_N0316_N0082
         if((numberOfPocBeforeCurr) >= m_aiNumRefIdx[REF_PIC_LIST_0])
         {
-          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr);
+          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i);
         }
         else
         {
-          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr);
+          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i);
           for (Int j = numberOfPocBeforeCurr; j < (m_aiNumRefIdx[REF_PIC_LIST_0] - i); j++)
           {
-            refPicListModification->setRefPicSetIdxL0(j, j + m_activeNumILRRefIdx);
+            assert( j + includeNumILRP < numberOfRpsCurrTempList );
+            refPicListModification->setRefPicSetIdxL0(j, j + includeNumILRP);
           }
         }
@@ -832,8 +892,6 @@
 
   //set L1 inter-layer reference picture modification
-  hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] == numberOfRpsCurrTempList) ? false : true;
-#if N0147_IRAP_ALIGN_FLAG
+  hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] >= numberOfRpsCurrTempList) ? false : true;
   hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_1] > 1 );
-#endif
 
   refPicListModification->setRefPicListModificationFlagL1(hasModification);
@@ -854,5 +912,7 @@
     else
     {
-      for(Int i = m_activeNumILRRefIdx; i > 0; i-- )
+      Int includeNumILRP = min(m_aiNumRefIdx[REF_PIC_LIST_1], m_activeNumILRRefIdx);
+
+      for(Int i = includeNumILRP; i > 0; i-- )
       {
         refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i);
@@ -1088,6 +1148,16 @@
       rpcPic->setCurrSliceIdx(0);
 #if NO_CLRAS_OUTPUT_FLAG
+#if POC_RESET_IDC_ENCODER
       if (noClrasOutputFlag)
       {
+        rpcPic->getSlice(0)->setReferenced(false);  // all layers // TODO. This does not mark all layers
+      }
+      else
+      {
+        if (rpcPic->getLayerId() == m_layerId) rpcPic->getSlice(0)->setReferenced(false);  // only current layer
+      }
+#else
+      if (noClrasOutputFlag)
+      {
         if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false);  // all layers
       }
@@ -1096,4 +1166,5 @@
         if (rpcPic->getPOC() != pocCurr && rpcPic->getLayerId() == m_layerId) rpcPic->getSlice(0)->setReferenced(false);  // only current layer
       }
+#endif
 #else
       if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false);
@@ -1101,4 +1172,7 @@
       iterPic++;
     }
+#if POC_RESET_IDC_ENCODER
+    this->getPic()->getSlice(0)->setReferenced(true);   // Mark the current picture back as refererced.
+#endif
     if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
       || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
@@ -1329,6 +1403,9 @@
 }
 
-
+#if POC_RESET_IDC_ENCODER
+Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic, Bool usePocBeforeReset)
+#else
 Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic)
+#endif
 {
   TComPic* rpcPic;
@@ -1419,5 +1496,16 @@
          nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL)
       {
+#if POC_RESET_IDC_ENCODER
+        if( usePocBeforeReset )
+        {
+          assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset());
+        }
+        else
+        {
+          assert(rpcPic->getPOC() < this->getPOC());
+        }
+#else
         assert(rpcPic->getPOC() < this->getPOC());
+#endif
       }
     }
@@ -1437,5 +1525,16 @@
           if(this->getAssociatedIRAPPOC() != rpcPic->getPOC())
           {
+#if POC_RESET_IDC_ENCODER
+            if( usePocBeforeReset )
+            {
+              assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset());
+            }
+            else
+            {
+              assert(rpcPic->getPOC() < this->getPOC());
+            }
+#else
             assert(rpcPic->getPOC() < this->getPOC());
+#endif
           }
         }
@@ -1454,5 +1553,16 @@
         // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB
         // rpcPic would violate the constraint if it was a trailing picture
+#if POC_RESET_IDC_ENCODER
+        if( usePocBeforeReset )
+        {
+          assert(rpcPic->getPOC() <= this->getAssociatedIrapPocBeforeReset());
+        }
+        else
+        {
+          assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC());
+        }
+#else
         assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC());
+#endif
       }
     }
@@ -1760,5 +1870,7 @@
     if(isAvailable == 0)    
     {            
+#if !UNAVAILABLE_PIC_BUGFIX
       if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess)
+#endif
       {
         if(!pReferencePictureSet->getUsed(i) )
@@ -1781,5 +1893,9 @@
       }
 #if ALLOW_RECOVERY_POINT_AS_RAP
+#if UNAVAILABLE_PIC_BUGFIX
+      if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess)
+#else
       else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess)
+#endif
       {
         atLeastOneUnabledByRecoveryPoint = 1;
@@ -2025,5 +2141,12 @@
   if ( layerId == 0 )
   {
-    retVal = sps->getPicWidthInLumaSamples();
+    if( vps->getAvcBaseLayerFlag() )
+    {
+      retVal = vps->getVpsRepFormat(layerId)->getPicWidthVpsInLumaSamples();
+    }
+    else
+    {
+      retVal = sps->getPicWidthInLumaSamples();
+    }
   }
   else
@@ -2051,5 +2174,12 @@
   if( layerId == 0 )
   {
-    retVal = sps->getPicHeightInLumaSamples();
+    if( vps->getAvcBaseLayerFlag() )
+    {
+      retVal = vps->getVpsRepFormat(layerId)->getPicHeightVpsInLumaSamples();
+    }
+    else
+    {
+      retVal = sps->getPicHeightInLumaSamples();
+    }
   }
   else
@@ -2207,14 +2337,9 @@
 , m_bTemporalIdNestingFlag    (false)
 , m_numHrdParameters          (  0)
-#if !VPS_RENAME
-, m_maxNuhReservedZeroLayerId (  0)
-#endif
 , m_hrdParameters             (NULL)
 , m_hrdOpSetIdx               (NULL)
 , m_cprmsPresentFlag          (NULL)
-#if VPS_RENAME
 , m_maxLayerId                (0)
 , m_numLayerSets              (0)
-#endif
 #if VPS_EXTN_OP_LAYER_SETS
 , m_numOutputLayerSets        (0)  
@@ -2234,8 +2359,6 @@
 #endif
 #endif
-#if VPS_VUI_BITRATE_PICRATE
 , m_bitRatePresentVpsFlag     (false)
 , m_picRatePresentVpsFlag     (false)
-#endif
 #if REPN_FORMAT_IN_VPS
 #if Q0195_REP_FORMAT_CLEANUP
@@ -2311,13 +2434,9 @@
   m_crossLayerPictureTypeAlignFlag = true;
 #endif 
-#if N0147_IRAP_ALIGN_FLAG
   m_crossLayerIrapAlignFlag = true;
-#endif 
 #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG
   m_crossLayerAlignedIdrOnlyFlag = false;
 #endif
-#if N0120_MAX_TID_REF_PRESENT_FLAG
   m_maxTidRefPresentFlag = true;
-#endif 
   for( Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++)
   {
@@ -2336,7 +2455,5 @@
   ::memset(m_loopFilterNotAcrossTilesFlag,  0, sizeof(m_loopFilterNotAcrossTilesFlag));
 #endif
-#if TILE_BOUNDARY_ALIGNED_FLAG
   ::memset(m_tileBoundariesAlignedFlag,  0, sizeof(m_tileBoundariesAlignedFlag));
-#endif 
 #if VPS_VUI_WPP_NOT_IN_USE__FLAG
   m_wppNotInUseFlag = true;
@@ -2363,5 +2480,4 @@
   }
 #endif
-#if VPS_VUI_BITRATE_PICRATE  
   ::memset(m_bitRatePresentFlag, 0, sizeof(m_bitRatePresentFlag));
   ::memset(m_picRatePresentFlag, 0, sizeof(m_picRatePresentFlag));
@@ -2370,5 +2486,4 @@
   ::memset(m_constPicRateIdc   , 0, sizeof(m_constPicRateIdc)   );
   ::memset(m_avgPicRate        , 0, sizeof(m_avgPicRate)        );
-#endif
 #if REPN_FORMAT_IN_VPS
   ::memset( m_vpsRepFormatIdx, 0, sizeof(m_vpsRepFormatIdx) );
@@ -2485,5 +2600,5 @@
     }
   }
-#if TILE_BOUNDARY_ALIGNED_FLAG  
+
   if (m_tilesNotInUseFlag)
   {
@@ -2496,7 +2611,7 @@
     }
   }
-#endif
-}
-#endif
+}
+#endif
+
 #if VPS_VUI_WPP_NOT_IN_USE__FLAG
 Void TComVPS::setWppNotInUseFlag(Bool x)
@@ -2526,6 +2641,8 @@
 }
 
-Void TComVPS::setNumRefLayers(Int currLayerId)
-{
+Void TComVPS::setNumRefLayers()
+{
+  memset( m_numberRefLayers, 0, sizeof( m_numberRefLayers ) );
+
   for (Int i = 0; i < m_uiMaxLayers; i++)
   {
@@ -2538,4 +2655,85 @@
   }
 }
+#endif
+
+#if Q0078_ADD_LAYER_SETS
+Void TComVPS::setPredictedLayerIds()
+{
+  for (UInt i = 0; i < getMaxLayers() - 1; i++)
+  {
+    UInt iNuhLId = getLayerIdInNuh(i);
+    UInt predIdx = 0;
+    for (UInt j = iNuhLId + 1; j < MAX_NUM_LAYER_IDS; j++)
+    {
+      if (getRecursiveRefLayerFlag(j, iNuhLId))
+      {
+        setPredictedLayerId(i, predIdx, j);
+        predIdx++;
+      }
+    }
+    setNumPredictedLayers(iNuhLId, predIdx);
+  }
+}
+
+Void TComVPS::setTreePartitionLayerIdList()
+{
+  Bool countedLayerIdxFlag[MAX_NUM_LAYER_IDS];
+
+  for (UInt i = 0; i <= getMaxLayers() - 1; i++)
+  {
+    countedLayerIdxFlag[i] = false;
+  }
+
+  Int numIndependentLayers = 0;
+
+  for (UInt i = 0; i <= getMaxLayers() - 1; i++)
+  {
+    UInt iNuhLId = getLayerIdInNuh(i);
+    if (getNumDirectRefLayers(iNuhLId) == 0)
+    {
+      setTreePartitionLayerId(numIndependentLayers, 0, iNuhLId);
+      setNumLayersInTreePartition(numIndependentLayers, 1);
+      for (UInt j = 0; j < getNumPredictedLayers(iNuhLId); j++)
+      {
+        if (!countedLayerIdxFlag[getLayerIdInVps(iNuhLId)])
+        {
+          setTreePartitionLayerId(numIndependentLayers, getNumLayersInTreePartition(numIndependentLayers), getPredictedLayerId(iNuhLId, j));
+          setNumLayersInTreePartition(numIndependentLayers, getNumLayersInTreePartition(numIndependentLayers) + 1);
+          countedLayerIdxFlag[getLayerIdInVps(getPredictedLayerId(iNuhLId, j))] = true;
+        }
+      }
+      numIndependentLayers++;
+    }
+  }
+
+  setNumIndependentLayers(numIndependentLayers);
+}
+
+void TComVPS::setLayerIdIncludedFlagsForAddLayerSets()
+{
+  for (UInt i = 0; i < getNumAddLayerSets(); i++)
+  {
+    for (UInt j = 1; j < getNumIndependentLayers(); j++)
+    {
+      Int layerNum = 0;
+      Int lsIdx = getVpsNumLayerSetsMinus1() + 1 + i;
+      for (Int layerId = 0; layerId < MAX_VPS_LAYER_ID_PLUS1; layerId++)
+      {
+        setLayerIdIncludedFlag(false, lsIdx, layerId);
+      }
+      for (Int treeIdx = 1; treeIdx < getNumIndependentLayers(); treeIdx++)
+      {
+        for (Int layerCnt = 0; layerCnt < getHighestLayerIdxPlus1(i, j); layerCnt++)
+        {
+          setLayerSetLayerIdList(lsIdx, layerNum, getTreePartitionLayerId(treeIdx, layerCnt));
+          setLayerIdIncludedFlag(true, lsIdx, getTreePartitionLayerId(treeIdx, layerCnt));
+          layerNum++;
+        }
+      }
+      setNumLayersInIdList(lsIdx, layerNum);
+    }
+  }
+}
+
 #endif
 
@@ -2701,4 +2899,5 @@
   return -1;  // Layer not found
 }
+#endif
 #if O0164_MULTI_LAYER_HRD
 Void TComVPS::setBspHrdParameters( UInt hrdIdx, UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess )
@@ -2780,4 +2979,5 @@
 }
 #endif
+#if RESOLUTION_BASED_DPB
 // RepFormat Assignment operator
 RepFormat& RepFormat::operator= (const RepFormat &other)
@@ -2851,4 +3051,5 @@
 #if SVC_EXTENSION
 , m_layerId                   ( 0 )
+, m_extensionFlag             ( false )
 , m_numScaledRefLayerOffsets  ( 0 )
 #if REPN_FORMAT_IN_VPS
@@ -2905,105 +3106,102 @@
 
   TimingInfo *timingInfo = vui->getTimingInfo();
-#if TIMING_INFO_NONZERO_LAYERID_SPS
-  if( getLayerId() > 0 )
+#if SVC_EXTENSION
+  if( m_layerId > 0 )
   {
     timingInfo->setTimingInfoPresentFlag( false );
+    return;
+  }
+#endif
+
+  timingInfo->setTimingInfoPresentFlag( true );
+  switch( frameRate )
+  {
+  case 24:
+    timingInfo->setNumUnitsInTick( 1125000 );    timingInfo->setTimeScale    ( 27000000 );
+    break;
+  case 25:
+    timingInfo->setNumUnitsInTick( 1080000 );    timingInfo->setTimeScale    ( 27000000 );
+    break;
+  case 30:
+    timingInfo->setNumUnitsInTick( 900900 );     timingInfo->setTimeScale    ( 27000000 );
+    break;
+  case 50:
+    timingInfo->setNumUnitsInTick( 540000 );     timingInfo->setTimeScale    ( 27000000 );
+    break;
+  case 60:
+    timingInfo->setNumUnitsInTick( 450450 );     timingInfo->setTimeScale    ( 27000000 );
+    break;
+  default:
+    timingInfo->setNumUnitsInTick( 1001 );       timingInfo->setTimeScale    ( 60000 );
+    break;
+  }
+
+  Bool rateCnt = ( bitRate > 0 );
+  hrd->setNalHrdParametersPresentFlag( rateCnt );
+  hrd->setVclHrdParametersPresentFlag( rateCnt );
+
+  hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) );
+
+  if( hrd->getSubPicCpbParamsPresentFlag() )
+  {
+    hrd->setTickDivisorMinus2( 100 - 2 );                          // 
+    hrd->setDuCpbRemovalDelayLengthMinus1( 7 );                    // 8-bit precision ( plus 1 for last DU in AU )
+    hrd->setSubPicCpbParamsInPicTimingSEIFlag( true );
+    hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 );                 // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay
   }
   else
   {
-#endif
-    timingInfo->setTimingInfoPresentFlag( true );
-    switch( frameRate )
-    {
-    case 24:
-      timingInfo->setNumUnitsInTick( 1125000 );    timingInfo->setTimeScale    ( 27000000 );
-      break;
-    case 25:
-      timingInfo->setNumUnitsInTick( 1080000 );    timingInfo->setTimeScale    ( 27000000 );
-      break;
-    case 30:
-      timingInfo->setNumUnitsInTick( 900900 );     timingInfo->setTimeScale    ( 27000000 );
-      break;
-    case 50:
-      timingInfo->setNumUnitsInTick( 540000 );     timingInfo->setTimeScale    ( 27000000 );
-      break;
-    case 60:
-      timingInfo->setNumUnitsInTick( 450450 );     timingInfo->setTimeScale    ( 27000000 );
-      break;
-    default:
-      timingInfo->setNumUnitsInTick( 1001 );       timingInfo->setTimeScale    ( 60000 );
-      break;
-    }
-
-    Bool rateCnt = ( bitRate > 0 );
-    hrd->setNalHrdParametersPresentFlag( rateCnt );
-    hrd->setVclHrdParametersPresentFlag( rateCnt );
-
-    hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) );
-
-    if( hrd->getSubPicCpbParamsPresentFlag() )
-    {
-      hrd->setTickDivisorMinus2( 100 - 2 );                          // 
-      hrd->setDuCpbRemovalDelayLengthMinus1( 7 );                    // 8-bit precision ( plus 1 for last DU in AU )
-      hrd->setSubPicCpbParamsInPicTimingSEIFlag( true );
-      hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 );                 // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay
-    }
-    else
-    {
-      hrd->setSubPicCpbParamsInPicTimingSEIFlag( false );  
-    }
-
-    hrd->setBitRateScale( 4 );                                       // in units of 2~( 6 + 4 ) = 1,024 bps
-    hrd->setCpbSizeScale( 6 );                                       // in units of 2~( 4 + 4 ) = 1,024 bit
-    hrd->setDuCpbSizeScale( 6 );                                       // in units of 2~( 4 + 4 ) = 1,024 bit
-  
-    hrd->setInitialCpbRemovalDelayLengthMinus1(15);                  // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit
-    if( randomAccess )
-    {
-      hrd->setCpbRemovalDelayLengthMinus1(5);                        // 32 = 2^5 (plus 1)
-      hrd->setDpbOutputDelayLengthMinus1 (5);                        // 32 + 3 = 2^6
-    }
-    else
-    {
-      hrd->setCpbRemovalDelayLengthMinus1(9);                        // max. 2^10
-      hrd->setDpbOutputDelayLengthMinus1 (9);                        // max. 2^10
-    }
-
-/*
-     Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported.
-*/
-    Int i, j;
-    UInt birateValue, cpbSizeValue;
-    UInt ducpbSizeValue;
-    UInt duBitRateValue = 0;
-
-    for( i = 0; i < MAX_TLAYER; i ++ )
-    {
-      hrd->setFixedPicRateFlag( i, 1 );
-      hrd->setPicDurationInTcMinus1( i, 0 );
-      hrd->setLowDelayHrdFlag( i, 0 );
-      hrd->setCpbCntMinus1( i, 0 );
-
-      birateValue  = bitRate;
-      cpbSizeValue = bitRate;                                     // 1 second
-      ducpbSizeValue = bitRate/numDU;
-      duBitRateValue = bitRate;
-      for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ )
-      {
-        hrd->setBitRateValueMinus1( i, j, 0, ( birateValue  - 1 ) );
-        hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) );
-        hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) );
-        hrd->setCbrFlag( i, j, 0, ( j == 0 ) );
-
-        hrd->setBitRateValueMinus1( i, j, 1, ( birateValue  - 1) );
-        hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) );
-        hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) );
-        hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) );
-        hrd->setCbrFlag( i, j, 1, ( j == 0 ) );
-      }
-    }
-#if TIMING_INFO_NONZERO_LAYERID_SPS
-  }
-#endif
+    hrd->setSubPicCpbParamsInPicTimingSEIFlag( false );  
+  }
+
+  hrd->setBitRateScale( 4 );                                       // in units of 2~( 6 + 4 ) = 1,024 bps
+  hrd->setCpbSizeScale( 6 );                                       // in units of 2~( 4 + 4 ) = 1,024 bit
+  hrd->setDuCpbSizeScale( 6 );                                       // in units of 2~( 4 + 4 ) = 1,024 bit
+
+  hrd->setInitialCpbRemovalDelayLengthMinus1(15);                  // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit
+  if( randomAccess )
+  {
+    hrd->setCpbRemovalDelayLengthMinus1(5);                        // 32 = 2^5 (plus 1)
+    hrd->setDpbOutputDelayLengthMinus1 (5);                        // 32 + 3 = 2^6
+  }
+  else
+  {
+    hrd->setCpbRemovalDelayLengthMinus1(9);                        // max. 2^10
+    hrd->setDpbOutputDelayLengthMinus1 (9);                        // max. 2^10
+  }
+
+  /*
+  Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported.
+  */
+  Int i, j;
+  UInt birateValue, cpbSizeValue;
+  UInt ducpbSizeValue;
+  UInt duBitRateValue = 0;
+
+  for( i = 0; i < MAX_TLAYER; i ++ )
+  {
+    hrd->setFixedPicRateFlag( i, 1 );
+    hrd->setPicDurationInTcMinus1( i, 0 );
+    hrd->setLowDelayHrdFlag( i, 0 );
+    hrd->setCpbCntMinus1( i, 0 );
+
+    birateValue  = bitRate;
+    cpbSizeValue = bitRate;                                     // 1 second
+    ducpbSizeValue = bitRate/numDU;
+    duBitRateValue = bitRate;
+    for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ )
+    {
+      hrd->setBitRateValueMinus1( i, j, 0, ( birateValue  - 1 ) );
+      hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) );
+      hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) );
+      hrd->setCbrFlag( i, j, 0, ( j == 0 ) );
+
+      hrd->setBitRateValueMinus1( i, j, 1, ( birateValue  - 1) );
+      hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) );
+      hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) );
+      hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) );
+      hrd->setCbrFlag( i, j, 1, ( j == 0 ) );
+    }
+  }
 }
 const Int TComSPS::m_winUnitX[]={1,2,2,1};
@@ -3061,5 +3259,8 @@
 , m_listsModificationPresentFlag(  0)
 , m_numExtraSliceHeaderBits(0)
+#if SVC_EXTENSION
+, m_extensionFlag(false)
 #if SCALINGLIST_INFERRING
+, m_layerId(0)
 , m_inferScalingListFlag ( false )
 , m_scalingListRefLayerId ( 0 )
@@ -3068,4 +3269,10 @@
 , m_pocResetInfoPresentFlag   (false)
 #endif
+#if Q0048_CGS_3D_ASYMLUT
+, m_nCGSFlag(0)
+, m_nCGSOutputBitDepthY(0)
+, m_nCGSOutputBitDepthC(0)
+#endif
+#endif //SVC_EXTENSION
 {
   m_scalingList = new TComScalingList;
@@ -3698,6 +3905,10 @@
     return false;
   }        
-#if POC_RESET_FLAG
+#if POC_RESET_FLAG || POC_RESET_IDC_DECODER
+#if POC_RESET_IDC_DECODER
+  TComPic* pic = xGetRefPic( rcListPic, getPOC() );
+#else
   TComPic* pic = xGetRefPic( rcListPic, m_bPocResetFlag ? 0 : m_iPOC );
+#endif
 
   if( pic )
@@ -3712,5 +3923,6 @@
   return true;
 #else
-  setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC())); 
+  setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC()));
+  return true;
 #endif
 }
Index: trunk/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.h	(revision 713)
+++ trunk/source/Lib/TLibCommon/TComSlice.h	(revision 815)
@@ -140,5 +140,5 @@
   
   Void  create  (Int numberOfEntries);
-  Void  destroy ();
+  Void  destroy();
 
 
@@ -469,5 +469,5 @@
 
   UInt        m_numHrdParameters;
-#if !VPS_RENAME
+#if !SVC_EXTENSION
   UInt        m_maxNuhReservedZeroLayerId;
 #endif
@@ -484,6 +484,11 @@
 #if SVC_EXTENSION
 #if DERIVE_LAYER_ID_LIST_VARIABLES
+#if Q0078_ADD_LAYER_SETS
+  Int         m_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS][MAX_VPS_LAYER_ID_PLUS1];
+  Int         m_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS];
+#else
   Int         m_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
   Int         m_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1];
+#endif
 #endif
 #if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED
@@ -492,7 +497,10 @@
 #endif
 #endif
-#if VPS_RENAME
   UInt        m_maxLayerId;
   UInt        m_numLayerSets;
+#if Q0078_ADD_LAYER_SETS
+  UInt        m_vpsNumLayerSetsMinus1;
+  Bool        m_layerIdIncludedFlag[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS][MAX_VPS_LAYER_ID_PLUS1];
+#else
   Bool        m_layerIdIncludedFlag[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
 #endif
@@ -514,7 +522,13 @@
   UInt       m_layerIdInVps[MAX_VPS_LAYER_ID_PLUS1];            // Maps layer_id_in_nuh with the layer ID in the VPS
 #endif
-#if ILP_SSH_SIG
+#if BITRATE_PICRATE_SIGNALLING
+#if Q0078_ADD_LAYER_SETS
+  UInt       m_maxSLInLayerSetMinus1[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS];
+#else
+  UInt       m_maxSLInLayerSetMinus1[MAX_VPS_LAYER_SETS_PLUS1];
+#endif
+#endif
+    
   Bool       m_ilpSshSignalingEnabledFlag;
-#endif
 #if VPS_EXTN_PROFILE_INFO
   // Profile-tier-level signalling related
@@ -529,6 +543,11 @@
   // Target output layer signalling related
   UInt       m_numOutputLayerSets;
+#if Q0078_ADD_LAYER_SETS
+  UInt       m_outputLayerSetIdx[MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS];
+  Bool       m_outputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS][MAX_VPS_LAYER_ID_PLUS1];
+#else
   UInt       m_outputLayerSetIdx[MAX_VPS_LAYER_SETS_PLUS1];
   Bool       m_outputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
+#endif
 #endif
 #if VPS_EXTN_DIRECT_REF_LAYERS
@@ -565,7 +584,5 @@
   Bool       m_crossLayerPictureTypeAlignFlag;
 #endif
-#if N0147_IRAP_ALIGN_FLAG
   Bool       m_crossLayerIrapAlignFlag;
-#endif
 #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG
   Bool       m_crossLayerAlignedIdrOnlyFlag;
@@ -576,7 +593,5 @@
   UInt       m_maxTidIlRefPicsPlus1[MAX_VPS_LAYER_ID_PLUS1 - 1];
 #endif
-#if N0120_MAX_TID_REF_PRESENT_FLAG
   Bool       m_maxTidRefPresentFlag;
-#endif 
 #if VPS_TSLAYERS
   Bool       m_maxTSLayersPresentFlag;
@@ -594,7 +609,5 @@
   Bool       m_loopFilterNotAcrossTilesFlag[MAX_VPS_LAYER_ID_PLUS1];
 #endif 
-#if TILE_BOUNDARY_ALIGNED_FLAG
   Bool       m_tileBoundariesAlignedFlag[MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
-#endif 
 #if VPS_VUI_WPP_NOT_IN_USE__FLAG
   Bool       m_wppNotInUseFlag;
@@ -616,6 +629,6 @@
   Int        m_vpsTransChar[16];
   Int        m_vpsMatCoeff[16];
-#endif 
-#if VPS_VUI_BITRATE_PICRATE
+#endif
+
   Bool       m_bitRatePresentVpsFlag;
   Bool       m_picRatePresentVpsFlag;
@@ -626,5 +639,4 @@
   Int        m_constPicRateIdc     [MAX_VPS_LAYER_SETS_PLUS1][MAX_TLAYER];
   Int        m_avgPicRate          [MAX_VPS_LAYER_SETS_PLUS1][MAX_TLAYER];
-#endif
   
 #if P0312_VERT_PHASE_ADJ
@@ -633,5 +645,9 @@
 
 #if P0300_ALT_OUTPUT_LAYER_FLAG
+#if Q0078_ADD_LAYER_SETS
+  Bool       m_altOutputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS];
+#else
   Bool       m_altOutputLayerFlag[MAX_VPS_LAYER_SETS_PLUS1];
+#endif
 #else
 #if O0153_ALT_OUTPUT_LAYER_FLAG
@@ -661,4 +677,13 @@
   Int        m_numberRefLayers[MAX_NUM_LAYER_IDS];  // number of direct and indirect reference layers of a coding layer
   Bool       m_recursiveRefLayerFlag[MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS];  // flag to indicate if j-th layer is a direct or indirect reference layer of i-th layer
+#endif
+#if Q0078_ADD_LAYER_SETS
+  Int        m_numAddLayerSets;
+  UInt       m_highestLayerIdxPlus1[MAX_NUM_ADD_LAYER_SETS][MAX_NUM_LAYER_IDS];
+  UInt       m_predictedLayerId[MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS];
+  UInt       m_numPredictedLayers[MAX_NUM_LAYER_IDS];
+  Int        m_numIndependentLayers;
+  Int        m_numLayersInTreePartition[MAX_NUM_LAYER_IDS];
+  UInt       m_treePartitionLayerIdList[MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS];
 #endif
 #if SPS_DPB_PARAMS
@@ -675,5 +700,9 @@
   Int        m_maxVpsLatencyIncreasePlus1  [MAX_VPS_OP_LAYER_SETS_PLUS1][MAX_LAYERS];
 #if CHANGE_NUMSUBDPB_IDX
+#if Q0078_ADD_LAYER_SETS
+  Int        m_numSubDpbs                  [MAX_VPS_LAYER_SETS_PLUS1 + 2*MAX_NUM_ADD_LAYER_SETS];
+#else
   Int        m_numSubDpbs                  [MAX_VPS_LAYER_SETS_PLUS1];
+#endif
 #else
   Int        m_numSubDpbs                  [MAX_VPS_OP_LAYER_SETS_PLUS1];
@@ -735,4 +764,10 @@
   }
 #endif
+#if HRD_BPB
+  Int getBspHrdParamBufferCpbCntMinus1(UInt i, UInt sl)
+  {
+    return m_bspHrd->getCpbCntMinus1(sl);
+  }
+#endif
 
   TComHRD* getHrdParameters   ( UInt i )             { return &m_hrdParameters[ i ]; }
@@ -798,13 +833,31 @@
   Void    setRecursiveRefLayerFlag(Int currLayerId, Int refLayerId, Bool x)      { m_recursiveRefLayerFlag[currLayerId][refLayerId] = x;   }
   Int     getNumRefLayers(Int currLayerId)                                       { return m_numberRefLayers[currLayerId];                  }
-  Void    setNumRefLayers(Int currLayerId);
-#endif
-#if VPS_RENAME
-  UInt    getMaxLayerId()                                       { return m_maxLayerId; }
-  Void    setMaxLayerId(UInt v)                                 { m_maxLayerId = v;    }
-
+  Void    setNumRefLayers();
+#endif
+#if Q0078_ADD_LAYER_SETS
+  void    setLayerIdIncludedFlagsForAddLayerSets();
+  UInt    getVpsNumLayerSetsMinus1()                                             { return m_vpsNumLayerSetsMinus1; }
+  Void    setVpsNumLayerSetsMinus1(UInt x)                                       { m_vpsNumLayerSetsMinus1 = x; }
+  UInt    getNumAddLayerSets()                                                   { return m_numAddLayerSets; }
+  Void    setNumAddLayerSets(UInt x)                                             { m_numAddLayerSets = x; }
+  UInt    getHighestLayerIdxPlus1(UInt set, UInt idx)                            { return m_highestLayerIdxPlus1[set][idx]; }
+  Void    setHighestLayerIdxPlus1(UInt set, UInt idx, UInt layerIdx)             { m_highestLayerIdxPlus1[set][idx] = layerIdx; }
+  Void    setPredictedLayerIds();
+  UInt    getPredictedLayerId(UInt layerIdx, UInt predIdx)                       { return m_predictedLayerId[layerIdx][predIdx]; }
+  Void    setPredictedLayerId(UInt layerIdx, UInt predIdx, UInt x)               { m_predictedLayerId[layerIdx][predIdx] = x; }
+  UInt    getNumPredictedLayers(UInt layerId)                                    { return m_numPredictedLayers[layerId]; }
+  Void    setNumPredictedLayers(UInt layerId, UInt x)                            { m_numPredictedLayers[layerId] = x; }
+  Void    setTreePartitionLayerIdList();
+  Int     getNumIndependentLayers()                                              { return m_numIndependentLayers; }
+  Void    setNumIndependentLayers(Int x)                                         { m_numIndependentLayers = x; }
+  Int     getNumLayersInTreePartition(Int idx)                                   { return m_numLayersInTreePartition[idx]; }
+  Void    setNumLayersInTreePartition(Int idx, Int x)                            { m_numLayersInTreePartition[idx] = x; }
+  UInt    getTreePartitionLayerId(Int idx, Int layerIdx)                         { return m_treePartitionLayerIdList[idx][layerIdx]; }
+  Void    setTreePartitionLayerId(Int idx, Int layerIdx, UInt layerId)           { m_treePartitionLayerIdList[idx][layerIdx] = layerId; }
+#endif
+  UInt    getMaxLayerId()                                       { return m_maxLayerId;   }
+  Void    setMaxLayerId(UInt v)                                 { m_maxLayerId = v;      }
   UInt    getNumLayerSets()                                     { return m_numLayerSets; }
   Void    setNumLayerSets(UInt v)                               { m_numLayerSets = v;    }
-#endif
 #if VPS_EXTN_MASK_AND_DIM_INFO
   Bool   getAvcBaseLayerFlag()                                  { return m_avcBaseLayerFlag;       }
@@ -835,8 +888,10 @@
   Void   setLayerIdInVps(Int id, UInt x)                        { m_layerIdInVps[id] = x;          }
 #endif
-#if ILP_SSH_SIG
-    Bool   getIlpSshSignalingEnabledFlag()                      { return m_ilpSshSignalingEnabledFlag;}
-    Void   setIlpSshSignalingEnabledFlag(Bool x)                { m_ilpSshSignalingEnabledFlag = x;}
-#endif
+#if BITRATE_PICRATE_SIGNALLING
+  UInt   getMaxSLayersInLayerSetMinus1(Int ls)                  { return m_maxSLInLayerSetMinus1[ls]; }
+  Void   setMaxSLayersInLayerSetMinus1(Int ls, Int x)           { m_maxSLInLayerSetMinus1[ls] = x;    }
+#endif
+  Bool   getIlpSshSignalingEnabledFlag()                        { return m_ilpSshSignalingEnabledFlag;}
+  Void   setIlpSshSignalingEnabledFlag(Bool x)                  { m_ilpSshSignalingEnabledFlag = x;}
 #if VPS_EXTN_PROFILE_INFO
   Bool   getProfilePresentFlag(Int id)                          { return m_profilePresentFlag[id]; }
@@ -883,4 +938,6 @@
   UInt   getDirectDependencyType(Int currLayerId, Int refLayerId)               { return m_directDependencyType[currLayerId][refLayerId]; }
   Void   setDirectDependencyType(Int currLayerId, Int refLayerId, UInt x)       { m_directDependencyType[currLayerId][refLayerId] = x;    }
+  Bool   isSamplePredictionType(Int currLayerId, Int refLayerId)                { assert(currLayerId != refLayerId); return ( ( m_directDependencyType[currLayerId][refLayerId] + 1 ) & 1 ) ? true : false; }
+  Bool   isMotionPredictionType(Int currLayerId, Int refLayerId)                { assert(currLayerId != refLayerId); return ( ( ( m_directDependencyType[currLayerId][refLayerId] + 1 ) & 2 ) >> 1 ) ? true : false; }
 #endif
   UInt   getNumProfileTierLevel()                                { return m_numProfileTierLevel; }
@@ -923,8 +980,6 @@
   Void   setCrossLayerAlignedIdrOnlyFlag(Bool x)                              { m_crossLayerAlignedIdrOnlyFlag = x;                         }
 #endif 
-#if N0147_IRAP_ALIGN_FLAG
   Bool   getCrossLayerIrapAlignFlag()                                           { return m_crossLayerIrapAlignFlag;                      }
   Void   setCrossLayerIrapAlignFlag(Bool x)                                     { m_crossLayerIrapAlignFlag = x;                         }
-#endif 
 #if O0225_MAX_TID_FOR_REF_LAYERS
   UInt   getMaxTidIlRefPicsPlus1(Int layerId, Int refLayerId)                     { return m_maxTidIlRefPicsPlus1[layerId][refLayerId];           }
@@ -934,8 +989,6 @@
   Void   setMaxTidIlRefPicsPlus1(Int layerId, UInt maxSublayer)   { m_maxTidIlRefPicsPlus1[layerId] = maxSublayer;            }
 #endif
-#if N0120_MAX_TID_REF_PRESENT_FLAG
   Bool   getMaxTidRefPresentFlag()                                  { return m_maxTidRefPresentFlag ;}
   Void   setMaxTidRefPresentFlag(Bool x)                            { m_maxTidRefPresentFlag = x;}
-#endif 
 #if VPS_TSLAYERS
   Bool   getMaxTSLayersPresentFlag()                                  { return m_maxTSLayersPresentFlag ;}
@@ -960,8 +1013,6 @@
   Void   setLoopFilterNotAcrossTilesFlag(Int currLayerId, Bool x)    { m_loopFilterNotAcrossTilesFlag[currLayerId] = x; } 
 #endif 
-#if TILE_BOUNDARY_ALIGNED_FLAG  
   Bool   getTileBoundariesAlignedFlag(Int currLayerId, Int refLayerId)           { return m_tileBoundariesAlignedFlag[currLayerId][refLayerId]; }
   Void   setTileBoundariesAlignedFlag(Int currLayerId, Int refLayerId, Bool x)   { m_tileBoundariesAlignedFlag[currLayerId][refLayerId] = x; } 
-#endif 
 #if VPS_VUI_WPP_NOT_IN_USE__FLAG  
   Bool   getWppNotInUseFlag()         { return m_wppNotInUseFlag; }
@@ -1001,5 +1052,4 @@
   Void   setMaxtrixCoeff(Int idx, Int x)       { m_vpsMatCoeff[idx] = x;        }
 #endif
-#if VPS_VUI_BITRATE_PICRATE
   Bool   getBitRatePresentVpsFlag()       { return m_bitRatePresentVpsFlag; }
   Void   setBitRatePresentVpsFlag(Bool x) { m_bitRatePresentVpsFlag = x;    }
@@ -1021,5 +1071,4 @@
   Int    getAvgPicRate(Int i, Int j)          { return m_avgPicRate[i][j]; }
   Void   setAvgPicRate(Int i, Int j, Int x)   { m_avgPicRate[i][j] = x;    }
-#endif
 #if O0164_MULTI_LAYER_HRD
   Bool     getVpsVuiBspHrdPresentFlag()                         { return m_vpsVuiBspHrdPresentFlag;      }
@@ -1463,4 +1512,5 @@
 #if SVC_EXTENSION
   UInt        m_layerId;
+  Bool        m_extensionFlag;
   UInt        m_numScaledRefLayerOffsets;
 #if P0312_VERT_PHASE_ADJ
@@ -1621,4 +1671,6 @@
   Void     setLayerId(UInt layerId)            { m_layerId = layerId; }
   UInt     getLayerId()                        { return m_layerId;    }
+  Int      getExtensionFlag()                  { return m_extensionFlag;  }
+  Void     setExtensionFlag(Int n)             { m_extensionFlag = n;     }
   UInt     getNumScaledRefLayerOffsets()       { return m_numScaledRefLayerOffsets; }
   Void     setNumScaledRefLayerOffsets(Int x)  { m_numScaledRefLayerOffsets = x;    }
@@ -1736,4 +1788,5 @@
 
 #if SVC_EXTENSION
+  Bool     m_extensionFlag;
 #if SCALINGLIST_INFERRING
   UInt     m_layerId;
@@ -1862,13 +1915,4 @@
 
 #if SCALINGLIST_INFERRING
-  UInt     getLayerId() { return m_layerId; }
-  Void     setLayerId( UInt layerId ) { m_layerId = layerId;            }
-  Bool     getInferScalingListFlag()  { return m_inferScalingListFlag;  }
-  UInt     getScalingListRefLayerId() { return m_scalingListRefLayerId; }
-  Void     setInferScalingListFlag( Bool flag )     { m_inferScalingListFlag = flag;     }
-  Void     setScalingListRefLayerId( UInt layerId ) { m_scalingListRefLayerId = layerId; }
-#endif
-
-#if SCALINGLIST_INFERRING
   Void     setScalingList( TComScalingList *scalingList ) { m_scalingList = scalingList; }
 #else
@@ -1886,4 +1930,15 @@
   Bool getSliceHeaderExtensionPresentFlag   ()                    { return m_sliceHeaderExtensionPresentFlag; }
   Void setSliceHeaderExtensionPresentFlag   (Bool val)            { m_sliceHeaderExtensionPresentFlag = val; }
+#if SVC_EXTENSION
+  Int     getExtensionFlag()                { return m_extensionFlag;  }
+  Void    setExtensionFlag(Int n)           { m_extensionFlag = n;     }
+#if SCALINGLIST_INFERRING
+  UInt     getLayerId() { return m_layerId; }
+  Void     setLayerId( UInt layerId ) { m_layerId = layerId;            }
+  Bool     getInferScalingListFlag()  { return m_inferScalingListFlag;  }
+  UInt     getScalingListRefLayerId() { return m_scalingListRefLayerId; }
+  Void     setInferScalingListFlag( Bool flag )     { m_inferScalingListFlag = flag;     }
+  Void     setScalingListRefLayerId( UInt layerId ) { m_scalingListRefLayerId = layerId; }
+#endif
 #if POC_RESET_IDC
   Bool getPocResetInfoPresentFlag   ()                    { return m_pocResetInfoPresentFlag; }
@@ -1898,4 +1953,5 @@
   Void    setCGSOutputBitDepthC(Int n){ m_nCGSOutputBitDepthC = n;     }
 #endif
+#endif //SVC_EXTENSION
 };
 
@@ -1935,4 +1991,8 @@
   Int         m_iLastIDR;
   Int         m_iAssociatedIRAP;
+#if POC_RESET_IDC_ENCODER
+  Int         m_associatedIrapPocBeforeReset;
+#endif
+
   NalUnitType m_iAssociatedIRAPType;
   static Int  m_prevTid0POC;
@@ -2061,4 +2121,10 @@
   Bool        m_pocMsbValPresentFlag;
 #endif
+#if POC_RESET_IDC_ENCODER
+  Int         m_pocValueBeforeReset;
+#endif
+#if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER
+  Int         m_picOrderCntLsb;
+#endif
 #if Q0048_CGS_3D_ASYMLUT
   Int        m_nCGSOverWritePPS;  // for optimization, not output to bitstream
@@ -2106,4 +2172,8 @@
     Void     adjustPrevTid0POC      (Int adj)             { m_prevTid0POC=m_prevTid0POC-adj; }
 #endif
+#if POC_RESET_IDC_DECODER
+  Void      setPrevTid0POC( Int x ) { m_prevTid0POC = x; }
+#endif
+
   TComRefPicListModification* getRefPicListModification() { return &m_RefPicListModification; }
   Void      setLastIDR(Int iIDRPOC)                       { m_iLastIDR = iIDRPOC; }
@@ -2111,4 +2181,9 @@
   Void      setAssociatedIRAPPOC(Int iAssociatedIRAPPOC)             { m_iAssociatedIRAP = iAssociatedIRAPPOC; }
   Int       getAssociatedIRAPPOC()                        { return m_iAssociatedIRAP; }
+#if POC_RESET_IDC_ENCODER
+  Void setAssociatedIrapPocBeforeReset(Int x) { m_associatedIrapPocBeforeReset = x; }
+  Int  getAssociatedIrapPocBeforeReset(     ) { return m_associatedIrapPocBeforeReset; }
+#endif
+
   Void      setAssociatedIRAPType(NalUnitType associatedIRAPType)    { m_iAssociatedIRAPType = associatedIRAPType; }
   NalUnitType getAssociatedIRAPType()                        { return m_iAssociatedIRAPType; }
@@ -2220,5 +2295,9 @@
   Void setTLayerInfo( UInt uiTLayer );
   Void decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum ); 
+#if POC_RESET_IDC_ENCODER
+  Void checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic, Bool usePocBeforeReset = false);
+#else
   Void checkLeadingPictureRestrictions( TComList<TComPic*>& rcListPic );
+#endif
   Void applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *RPSList);
   Bool isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic );
@@ -2418,4 +2497,20 @@
   Bool      getCraPicFlag       ();
 #endif
+#if POC_RESET_IDC_DECODER
+  Bool      getRaslPicFlag      ();
+  Bool      getRadlPicFlag      ();
+#endif
+#if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER
+  Int       getPicOrderCntLsb() { return m_picOrderCntLsb; }
+  Void      setPicOrderCntLsb(Int x) { m_picOrderCntLsb = x; }
+#endif
+
+#if POC_RESET_IDC_ENCODER
+  Int       getPocValueBeforeReset ()                        { return m_pocValueBeforeReset; }
+  Void      setPocValueBeforeReset (Int x)                   { m_pocValueBeforeReset = x ;   }
+  Void      decrementRefPocValues(Int const decrementValue);
+  Int       getCurrMsb( Int currLsb, Int prevLsb, Int prevMsb, Int maxLsbVal );
+#endif
+
 
 #endif //SVC_EXTENSION
@@ -2472,4 +2567,16 @@
   }
 
+#if Q0078_ADD_LAYER_SETS
+  Void removePS(Int psId)
+  {
+    assert(psId < m_maxId);
+    if (m_paramsetMap.find(psId) != m_paramsetMap.end())
+    {
+      m_paramsetMap.erase(psId);
+    }
+  }
+#endif
+
+
 private:
   std::map<Int,T *> m_paramsetMap;
@@ -2494,4 +2601,7 @@
   TComSPS* getSPS(Int spsId)  { return m_spsMap.getPS(spsId); };
   TComSPS* getFirstSPS()      { return m_spsMap.getFirstPS(); };
+#if Q0078_ADD_LAYER_SETS
+  Void     removeSPS(Int spsId) { m_spsMap.removePS(spsId); };
+#endif
 
   //! store picture parameter set and take ownership of it 
@@ -2500,4 +2610,7 @@
   TComPPS* getPPS(Int ppsId)  { return m_ppsMap.getPS(ppsId); };
   TComPPS* getFirstPPS()      { return m_ppsMap.getFirstPS(); };
+#if Q0078_ADD_LAYER_SETS
+  Void     removePPS(Int ppsId) { m_ppsMap.removePS(ppsId); };
+#endif
 
   //! activate a SPS from a active parameter sets SEI message
Index: trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 713)
+++ trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 815)
@@ -1,90 +1,44 @@
-
+#include "TypeDef.h"
+#if SVC_EXTENSION
 #include "TComUpsampleFilter.h"
-#include "TypeDef.h"
-
-#if SVC_UPSAMPLING
-#define CNU -1 ///< Coefficients Not Used
 
 const Int TComUpsampleFilter::m_lumaFixedFilter[16][NTAPS_US_LUMA] =
 {
-  {  0,  0,  0, 64,  0,  0,  0,  0}, //
-#if ARBITRARY_SPATIAL_RATIO
-  {  0,  1, -3, 63,  4, -2,  1,  0},
-  { -1,  2, -5, 62,  8, -3,  1,  0},
-  { -1,  3, -8, 60, 13, -4,  1,  0},
-  { -1,  4,-10, 58, 17, -5,  1,  0},
-#else
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-#endif
-  { -1, 4, -11, 52, 26,  -8,  3, -1}, // <-> actual phase shift 1/3, used for spatial scalability x1.5
-#if ARBITRARY_SPATIAL_RATIO
-  { -1, 3,  -9, 47, 31, -10,  4, -1},
-  { -1, 4, -11, 45, 34, -10,  4, -1},
-#else
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-#endif
-  { -1, 4, -11, 40, 40, -11,  4, -1}, // <-> actual phase shift 1/2, equal to HEVC MC, used for spatial scalability x2
-#if ARBITRARY_SPATIAL_RATIO
-  { -1,  4, -10, 34, 45, -11,  4, -1},
-  { -1,  4, -10, 31, 47,  -9,  3, -1},
-#else
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-#endif
-  { -1, 3,  -8, 26, 52, -11, 4, -1}, // <-> actual phase shift 2/3, used for spatial scalability x1.5
-#if ARBITRARY_SPATIAL_RATIO
-  { 0,  1,  -5, 17, 58, -10,  4, -1},
-  { 0,  1,  -4, 13, 60,  -8,  3, -1},
-  { 0,  1,  -3,  8, 62,  -5,  2, -1},
-  { 0,  1,  -2,  4, 63,  -3,  1,  0}
-#else
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-  {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}  //
-#endif
+  {  0, 0,   0, 64,  0,   0,  0,  0 },
+  {  0, 1,  -3, 63,  4,  -2,  1,  0 },
+  { -1, 2,  -5, 62,  8,  -3,  1,  0 },
+  { -1, 3,  -8, 60, 13,  -4,  1,  0 },
+  { -1, 4, -10, 58, 17,  -5,  1,  0 },
+  { -1, 4, -11, 52, 26,  -8,  3, -1 }, // <-> actual phase shift 1/3, used for spatial scalability x1.5
+  { -1, 3,  -9, 47, 31, -10,  4, -1 },
+  { -1, 4, -11, 45, 34, -10,  4, -1 },
+  { -1, 4, -11, 40, 40, -11,  4, -1 }, // <-> actual phase shift 1/2, equal to HEVC MC, used for spatial scalability x2
+  { -1, 4, -10, 34, 45, -11,  4, -1 },
+  { -1, 4, -10, 31, 47,  -9,  3, -1 },
+  { -1, 3,  -8, 26, 52, -11,  4, -1 }, // <-> actual phase shift 2/3, used for spatial scalability x1.5
+  {  0, 1,  -5, 17, 58, -10,  4, -1 },
+  {  0, 1,  -4, 13, 60,  -8,  3, -1 },
+  {  0, 1,  -3,  8, 62,  -5,  2, -1 },
+  {  0, 1,  -2,  4, 63,  -3,  1,  0 }
 };
 
 const Int TComUpsampleFilter::m_chromaFixedFilter[16][NTAPS_US_CHROMA] =
 {
-  {  0, 64,  0,  0},//
-#if ARBITRARY_SPATIAL_RATIO
-  { -2, 62,  4,  0},
-  { -2, 58, 10, -2},
-  { -4, 56, 14, -2},
-#else
-  {CNU,CNU,CNU,CNU},//
-  {CNU,CNU,CNU,CNU},//
-  {CNU,CNU,CNU,CNU},//
-#endif
-  { -4, 54, 16, -2},// <-> actual phase shift 1/4,equal to HEVC MC, used for spatial scalability x1.5 (only for accurate Chroma alignement)
-  { -6, 52, 20, -2},// <-> actual phase shift 1/3, used for spatial scalability x1.5
-  { -6, 46, 28, -4},// <-> actual phase shift 3/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)
-#if ARBITRARY_SPATIAL_RATIO
-  { -4, 42, 30, -4},
-#else
-  {CNU,CNU,CNU,CNU},//
-#endif
-  { -4, 36, 36, -4},// <-> actual phase shift 1/2,equal to HEVC MC, used for spatial scalability x2
-  { -4, 30, 42, -4},// <-> actual phase shift 7/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
-#if ARBITRARY_SPATIAL_RATIO
-  { -4, 28, 46, -6},
-#else
-  {CNU,CNU,CNU,CNU},//
-#endif
-  { -2, 20, 52, -6},// <-> actual phase shift 2/3, used for spatial scalability x1.5
-#if ARBITRARY_SPATIAL_RATIO
-  {-2, 16, 54, -4},
-  {-2, 14, 56, -4},
-#else
-  {CNU,CNU,CNU,CNU},//
-  {CNU,CNU,CNU,CNU},//
-#endif
-  { -2, 10, 58, -2},// <-> actual phase shift 7/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)
-  {  0,  4, 62, -2} // <-> actual phase shift 11/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
+  {  0, 64,  0,  0 },
+  { -2, 62,  4,  0 },
+  { -2, 58, 10, -2 },
+  { -4, 56, 14, -2 },
+  { -4, 54, 16, -2 }, // <-> actual phase shift 1/4,equal to HEVC MC, used for spatial scalability x1.5 (only for accurate Chroma alignement)
+  { -6, 52, 20, -2 }, // <-> actual phase shift 1/3, used for spatial scalability x1.5
+  { -6, 46, 28, -4 }, // <-> actual phase shift 3/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)
+  { -4, 42, 30, -4 },
+  { -4, 36, 36, -4 }, // <-> actual phase shift 1/2,equal to HEVC MC, used for spatial scalability x2
+  { -4, 30, 42, -4 }, // <-> actual phase shift 7/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
+  { -4, 28, 46, -6 },
+  { -2, 20, 52, -6 }, // <-> actual phase shift 2/3, used for spatial scalability x1.5
+  { -2, 16, 54, -4 },
+  { -2, 14, 56, -4 },
+  { -2, 10, 58, -2 }, // <-> actual phase shift 7/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)
+  {  0,  4, 62, -2 }  // <-> actual phase shift 11/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
 };
 
@@ -260,11 +214,6 @@
     }
 
-#if ARBITRARY_SPATIAL_RATIO
     assert ( widthEL >= widthBL );
     assert ( heightEL >= heightBL );
-#else
-    assert ( widthEL == widthBL || widthEL == 2*widthBL || 2*widthEL == 3*widthBL );
-    assert ( heightEL == heightBL || heightEL == 2*heightBL || 2*heightEL == 3*heightBL );
-#endif
 
     pcBasePic->setBorderExtension(false);
@@ -298,11 +247,6 @@
 #endif
  
-#if ROUNDING_OFFSET
     Int   addX = ( ( phaseX * scaleX + 2 ) >> 2 ) + ( 1 << ( shiftX - 5 ) );
     Int   addY = ( ( phaseY * scaleY + 2 ) >> 2 ) + ( 1 << ( shiftY - 5 ) );
-#else
-    Int   addX = ( ( ( widthBL * phaseX ) << ( shiftX - 2 ) ) + ( widthEL >> 1 ) ) / widthEL + ( 1 << ( shiftX - 5 ) );
-    Int   addY = ( ( ( heightBL * phaseY ) << ( shiftY - 2 ) ) + ( heightEL >> 1 ) ) / heightEL+ ( 1 << ( shiftY - 5 ) );
-#endif
 
 #if Q0120_PHASE_CALCULATION
@@ -333,5 +277,4 @@
     Int bottomEndL = pcUsPic->getHeight() - scalEL.getWindowBottomOffset();
     Int leftOffset = leftStartL > 0 ? leftStartL : 0;
-#if N0214_INTERMEDIATE_BUFFER_16BITS
 #if O0194_JOINT_US_BITSHIFT
     // g_bitDepthY was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
@@ -345,5 +288,4 @@
 #else
     Int shift1 = g_bitDepthY - 8;
-#endif
 #endif
 
@@ -362,9 +304,5 @@
       for( j = 0; j < heightBL ; j++ )
       {
-#if N0214_INTERMEDIATE_BUFFER_16BITS
         *piDstY = sumLumaHor(piSrcY, coeff) >> shift1;
-#else
-        *piDstY = sumLumaHor(piSrcY, coeff);
-#endif
         piSrcY += strideBL;
         piDstY += strideEL;
@@ -378,12 +316,8 @@
     pcTempPic->setHeight(heightEL);
 
-#if N0214_INTERMEDIATE_BUFFER_16BITS
 #if O0194_JOINT_US_BITSHIFT
     Int nShift = 20 - g_bitDepthYLayer[currLayerId];
 #else
     Int nShift = US_FILTER_PREC*2 - shift1;
-#endif
-#else
-    const Int nShift = US_FILTER_PREC*2;
 #endif
     Int iOffset = 1 << (nShift - 1);
@@ -472,11 +406,6 @@
 #endif
     
-#if ROUNDING_OFFSET
     addX       = ( ( phaseXC * scaleX + 2 ) >> 2 ) + ( 1 << ( shiftX - 5 ) );
     addY       = ( ( phaseYC * scaleY + 2 ) >> 2 ) + ( 1 << ( shiftY - 5 ) );
-#else
-    addX       = ( ( ( widthBL * (phaseXC) ) << ( shiftX - 2 ) ) + ( widthEL >> 1 ) ) / widthEL + ( 1 << ( shiftX - 5 ) );
-    addY       = ( ( ( heightBL * (phaseYC) ) << ( shiftY - 2 ) ) + ( heightEL >> 1 ) ) / heightEL+ ( 1 << ( shiftY - 5 ) );
-#endif
 
 #if Q0120_PHASE_CALCULATION
@@ -502,5 +431,4 @@
     heightBL  = min<Int>( pcBasePic->getHeight() >> 1, heightEL );
 
-#if N0214_INTERMEDIATE_BUFFER_16BITS
 #if O0194_JOINT_US_BITSHIFT
     // g_bitDepthC was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
@@ -514,5 +442,4 @@
 #else
     shift1 = g_bitDepthC - 8;
-#endif
 #endif
 
@@ -533,11 +460,6 @@
       for( j = 0; j < heightBL ; j++ )
       {
-#if N0214_INTERMEDIATE_BUFFER_16BITS
         *piDstU = sumChromaHor(piSrcU, coeff) >> shift1;
         *piDstV = sumChromaHor(piSrcV, coeff) >> shift1;
-#else
-        *piDstU = sumChromaHor(piSrcU, coeff);
-        *piDstV = sumChromaHor(piSrcV, coeff);
-#endif
 
         piSrcU += strideBL;
@@ -554,5 +476,4 @@
     pcTempPic->setHeight(heightEL << 1);
 
-#if N0214_INTERMEDIATE_BUFFER_16BITS
 #if O0194_JOINT_US_BITSHIFT
     nShift = 20 - g_bitDepthCLayer[currLayerId];
@@ -561,5 +482,4 @@
 #endif
     iOffset = 1 << (nShift - 1);
-#endif
 
     for( j = 0; j < pcTempPic->getHeight() >> 1; j++ )
Index: trunk/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/TypeDef.h	(revision 713)
+++ trunk/source/Lib/TLibCommon/TypeDef.h	(revision 815)
@@ -41,13 +41,18 @@
 #define SVC_EXTENSION                    1
 
-#define SYNTAX_BYTES                     10      ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)]
+#define SYNTAX_BYTES                     10     ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)]
 #if SVC_EXTENSION
 #define MAX_LAYERS                       8      ///< max number of layers the codec is supposed to handle
 
 #define VPS_VUI_OFFSET                   1      ///< N0085: Signal VPS VUI offset in the VPS extension 
-#define RANDOM_ACCESS_SEI_FIX            1
 #define O0137_MAX_LAYERID                1      ///< JCTVC-O0137, JCTVC-O0200, JCTVC-O0223: restrict nuh_layer_id and vps_max_layers_minus1
 
-#define Q0200_CONFORMANCE_BL_SIZE        1       ///< JCTVC-Q0200; use conformance picture size in re-sampling processs
+#define Q0108_TSA_STSA                   0      ///< JCTVC-Q0108, Remove cross-layer alignment constraints of TSA and STSA pictures, enable to have different prediction structures in different layers
+#define Q0177_SPS_TEMP_NESTING_FIX       1      ///< JCTVC-Q0177; Fix the inference value of sps_temporal_id_nesting_flag when it is not present
+#define Q0177_EOS_CHECKS                 1      ///< JCTVC-Q0177; Put checks on handling EOS
+#define Q0142_POC_LSB_NOT_PRESENT        1      ///< JCTVC-Q0142; Add constraint checking on the value of poc_reset_idc and poc_lsb_val
+#define Q0146_SSH_EXT_DATA_BIT           1      ///< JCTVC-Q0146; Bug-fix -- the SSH_EXT_DATA_BIT can have any value -- not required to be 1
+
+#define Q0200_CONFORMANCE_BL_SIZE        1      ///< JCTVC-Q0200; use conformance picture size in re-sampling processs
 #define P0312_VERT_PHASE_ADJ             1      ///< JCTVC-P0312: vertical phase adjustment in re-sampling process (BoG report)
 #if P0312_VERT_PHASE_ADJ
@@ -62,11 +67,7 @@
 #define VPS_EXTN_UEV_CODING              1      ///< JCTVC-P0306: Code some syntax elements as ue(v), and remove some syntax elements that duplicate behaviour
 #define CHANGE_NUMSUBDPB_IDX             1      ///< Change index of NumSubDpb from output layer set to layer set, to be more aligned with the Spec
-#define RESOLUTION_BASED_DPB             1      ///< JCTVC-P0192: Assign layers to sub-DPBs based on the rep_format() signaled in the VPS
+#define RESOLUTION_BASED_DPB             0      ///< JCTVC-Q0154 - remove sharing of sub-DPB across layers
+                                                ///< JCTVC-P0192: Assign layers to sub-DPBs based on the rep_format() signaled in the VPS
 #define ALIGNED_BUMPING                  1      ///< JCTVC-P0192: Align bumping of pictures in an AU
-#define MAX_SUBDPBS                      MAX_LAYERS
-#define SUB_BITSTREAM_PROPERTY_SEI       1      ///< JCTVC-P0204: Sub-bitstream property SEI message
-#if SUB_BITSTREAM_PROPERTY_SEI
-#define MAX_SUB_STREAMS                  1024
-#endif
 #define O0109_O0199_FLAGS_TO_VUI         1      ///< JCTVC-O0109, O0199: move single_layer_for_non_irap_flag and higher_layer_flag to vps_vui
 #define O0109_VIEW_ID_LEN                1      ///< JCTVC-O0109: view_id_len_minus1 to view_id_len, and add constraint (1<<view_id_len) is greater than or equal to NumViews
@@ -77,5 +78,5 @@
 #endif
 
-#define P0295_DEFAULT_OUT_LAYER_IDC      1      ///< JCTVC-P0295: modifify default_one_target_output_layer_idc to default_target_output_layer_idc
+#define P0295_DEFAULT_OUT_LAYER_IDC      1      ///< JCTVC-P0295: modifify default_one_target_output_layer_idc to default_output_layer_idc
 #define O0109_DEFAULT_ONE_OUT_LAYER_IDC  1      ///< JCTVC-O0109: default_one_target_output_layer_flag to default_one_target_output_layer_idc
 #define O0109_MOVE_VPS_VUI_FLAG          1      ///< JCTVC-O0109: move vps_vui_present_flag before vps_vui_offset
@@ -84,5 +85,5 @@
 
 #define O0164_MULTI_LAYER_HRD            1      ///< JCTVC-O0164: Multi-layer HRD operation
-#define Q0074_SEI_COLOR_MAPPING          1      ///< JCTVC-Q0074, SEI Color Mapping
+#define Q0182_MULTI_LAYER_HRD_UPDATE     1      ///< JCTVC-Q0182: On bitstream partition buffering
 
 #define O0194_DIFFERENT_BITDEPTH_EL_BL   1      ///< JCTVC-O0194: Support for different bitdepth values for BL and EL, add required configuration parameters (and Some bugfixes when REPN_FORMAT_IN_VPS (JCTVC-N0092) is enabled)
@@ -92,31 +93,29 @@
 #define Q0048_CGS_3D_ASYMLUT             1      ///< JCTVC-Q0048: Colour gamut scalability with look-up table
 #if Q0048_CGS_3D_ASYMLUT
+#define CGS_GCC_NO_VECTORIZATION         1
 #define O0194_WEIGHTED_PREDICTION_CGS    0
 #else
 #define O0194_WEIGHTED_PREDICTION_CGS    1      ///< JCTVC-O0194: Weighted prediciton for color gamut scalability
 #endif
-#define MFM_ENCCONSTRAINT                1      ///< JCTVC-O0216: Encoder constraint for motion field mapping
-#define VPS_NUH_LAYER_ID                 1      ///< JCTVC-N0085: Assert that the nuh_layer_id of VPS NAL unit should be 0
-#define POC_RESET_FLAG                   1      ///< JCTVC-N0244: POC reset flag for  layer pictures.
+#define POC_RESET_FLAG                   0      ///< JCTVC-N0244: POC reset flag for  layer pictures.
 #define POC_RESET_IDC                    1      ///< JCTVC-P0041: Include poc_reset_idc and related derivation - eventually will replace POC_RESET_FLAG
 #if POC_RESET_IDC
 #define POC_RESET_IDC_SIGNALLING         1      ///< JCTVC-P0041: Include signalling for poc_reset related syntax elements
-#endif
+#define POC_RESET_IDC_ENCODER            1      ///< JCTVC-P0041: Include support of enabling POC reset at the encoder
+#define POC_RESET_IDC_DECODER            1      ///< JCTVC-P0041: Include support of enabling POC reset at the decoder
+#define ALIGN_IRAP_BUGFIX                1
+#define UNAVAILABLE_PIC_BUGFIX           1
+#endif
+#define POC_MSB_VAL_PRESENT_FLAG_SEM     1      ///< JCTVC-Q0146: Inference of poc_msb_val_present_flag
+#define POC_RESET_INFO_INFERENCE         1      ///< JCTVC-Q0146: Infer the value of poc_reset_info_present_flag when not present
 #define NO_OUTPUT_OF_PRIOR_PICS          1      ///< Use no_output_of_prior_pics_flag
-#define ALIGN_TSA_STSA_PICS              1      ///< JCTVC-N0084: Alignment of TSA and STSA pictures across AU.
 #define REPN_FORMAT_IN_VPS               1      ///< JCTVC-N0092: Signal represenation format (spatial resolution, bit depth, colour format) in the VPS
 #if REPN_FORMAT_IN_VPS
 #define REPN_FORMAT_CONTROL_FLAG         1      ///< JCTVC-O0179: Add control flag in representation format to control sending of chroma and bitdepth parameters
 #endif 
-#define TIMING_INFO_NONZERO_LAYERID_SPS  1      ///< JCTVC-N0085: Semantics of vui_timing_info_present_flag to always set that flag to zero for non-zero layer ID SPS 
 #define RPL_INIT_N0316_N0082             1      ///< JCTVC-N0316, JCTVC-N0082: initial reference picture list construction 
 
 #define SCALINGLIST_INFERRING            1      ///< JCTVC-N0371: inter-layer scaling list
-#define SPS_EXTENSION                    1      ///< Define sps_extension() syntax structure
-#if SPS_EXTENSION
 #define O0142_CONDITIONAL_SPS_EXTENSION  1      ///< JCTVC-O0142: Conditional SPS extension
-#endif
-#define SCALABILITY_MASK_E0104           1      ///< JCT3V-E0104: scalability mask for depth
-#define LAYER_CTB                        0      ///< enable layer-specific CTB structure
 #if POC_RESET_FLAG
 #define PREVTID0_POC_RESET               1      ///< JCTVC-O0117 Modification of the PicOrderCntVal of prevTid0Pic
@@ -124,14 +123,4 @@
 #endif
 
-#define ILP_SSH_SIG                      1      ///< JCTVC-N0195 proposal 2, JCTVC-N0118: add presence flag in VPS ext to condition inter-layer prediction signaling in slice segment header
-#if ILP_SSH_SIG
-#define ILP_SSH_SIG_FIX                  1      ///< fix for SHM ticket #5
-#endif 
-#define SPL_FLG_CHK                      1      ///< JCTVC-N0195 proposal 5, JCTVC-N0085: constrain sum of lengths to be less than or equal to 6
-#define ILP_NUM_REF_CHK                  1      ///< JCTVC-N0195 proposal 1, JCTVC-N0081, JCTVC-N0154, JCTVC-N0217: a condition on signaling inter_layer_pred_layer_idc[ i ], to avoid sending when NumDirectRefLayers equals NumActiveRefLayerPics, and instead infer values
-
-#define VPS_RENAME                       1      ///< Rename variables max_layer_id and num_layer_sets_minus1 in VPS
-#define VPS_EXTNS                        1      ///< Include function structure for VPS extensions
-#if VPS_EXTNS
 #define VPS_EXTN_MASK_AND_DIM_INFO       1      ///< Include avc_base_layer_flag, splitting_flag, scalability mask and dimension related info
 #if VPS_EXTN_MASK_AND_DIM_INFO
@@ -142,12 +131,8 @@
 #define VPS_EXTN_DIRECT_REF_LAYERS       1      ///< Include indication of direct dependency of layers in VPS extension
 #define M0040_ADAPTIVE_RESOLUTION_CHANGE 1
-#define VPS_VUI                          1      ///< Include function structure for VPS VUI
-
-#if VPS_VUI
+
 #define VPS_VUI_TILES_NOT_IN_USE__FLAG   1      ///< JCTVC-O0226: VPS VUI flag to indicate tile not in use
 #define VPS_VUI_WPP_NOT_IN_USE__FLAG     1      ///< JCTVC-O0226: VPS VUI flag to indicate tile not in use
-#define TILE_BOUNDARY_ALIGNED_FLAG       1      ///< JCTVC-N0160/JCTVC-N0199 proposal 2 variant 2: VPS VUI flag to indicate tile boundary alignment
 #define N0160_VUI_EXT_ILP_REF            1      ///< VUI extension inter-layer dependency offset signalling
-#define VPS_VUI_BITRATE_PICRATE          1      ///< JCTVC-N0085: Signal bit rate and picture in VPS VUI
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
 #define HIGHER_LAYER_IRAP_SKIP_FLAG      1      ///< JCTVC-O0199: Indication that higher layer IRAP picture uses skip blocks only
@@ -158,7 +143,4 @@
 #endif 
 #define P0182_VPS_VUI_PS_FLAG            1      ///< JCTVC-P0182, add base_layer_parameter_set_compatibility_flag
-#endif //VPS_VUI
-
-#endif
 
 #define P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED        1   ///< JCTVC-P0125 -- Keep it as a reserved FFFF value --- The following two macros (VPS_EXTN_OFFSET & VPS_EXTN_OFFSET_CALC) will have no effect when this macro is set to 1.
@@ -169,11 +151,4 @@
 #define DERIVE_LAYER_ID_LIST_VARIABLES   1      ///< Derived variables based on the variables in VPS - for use in syntax table parsing
 
-#define SVC_UPSAMPLING                   1      ///< upsampling filters
-#define ROUNDING_OFFSET                  1      ///< JCTVC-N0111: upsampling rounding offset using scalling factors
-#define N0214_INTERMEDIATE_BUFFER_16BITS 1      ///< JCTVC-N0214: support base layer input more than 8 bits
-#define ARBITRARY_SPATIAL_RATIO          1      ///< JCTVC-N0219, JCTVC-N0273: Support arbitrary spatial ratio
-
-#define JCTVC_M0259_LAMBDAREFINEMENT     1      ///< JCTVC-M0259: lambda refinement (encoder only optimization)
-
 #define AVC_BASE                         1      ///< YUV BL reading for AVC base SVC
 #if AVC_BASE
@@ -181,12 +156,9 @@
 #endif
 
-#define REF_IDX_ME_ZEROMV                1      ///< JCTVC-L0051: use zero motion for inter-layer reference picture (without fractional ME)
-#define ENCODER_FAST_MODE                1      ///< JCTVC-L0174: enable encoder fast mode. TestMethod 1 is enabled by setting to 1 and TestMethod 2 is enable by setting to 2. By default it is set to 1.
 #define REF_IDX_MFM                      1      ///< JCTVC-L0336: motion vector mapping of inter-layer reference picture
 #define MAX_ONE_RESAMPLING_DIRECT_LAYERS 1      ///< Allow maximum of one resampling process for direct reference layers
 #define MOTION_RESAMPLING_CONSTRAINT     1      ///< JCTVC-N0108: Allow maximum of one motion resampling process for direct reference layers, and use motion inter-layer prediction from the same layer as texture inter-layer prediction.
-#define EARLY_REF_PIC_MARKING            1      ///< Decoded picture marking of sub-layer non-reference pictures
-#define N0120_MAX_TID_REF_PRESENT_FLAG   1      ///< JCTVC-N0120: max_tid_ref_pics_plus1_present_flag
-#define N0120_MAX_TID_REF_CFG            1      ///< set max_tid_il_ref_pics_plus1 and max_tid_ref_present_flag in the config. file (configuration setting)
+#define EARLY_REF_PIC_MARKING            0      ///< Valencia meeting - remove early marking of inter-layer reference pictures
+                                                ///< Decoded picture marking of sub-layer non-reference pictures
 #define O0225_MAX_TID_FOR_REF_LAYERS     1
 #define O0225_TID_BASED_IL_RPS_DERIV     1
@@ -195,30 +167,12 @@
 #define P0079_DERIVE_NUMACTIVE_REF_PICS  1      ///< JCTVC-P0079 Modification of derivation of variable NumActiveRefLayerPics
 #define Q0060_MAX_TID_REF_EQUAL_TO_ZERO  1      ///< JCTVC-Q0060 handling the case max_tid_il_ref_pics_plus1 is equal to 0.
-#if REF_IDX_MFM
-#define N0139_POSITION_ROUNDING_OFFSET   1      ///< JCTVC-N0139: offset for collocated block in motion mapping
-#endif
-
-#define O0223_PICTURE_TYPES_ALIGN_FLAG   1  ///< a flag to indicatate whether picture types are aligned across layers.
+
+#define O0223_PICTURE_TYPES_ALIGN_FLAG   1      ///< a flag to indicatate whether picture types are aligned across layers.
 
 #define P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG   1  ///< a flag to indicatate whether picture types for IRAP are IDR across layers.
 
-#define N0147_IRAP_ALIGN_FLAG            1      ///< a flag to indicatate whether IRAPs are aligned across layers
-#if N0147_IRAP_ALIGN_FLAG
-#define O0223_O0139_IRAP_ALIGN_NO_CONTRAINTS  1  ///< Remove IRAP align depedency constraints on poc_Reset_flag.
-#define IRAP_ALIGN_FLAG_IN_VPS_VUI       1       ///< Move IRAP align flag to VPS VUI 
-#endif 
-#if !N0147_IRAP_ALIGN_FLAG
-#define IDR_ALIGNMENT                    1      ///< align IDR picures across layers : As per JCTVC-N0373, IDR are not required to be aligned.
-#endif
-#define FAST_INTRA_SHVC                  1      ///< JCTVC-M0115: reduction number of intra modes in the EL (encoder only)
-#if FAST_INTRA_SHVC
-#define NB_REMAIN_MODES                  2      ///< JCTVC-M0115: nb of remaining modes
-#endif
-
-#define RC_SHVC_HARMONIZATION            1      ///< JCTVC-M0037: rate control for SHVC
+#define IRAP_ALIGN_FLAG_IN_VPS_VUI       1      ///< Move IRAP align flag to VPS VUI 
 
 #define VIEW_ID_RELATED_SIGNALING        1      ///< Introduce syntax elements view_id and view_id_val
-#define LAYERS_NOT_PRESENT_SEI           1      ///< JCTVC-M0043: add layers not present SEI.
-#define N0383_IL_CONSTRAINED_TILE_SETS_SEI  1
 #define N0065_LAYER_POC_ALIGNMENT        1
 
@@ -246,5 +200,10 @@
 
 #define Q0165_OUTPUT_LAYER_SET           1      ///< JCTVC-Q0165: add a constraint to disallow an empty output layer set
-#define Q0165_NUM_ADD_OUTPUT_LAYER_SETS  1      ///< JCTVC-Q0165: signal num_add_output_layer_set and default_target_output_layer_idc when vps_num_layer_sets_minus1 is greater than 0
+#define Q0165_NUM_ADD_OUTPUT_LAYER_SETS  1      ///< JCTVC-Q0165: signal num_add_olss and default_target_output_layer_idc when vps_num_layer_sets_minus1 is greater than 0
+
+#define Q0078_ADD_LAYER_SETS             1      ///< JCTVC-Q0078: additional layer sets and layer set config
+#if Q0078_ADD_LAYER_SETS
+#define MAX_NUM_ADD_LAYER_SETS           1023
+#endif
 
 #define VPS_DPB_SIZE_TABLE               1      ///< JCTVC-O0217: DPB operations: signaling DPB-related parameters
@@ -263,13 +222,43 @@
 #define P0138_USE_ALT_CPB_PARAMS_FLAG    1      ///< JCTVC-P0138: use_alt_cpb_params_flag syntax in buffering period SEI message extension
 #define P0166_MODIFIED_PPS_EXTENSION     1      ///< JCTVC-P0166: add pps_extension_type_flag
-
-#if VIEW_ID_RELATED_SIGNALING
+#define BITRATE_PICRATE_SIGNALLING       1      ///< JCTVC-Q0102 Proposal 3 signal bitrate, picrate only up to the maximum temporal sub-layers in the corresponding layer set
+#define LAYER_DECPICBUFF_PARAM           1      ///< JCTVC-Q0102 Proposal 2 infer value from layer DPB param
+#define HRD_BPB                          1      ///< JCTVC-Q0101 Bitstream Partition Buffering Proposals
+#define DPB_CONSTRAINTS                  1      ///< JCTVC-Q0100 RPS DPB constraints
+
 /// scalability types
 enum ScalabilityType
 {
   VIEW_ORDER_INDEX  = 1,
-  SCALABILITY_ID = 2,
-};
-#endif
+  SCALABILITY_ID    = 2,
+  AUX_ID            = 3,
+};
+
+/// normative encoder constraints --------
+#define MFM_ENCCONSTRAINT                1      ///< JCTVC-O0216: Encoder constraint for motion field mapping
+#define REF_IDX_ME_ZEROMV                1      ///< JCTVC-L0051: use zero motion for inter-layer reference picture (without fractional ME)
+
+/// encoder settings ---------------------
+#define FAST_INTRA_SHVC                  1      ///< JCTVC-M0115: reduction number of intra modes in the EL (encoder only)
+#if FAST_INTRA_SHVC
+#define NB_REMAIN_MODES                  2      ///< JCTVC-M0115: nb of remaining modes
+#endif
+#define RC_SHVC_HARMONIZATION            1      ///< JCTVC-M0037: rate control for SHVC
+#define JCTVC_M0259_LAMBDAREFINEMENT     1      ///< JCTVC-M0259: lambda refinement (encoder only optimization)
+#define ENCODER_FAST_MODE                1      ///< JCTVC-L0174: enable encoder fast mode. TestMethod 1 is enabled by setting to 1 and TestMethod 2 is enable by setting to 2. By default it is set to 1.
+#define LAYER_CTB                        0      ///< enable layer-specific CTB structure
+
+/// SEI messages -------------------------
+#define P0050_KNEE_FUNCTION_SEI          1      ///< JCTVC-P0050: Knee function SEI
+#define SUB_BITSTREAM_PROPERTY_SEI       1      ///< JCTVC-P0204: Sub-bitstream property SEI message
+#if SUB_BITSTREAM_PROPERTY_SEI
+#define MAX_SUB_STREAMS                  1024
+#endif
+#define Q0074_SEI_COLOR_MAPPING          1      ///< JCTVC-Q0074, SEI Color Mapping
+#define LAYERS_NOT_PRESENT_SEI           1      ///< JCTVC-M0043: add layers not present SEI.
+#define N0383_IL_CONSTRAINED_TILE_SETS_SEI  1
+#define Q0189_TMVP_CONSTRAINTS           1      ///< JCTVC-Q0189: indicate constraints on TMVP
+#define Q0247_FRAME_FIELD_INFO           1      ///< JCTVC-Q0247: field_frame_info SEI message
+
 
 #else
@@ -304,6 +293,6 @@
 #define MAX_NESTING_NUM_LAYER       64
 
-#if VPS_RENAME
-#define MAX_VPS_OP_LAYER_SETS_PLUS1               3
+#if SVC_EXTENSION
+#define MAX_VPS_OP_LAYER_SETS_PLUS1               (MAX_LAYERS+1)
 #define MAX_VPS_LAYER_SETS_PLUS1                  1024
 #define MAX_VPS_LAYER_ID_PLUS1                    MAX_LAYERS
