Index: trunk/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/CommonDef.h	(revision 313)
+++ trunk/source/Lib/TLibCommon/CommonDef.h	(revision 345)
@@ -57,5 +57,5 @@
 
 #if SVC_EXTENSION
-#define NV_VERSION        "trunk"                 ///< Current software version
+#define NV_VERSION        "3.0"                 ///< Current software version
 #else
 #define NV_VERSION        "11.0"                ///< Current software version
Index: trunk/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- trunk/source/Lib/TLibCommon/ContextTables.h	(revision 313)
+++ trunk/source/Lib/TLibCommon/ContextTables.h	(revision 345)
@@ -92,7 +92,4 @@
 #define NUM_SAO_MERGE_FLAG_CTX        1       ///< number of context models for SAO merge flags
 #define NUM_SAO_TYPE_IDX_CTX          1       ///< number of context models for SAO type index
-#if INTRA_BL
-#define NUM_INTRA_BL_PRED_CTX         3
-#endif
 
 #define NUM_TRANSFORMSKIP_FLAG_CTX    1       ///< number of context models for transform skipping 
@@ -330,13 +327,4 @@
 };
 
-#if INTRA_BL
-static const UChar 
-INIT_INTRA_BL_PRED_FLAG[3][NUM_INTRA_BL_PRED_CTX] = 
-{
-  { 185,  185,  201, }, 
-  { 197,  197,  185, }, 
-  { 197,  197,  185, }, 
-};
-#endif
 static const UChar
 INIT_TRANSFORMSKIP_FLAG[3][2*NUM_TRANSFORMSKIP_FLAG_CTX] = 
Index: trunk/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 345)
@@ -1643,48 +1643,10 @@
   pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
   
-#if INTRA_BL
-  iLeftIntraDir  = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) && ( !pcTempCU->isIntraBL( uiTempPartIdx ) ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
-#else
   iLeftIntraDir  = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
-#endif
   
   // Get intra direction of above PU
   pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true );
   
-#if INTRA_BL
-  iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) && ( !pcTempCU->isIntraBL( uiTempPartIdx ) ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
-#else
   iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
-#endif 
-  
-#if SVC_BL_CAND_INTRA
-  if(m_layerId > 0)
-  {
-    UInt uiCUAddrBase, uiAbsPartAddrBase;
-    pcTempCU = getBaseColCU( uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase );
-
-    if(pcTempCU->getPredictionMode( uiAbsPartAddrBase ) == MODE_INTRA )
-    {
-      Int iColBaseDir = pcTempCU->getLumaIntraDir( uiAbsPartAddrBase );
-      if( iColBaseDir != iAboveIntraDir && iColBaseDir != iLeftIntraDir && iAboveIntraDir != iLeftIntraDir)
-      {
-        uiIntraDirPred[0] = iColBaseDir;
-        uiIntraDirPred[1] = iLeftIntraDir;
-        uiIntraDirPred[2] = iAboveIntraDir;
-        if( piMode )
-        {
-          *piMode = 2;
-        }
-        uiPredNum = 3;
-        return uiPredNum;
-      }
-      else 
-      {
-        iAboveIntraDir = (iColBaseDir == iLeftIntraDir) ? iAboveIntraDir : iLeftIntraDir;
-        iLeftIntraDir  = iColBaseDir;
-      }
-    }
-  }
-#endif
   
   uiPredNum = 3;
@@ -1828,9 +1790,5 @@
   UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2;
   PartSize  partSize  = getPartitionSize( absPartIdx );
-#if INTRA_BL
-  UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); 
-#else
   UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); 
-#endif
   Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA && partSize == SIZE_NxN ) ? 1 : 0;
   Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) );
@@ -1854,39 +1812,4 @@
   return log2MinTUSizeInCU;
 }
-
-#if INTRA_BL
-UInt TComDataCU::getCtxIntraBLFlag( UInt uiAbsPartIdx )
-{
-#if INTRA_BL_CTX_CHANGE
-  Int cuDepth = getDepth(uiAbsPartIdx);
-  Int maxCuDepth = g_uiMaxCUDepth - g_uiAddCUDepth;
-  UInt uiCtx = (maxCuDepth==3 && cuDepth > 0) ? (cuDepth - 1) : cuDepth;
-  return uiCtx;
-#else
-  TComDataCU* pcTempCU;
-  UInt        uiTempPartIdx;
-  UInt        uiCtx = 0;
-  
-  // Get BCBP of left PU
-#if DEPENDENT_SLICES
-  Bool bDepSliceRestriction = ( !m_pcSlice->getPPS()->getDependentSliceEnabledFlag());
-  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction );
-#else
-  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
-#endif  
-  uiCtx    = ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0;
-  
-  // Get BCBP of above PU
-#if DEPENDENT_SLICES
-  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction );
-#else
-  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
-#endif  
-  uiCtx   += ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0;
-  
-  return uiCtx;
-#endif
-}
-#endif
 
 #if REF_IDX_ME_ZEROMV
@@ -2586,58 +2509,4 @@
   deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
   deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
-#if SVC_MVP
-  // BL collocated
-  TComDataCU *pcColCU = NULL;
-  UInt uiCUAddrBase = 0, uiAbsPartAddrBase = 0;
-#if AVC_BASE
-  if( !this->getSlice()->getVPS()->getAvcBaseLayerFlag() || AVC_SYNTAX )
-#endif
-  {
-    TComMvField cMvFieldBaseColCU[2];
-    if(m_layerId)  
-    {
-      pcColCU = getBaseColCU( m_layerId - 1, xP + nPSW/2, yP + nPSH/2, uiCUAddrBase, uiAbsPartAddrBase );
-
-#if INTRA_BL
-      if( pcColCU && pcColCU->isIntraBL( uiAbsPartAddrBase ) )
-      {
-        pcColCU = NULL;
-      }
-#endif
-
-      if(pcColCU && !pcColCU->isIntra( uiAbsPartAddrBase ) )
-      {
-        abCandIsInter[iCount] = true;
-
-        // get interDir
-        puhInterDirNeighbours[iCount] = pcColCU->getInterDir( uiAbsPartAddrBase );
-
-        pcMvFieldNeighbours[(iCount << 1)].setMvField( TComMv(0,0), -1);
-        pcMvFieldNeighbours[(iCount << 1) + 1].setMvField( TComMv(0,0), -1);
-
-        if( puhInterDirNeighbours[iCount] & 1 )
-        {
-          pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_0, cMvFieldBaseColCU[0]);
-          scaleBaseMV( m_layerId - 1, pcMvFieldNeighbours[iCount<<1], cMvFieldBaseColCU[0] );
-        }
-
-        if ( getSlice()->isInterB() && puhInterDirNeighbours[iCount] & 2 )
-        {
-          pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_1, cMvFieldBaseColCU[1] );
-          scaleBaseMV( m_layerId - 1, pcMvFieldNeighbours[(iCount<<1)+1], cMvFieldBaseColCU[1] );
-        }
-
-        if( puhInterDirNeighbours[iCount] > 0 )
-        {
-          if ( mrgCandIdx == iCount )
-          {
-            return;
-          }
-          iCount ++;
-        }
-      }
-    }
-  }
-#endif
 
   //left
@@ -2645,15 +2514,7 @@
   TComDataCU* pcCULeft = 0;
   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
-#if INTRA_BL
-  if( pcCULeft && pcCULeft->isIntraBL( uiLeftPartIdx ) )
-  {
-    pcCULeft = NULL;
-  }
-#endif
+
   Bool isAvailableA1 = pcCULeft &&
   pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
-#if SVC_MVP
-  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) &&
-#endif
   !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
   !pcCULeft->isIntra( uiLeftPartIdx ) ;
@@ -2685,14 +2546,6 @@
   TComDataCU* pcCUAbove = 0;
   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
-#if INTRA_BL
-  if( pcCUAbove && pcCUAbove->isIntraBL( uiAbovePartIdx ) )
-  {
-    pcCUAbove = NULL;
-  }
-#endif
+
   Bool isAvailableB1 = pcCUAbove &&
-#if SVC_MVP
-  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) &&
-#endif
   pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
   !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
@@ -2725,14 +2578,6 @@
   TComDataCU* pcCUAboveRight = 0;
   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
-#if INTRA_BL
-  if( pcCUAboveRight && pcCUAboveRight->isIntraBL( uiAboveRightPartIdx ) )
-  {
-    pcCUAboveRight = NULL;
-  }
-#endif
+
   Bool isAvailableB0 = pcCUAboveRight &&
-#if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING
-  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveRight->hasEqualMotion( uiAboveRightPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) &&
-#endif
   pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
   !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
@@ -2761,22 +2606,10 @@
 
   //left bottom
-#if SVC_MVP
-  if( iCount < 4 )
-  {
-#endif
   UInt uiLeftBottomPartIdx = 0;
   TComDataCU* pcCULeftBottom = 0;
   pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
-#if INTRA_BL
-  if( pcCULeftBottom && pcCULeftBottom->isIntraBL( uiLeftBottomPartIdx ) )
-  {
-    pcCULeftBottom = NULL;
-  }
-#endif
+
   Bool isAvailableA0 = pcCULeftBottom &&
   pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
-#if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING
-  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeftBottom->hasEqualMotion( uiLeftBottomPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) &&
-#endif
   !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
   if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
@@ -2802,7 +2635,4 @@
     return;
   }
-#if SVC_MVP
-  }
-#endif
 
   // above left 
@@ -2812,15 +2642,7 @@
     TComDataCU* pcCUAboveLeft = 0;
     pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
-#if INTRA_BL
-    if( pcCUAboveLeft && pcCUAboveLeft->isIntraBL( uiAboveLeftPartIdx ) )
-    {
-      pcCUAboveLeft = NULL;
-    }
-#endif
+
     Bool isAvailableB2 = pcCUAboveLeft &&
     pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
-#if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING
-    ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveLeft->hasEqualMotion( uiAboveLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) &&
-#endif
     !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
     if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
@@ -3123,18 +2945,10 @@
   UInt idx;
   tmpCU = getPUBelowLeft(idx, uiPartIdxLB);
-#if INTRA_BL
-  bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx));
-#else
   bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA);
-#endif
 
   if (!bAddedSmvp)
   {
     tmpCU = getPULeft(idx, uiPartIdxLB);
-#if INTRA_BL
-    bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx));
-#else
     bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA);
-#endif
   }
 
@@ -3562,5 +3376,5 @@
 
   // use coldir.
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
   TComPic *pColPic;
   if (m_layerId > 0 && getSlice()->getAltColIndicationFlag())
@@ -3699,11 +3513,6 @@
   if (scaleFactor > 0)
   {
-#if SVC_MVP
-    m_acCUMvField[0].compress(m_pePredMode, m_puhInterDir, scaleFactor);
-    m_acCUMvField[1].compress(m_pePredMode, m_puhInterDir, scaleFactor);    
-#else
     m_acCUMvField[0].compress(m_pePredMode, scaleFactor);
     m_acCUMvField[1].compress(m_pePredMode, scaleFactor);    
-#endif
   }
 }
@@ -4137,41 +3946,4 @@
 }
 
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED 
-Void TComDataCU::getBaseLumaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride )
-{
-  TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec();
-  UInt uiStrideBase = pcBaseRec->getStride();
-  Pel* piBase = pcBaseRec->getLumaAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx );
-  
-  for ( UInt y = 0; y < uiHeight; y ++ )
-  {
-    memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) );
-  }
-}
-
-Void TComDataCU::getBaseChromaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, UInt uiChromaId )
-{
-  TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec();
-
-  UInt uiStrideBase = pcBaseRec->getCStride();
-  Pel* piBase;
-  
-  if( uiChromaId == 0 )
-  {
-    piBase = pcBaseRec->getCbAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx );
-  }
-  else
-  {
-    piBase = pcBaseRec->getCrAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx );
-  }
-  
-  for ( UInt y = 0; y < uiHeight; y ++ )
-  {
-    memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) );
-  }
-}
-
-#endif
-
 #if SVC_COL_BLK
 TComDataCU*  TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
@@ -4273,4 +4045,9 @@
 #endif
 
+#if N0139_POSITION_ROUNDING_OFFSET
+  iBX += 4;
+  iBY += 4;
+#endif
+
 #if SCALED_REF_LAYER_OFFSETS
   if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight() ||
@@ -4334,28 +4111,3 @@
 }
 #endif
-
-#if SVC_MVP
-Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, UChar uchInterDir, TComMvField* pcMvField  )
-{
-  if ( getInterDir( uiAbsPartIdx ) != uchInterDir )
-  {
-    return false;
-  }
-
-  for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
-  {
-    if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) )
-    {
-      if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx )  != pcMvField[uiRefListIdx].getMv() || 
-        getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcMvField[uiRefListIdx].getRefIdx() )
-      {
-        return false;
-      }
-    }
-  }
-
-  return true;
-}
-#endif
-
 //! \}
Index: trunk/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 345)
@@ -485,22 +485,9 @@
   Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
   
-#if SVC_MVP
-  Bool          hasEqualMotion              ( UInt uiAbsPartIdx, UChar uchInterDir, TComMvField* pcMvField  );
-#endif
-  
   // -------------------------------------------------------------------------------------------------------------------
   // member functions for modes
   // -------------------------------------------------------------------------------------------------------------------
   
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED 
-  Void          getBaseLumaBlk   ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride );
-  Void          getBaseChromaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, UInt uiChromaId );
-#endif
-#if INTRA_BL
-  Bool          isIntraBL ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA_BL; }
-  Bool          isIntra   ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA || m_pePredMode[ uiPartIdx ] == MODE_INTRA_BL; }
-#else
   Bool          isIntra   ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; }
-#endif 
   Bool          isSkipped ( UInt uiPartIdx );                                                     ///< SKIP (no residual)
   Bool          isBipredRestriction( UInt puIdx );
@@ -529,8 +516,5 @@
   UInt&         getTotalBins            ()                            { return m_uiTotalBins;                                                                                                  }
 
-#if INTRA_BL
-  UInt          getCtxIntraBLFlag               ( UInt   uiAbsPartIdx                                 );
-#endif  
-
+#if REF_IDX_FRAMEWORK
 #if FAST_INTRA_SHVC
   Int           reduceSetOfIntraModes              (  UInt   uiAbsPartIdx, Int* uiIntraDirPred, Int &fullSetOfModes );
@@ -540,4 +524,5 @@
   Bool xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
   Bool xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx);
+#endif
 #endif
 
@@ -553,8 +538,10 @@
   UInt          getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra);
 
+#if REF_IDX_FRAMEWORK
 #if SVC_COL_BLK 
   TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
   TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
   Void          scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase );
+#endif
 #endif
 };
Index: trunk/source/Lib/TLibCommon/TComMotionInfo.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 345)
@@ -328,9 +328,5 @@
  * \param scale      Factor by which to subsample motion information
  */
-#if SVC_MVP
-Void TComCUMvField::compress(Char* pePredMode, UChar* peInterDir, Int scale)
-#else
 Void TComCUMvField::compress(Char* pePredMode, Int scale)
-#endif
 {
   Int N = scale * scale;
@@ -351,7 +347,4 @@
       pePredMode[ uiPartIdx + i ] = predMode;
       m_piRefIdx[ uiPartIdx + i ] = iRefIdx;
-#if SVC_MVP
-      peInterDir[ uiPartIdx + i ] = peInterDir[ uiPartIdx ];
-#endif
     }
   }
Index: trunk/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 345)
@@ -158,9 +158,5 @@
   }
   
-#if SVC_MVP
-  Void compress(Char* pePredMode, UChar* peInterDir, Int scale);
-#else
   Void compress(Char* pePredMode, Int scale); 
-#endif
 
 #if REF_IDX_MFM
Index: trunk/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 345)
@@ -408,13 +408,4 @@
 }
 
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
-Void TComPrediction::getBaseBlk( TComDataCU* pcCU, TComYuv* pcYuvPred, Int iPartAddr, Int iWidth, Int iHeight )
-{
-  pcCU->getBaseLumaBlk( iWidth, iHeight, iPartAddr, pcYuvPred->getLumaAddr( iPartAddr ), pcYuvPred->getStride() );
-  pcCU->getBaseChromaBlk( iWidth >> 1, iHeight >> 1, iPartAddr, pcYuvPred->getCbAddr( iPartAddr ), pcYuvPred->getCStride(), 0 );
-  pcCU->getBaseChromaBlk( iWidth >> 1, iHeight >> 1, iPartAddr, pcYuvPred->getCrAddr( iPartAddr ), pcYuvPred->getCStride(), 1 );
-}
-#endif
-
 Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
 {
Index: trunk/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 345)
@@ -101,8 +101,5 @@
   
   Void    initTempBuff();
-  
-#if INTRA_BL
-  Void getBaseBlk ( TComDataCU* pcCU, TComYuv* pcYuvPred, Int iPartAddr, Int iWidth, Int iHeight );
-#endif
+
   // inter
   Void motionCompensation         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1 );
@@ -121,4 +118,5 @@
   Int  getPredicBufHeight()       { return m_iYuvExtHeight; }
 
+#if REF_IDX_FRAMEWORK
 #if SVC_UPSAMPLING
 #if SCALED_REF_LAYER_OFFSETS
@@ -128,4 +126,5 @@
 #endif
 #endif
+#endif
 };
 
Index: trunk/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 345)
@@ -124,5 +124,5 @@
   m_numILRRefIdx = 0;
 #endif 
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
   m_altColIndicationFlag = false;
   m_colRefLayerIdx       = 0;
@@ -385,12 +385,5 @@
 
 #if REF_IDX_FRAMEWORK
-#if ZERO_NUM_DIRECT_LAYERS
   if( m_layerId == 0 || ( m_layerId > 0 && ( m_activeNumILRRefIdx == 0 || !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ) ) )
-#else
-  if ((getLayerId() == 0) || 
-      ((getSPS()->getLayerId()) &&  !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
-       (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) )
-     )
-#endif
   {
 #endif
@@ -458,15 +451,7 @@
 #if ILR_RESTR
     Int maxSubLayerForILPPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()) : 0;
-#if ZERO_NUM_DIRECT_LAYERS
     if( m_layerId > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=  maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )  ) 
-#else
-    if( m_layerId > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )  )
-#endif
 #else //#if ILR_RESTR
-#if ZERO_NUM_DIRECT_LAYERS
     if( m_layerId > 0 && m_activeNumILRRefIdx > 0 )
-#else
-    if( m_layerId > 0 )
-#endif
 #endif //#if ILR_RESTR
     {
@@ -599,13 +584,5 @@
       rpsCurrList0[cIdx] = RefPicSetStCurr0[i];
     }
-    for ( i=0; i<NumPocStCurr1; i++, cIdx++)
-    {
-      rpsCurrList0[cIdx] = RefPicSetStCurr1[i];
-    }
-    for ( i=0; i<NumPocLtCurr;  i++, cIdx++)
-    {
-      rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
-    }    
-
+#if RPL_INIT_N0316_N0082
 #if REF_IDX_FRAMEWORK
     if( m_layerId > 0 )
@@ -619,4 +596,32 @@
         Int refLayerIdc = m_interLayerPredLayerIdc[i];
 #if ILR_RESTR
+        Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
+        if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
+#endif
+          rpsCurrList0[cIdx] = ilpPic[refLayerIdc];
+      }
+    }
+#endif
+#endif 
+    for ( i=0; i<NumPocStCurr1; i++, cIdx++)
+    {
+      rpsCurrList0[cIdx] = RefPicSetStCurr1[i];
+    }
+    for ( i=0; i<NumPocLtCurr;  i++, cIdx++)
+    {
+      rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
+    }    
+#if !RPL_INIT_N0316_N0082
+#if REF_IDX_FRAMEWORK
+    if( m_layerId > 0 )
+    {
+#if JCTVC_M0458_INTERLAYER_RPS_SIG
+      for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)      
+#else
+      for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
+#endif 
+      {
+        Int refLayerIdc = m_interLayerPredLayerIdc[i];
+#if ILR_RESTR
          Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
         if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
@@ -625,4 +630,5 @@
       }
     }
+#endif
 #endif
   assert(cIdx == numPocTotalCurr);
@@ -707,4 +713,7 @@
   TComRefPicListModification* refPicListModification = &m_RefPicListModification;
   Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList();  // total number of ref pics in listTemp0 including inter-layer ref pics
+#if RPL_INIT_N0316_N0082
+  Int numberOfPocBeforeCurr = this->getNumNegativeRpsCurrTempList();  // number of negative temporal ref pics 
+#endif
 
   assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 1);
@@ -712,5 +721,12 @@
 
   //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;
+#else
   Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true;
+#endif
+#if FINAL_RPL_CHANGE_N0082
+  hasModification = false; //modification is not necessary
+#endif
   refPicListModification->setRefPicListModificationFlagL0(hasModification);
   if(hasModification)
@@ -736,5 +752,16 @@
 #endif 
       {
+#if RPL_INIT_N0316_N0082
+        if((numberOfPocBeforeCurr) >= m_aiNumRefIdx[REF_PIC_LIST_0])
+          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr);
+        else
+        {
+          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr);
+          for (Int j = numberOfPocBeforeCurr; j < (m_aiNumRefIdx[REF_PIC_LIST_0] - i); j++)
+            refPicListModification->setRefPicSetIdxL0(j, j + m_activeNumILRRefIdx);
+        }
+#else
         refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i);
+#endif
       }
     }
@@ -773,5 +800,24 @@
 }
 #endif
-
+#if RPL_INIT_N0316_N0082
+Int TComSlice::getNumNegativeRpsCurrTempList()
+{
+  if( m_eSliceType == I_SLICE ) 
+  {
+    return 0;
+  }
+
+  Int numPocBeforeCurr = 0;
+  for( UInt i = 0; i < m_pcRPS->getNumberOfNegativePictures(); i++ )
+  {
+    if(m_pcRPS->getUsed(i))
+    {
+      numPocBeforeCurr++;
+    }
+  }
+
+  return numPocBeforeCurr;
+}
+#endif
 Int TComSlice::getNumRpsCurrTempList()
 {
@@ -1616,4 +1662,7 @@
 #endif
 #if JCTVC_M0203_INTERLAYER_PRED_IDC
+#if N0120_MAX_TID_REF_PRESENT_FLAG
+  m_maxTidIlRefPicsPlus1PresentFlag = true;
+#endif 
   for( Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++)
   {
Index: trunk/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.h	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComSlice.h	(revision 345)
@@ -456,4 +456,7 @@
   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
+  Bool       m_ilpSshSignalingEnabledFlag;
+#endif
 #if VPS_EXTN_PROFILE_INFO
   // Profile-tier-level signalling related
@@ -491,4 +494,7 @@
   UInt       m_maxSublayerForIlpPlus1[MAX_VPS_LAYER_ID_PLUS1 - 1];
 #endif
+#if N0120_MAX_TID_REF_PRESENT_FLAG
+  Bool       m_maxTidIlRefPicsPlus1PresentFlag;
+#endif 
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
   Bool       m_singleLayerForNonIrapFlag;
@@ -588,4 +594,8 @@
   UInt   getLayerIdInVps(Int id)                                { return m_layerIdInVps[id];       }
   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 VPS_EXTN_PROFILE_INFO
@@ -653,4 +663,8 @@
   Void   setMaxSublayerForIlpPlus1(Int layerId, UInt maxSublayer)   { m_maxSublayerForIlpPlus1[layerId] = maxSublayer;            }
 #endif
+#if N0120_MAX_TID_REF_PRESENT_FLAG
+  Bool   getMaxTidIlRefPicsPlus1PresentFlag()                   { return m_maxTidIlRefPicsPlus1PresentFlag ;}
+  Void   setMaxTidIlRefPicsPlus1PresentFlag(Bool x)             { m_maxTidIlRefPicsPlus1PresentFlag = x;}
+#endif 
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
   Bool   getSingleLayerForNonIrapFlag()                             { return m_singleLayerForNonIrapFlag; }
@@ -1560,4 +1574,7 @@
   Bool      getMvdL1ZeroFlag ()                                  { return m_bLMvdL1Zero;    }
   Int       getNumRpsCurrTempList();
+#if RPL_INIT_N0316_N0082
+  Int       getNumNegativeRpsCurrTempList();
+#endif
   Int       getList1IdxToList0Idx ( Int list1Idx )               { return m_list1IdxToList0Idx[list1Idx]; }
   Void      setReferenced(Bool b)                               { m_bRefenced = b; }
@@ -1778,4 +1795,5 @@
   Void      setMFMEnabledFlag(Bool flag)                { m_bMFMEnabledFlag = flag; }
   Bool      getMFMEnabledFlag()                         { return m_bMFMEnabledFlag; }
+#if !REMOVE_COL_PICTURE_SIGNALING
   Void      setColRefLayerIdx(Int i)                    { m_colRefLayerIdx = i;     }
   Int       getColRefLayerIdx()                         { return m_colRefLayerIdx;  }
@@ -1784,4 +1802,5 @@
   Void      setMotionPredIlp(TComPic *ilpPic)           { m_pcIlpPic = ilpPic; }
   TComPic*  getMotionPredIlp()                          { return m_pcIlpPic; }
+#endif
 #endif
 #endif
Index: trunk/source/Lib/TLibCommon/TComTrQuant.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComTrQuant.cpp	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComTrQuant.cpp	(revision 345)
@@ -1235,10 +1235,4 @@
     uiMode = pcCU->getLumaIntraDir( uiAbsPartIdx );
   }
-#if INTRA_BL_DST4x4
-  else if(eTType == TEXT_LUMA && pcCU->isIntraBL(uiAbsPartIdx) )
-  {
-    uiMode = DC_IDX; //Using DST
-  }
-#endif
   else
   {
@@ -1314,16 +1308,5 @@
     Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTxt];
     assert(scalingListType < 6);
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-    if(pcCU->isIntraBL(uiAbsPartIdx) && eTxt == TEXT_LUMA)
-    {
-      invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, DC_IDX, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) );
-    }
-    else
-    {
-      invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, REG_DCT, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) );
-    }
-#else
     invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, REG_DCT, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) );
-#endif
   }
   else
@@ -1809,9 +1792,5 @@
   Int     ui16CtxCbf          = 0;
   Int     iBestLastIdxP1      = 0;
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  if( (!pcCU->isIntra( uiAbsPartIdx ) || pcCU->isIntraBL( uiAbsPartIdx )) && eTType == TEXT_LUMA && pcCU->getTransformIdx( uiAbsPartIdx ) == 0 )
-#else
   if( !pcCU->isIntra( uiAbsPartIdx ) && eTType == TEXT_LUMA && pcCU->getTransformIdx( uiAbsPartIdx ) == 0 )
-#endif
   {
     ui16CtxCbf   = 0;
Index: trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 345)
@@ -9,58 +9,82 @@
 {
   {  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}, //
-  { -1, 4, -11, 52, 26,  -8, 3, -1}, // <-> actual phase shift 1/3, used for spatial scalability x1.5      
+#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}, // 
-  { -1, 4, -11, 40, 40, -11, 4, -1}, // <-> actual phase shift 1/2, equal to HEVC MC, used for spatial scalability x2
+#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
 };
 
 const Int TComUpsampleFilter::m_chromaFixedFilter[16][NTAPS_US_CHROMA] =
 {
-#if CHROMA_UPSAMPLING
   {  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)
-#else
-  {  0, 64,  0,  0},//
-  {CNU,CNU,CNU,CNU},//
-  {CNU,CNU,CNU,CNU},//
-  {CNU,CNU,CNU,CNU},// 
-  { -4, 54, 16, -2},// <-> actual phase shift 1/4,equal to HEVC MC, used for spatial scalability x1.5 (only for accurate Chroma alignement)
-  { -5, 50, 22, -3},// <-> 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)      
-  {CNU,CNU,CNU,CNU},// 
-  { -4, 36, 36, -4},// <-> actual phase shift 1/2,equal to HEVC MC, used for spatial scalability x2
-  { -4, 30, 43, -5},// <-> actual phase shift 7/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
-  {CNU,CNU,CNU,CNU},// 
-  { -3, 22, 50, -5},// <-> actual phase shift 2/3, used for spatial scalability x1.5
-  {CNU,CNU,CNU,CNU},// 
-  {CNU,CNU,CNU,CNU},// 
-  { -2, 10, 58, -2},// <-> actual phase shift 7/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)  
-  { -1,  5, 62, -2} // <-> actual phase shift 11/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
-#endif
 };
 
@@ -183,6 +207,11 @@
     }
 
+#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);
@@ -195,6 +224,11 @@
     Int   phaseY = 0;
 
+#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
 
     Int   deltaX     = 4 * phaseX;
@@ -216,4 +250,11 @@
     Int topStartL  = scalEL.getWindowTopOffset();
     Int bottomEndL = pcUsPic->getHeight() - scalEL.getWindowBottomOffset();
+#if BUGFIX_RESAMPLE
+    Int leftOffset = leftStartL > 0 ? leftStartL : 0;
+#endif
+#endif
+
+#if  N0214_INTERMEDIATE_BUFFER_16BITS
+    Int shift1 = g_bitDepthY - 8;
 #endif
 
@@ -236,5 +277,9 @@
       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;
@@ -248,5 +293,9 @@
     pcTempPic->setHeight(heightEL);
 
+#if  N0214_INTERMEDIATE_BUFFER_16BITS
+    Int nShift = US_FILTER_PREC*2 - shift1;
+#else
     const Int nShift = US_FILTER_PREC*2;
+#endif
     Int iOffset = 1 << (nShift - 1); 
 
@@ -269,4 +318,29 @@
       piSrcY = piTempBufY + (refPos -((NTAPS_US_LUMA>>1) - 1))*strideEL;
 #if SCALED_REF_LAYER_OFFSETS
+#if BUGFIX_RESAMPLE
+      Pel* piDstY0 = piDstBufY + j * strideEL;            
+      piDstY = piDstY0 + leftOffset;
+      piSrcY += leftOffset;
+
+      for( i = min<Int>(rightEndL, pcTempPic->getWidth()) - max<Int>(0, leftStartL); i > 0; i-- )
+      {
+        *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift));
+        piSrcY++;
+        piDstY++;
+      }
+
+      for( i = rightEndL; i < pcTempPic->getWidth(); i++ )
+      {
+        *piDstY = piDstY0[rightEndL-1];
+        piDstY++;
+      }
+
+      piDstY = piDstY0;
+      for( i = 0; i < leftStartL; i++ )
+      {
+        *piDstY = piDstY0[leftStartL];
+        piDstY++;
+      }
+#else
 #if 1 // it should provide identical result
       Pel* piDstY0 = piDstBufY + j * strideEL;            
@@ -308,4 +382,5 @@
       }
 #endif
+#endif
 #else
       piDstY = piDstBufY + j * strideEL;
@@ -351,4 +426,7 @@
     Int topStartC  = scalEL.getWindowTopOffset() >> 1;
     Int bottomEndC = (pcUsPic->getHeight() >> 1) - (scalEL.getWindowBottomOffset() >> 1);
+#if BUGFIX_RESAMPLE
+    leftOffset = leftStartC > 0 ? leftStartC : 0;
+#endif
 #endif
 
@@ -359,6 +437,11 @@
     phaseY = 1;
 
+#if ROUNDING_OFFSET
+    addX       = ( ( phaseX * scaleX + 2 ) >> 2 ) + ( 1 << ( shiftX - 5 ) );
+    addY       = ( ( phaseY * scaleY + 2 ) >> 2 ) + ( 1 << ( shiftY - 5 ) );
+#else
     addX       = ( ( ( widthBL * phaseX ) << ( shiftX - 2 ) ) + ( widthEL >> 1 ) ) / widthEL + ( 1 << ( shiftX - 5 ) );
     addY       = ( ( ( heightBL * phaseY ) << ( shiftY - 2 ) ) + ( heightEL >> 1 ) ) / heightEL+ ( 1 << ( shiftY - 5 ) );
+#endif
 
     deltaX     = 4 * phaseX;
@@ -379,4 +462,8 @@
     widthBL   = pcBasePic->getWidth () >> 1;
     heightBL  = min<Int>( pcBasePic->getHeight() >> 1, heightEL );
+#endif
+
+#if  N0214_INTERMEDIATE_BUFFER_16BITS
+    shift1 = g_bitDepthC - 8;
 #endif
 
@@ -401,6 +488,11 @@
       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;
@@ -416,4 +508,9 @@
     pcTempPic->extendPicBorder   (); // extend the border.
     pcTempPic->setHeight(heightEL << 1);
+
+#if  N0214_INTERMEDIATE_BUFFER_16BITS
+    nShift = US_FILTER_PREC*2 - shift1;
+    iOffset = 1 << (nShift - 1); 
+#endif
 
 #if SCALED_REF_LAYER_OFFSETS
@@ -436,4 +533,40 @@
       piSrcV = piTempBufV  + (refPos -((NTAPS_US_CHROMA>>1) - 1))*strideEL;
 #if SCALED_REF_LAYER_OFFSETS
+#if BUGFIX_RESAMPLE
+      Pel* piDstU0 = piDstBufU + j*strideEL;
+      Pel* piDstV0 = piDstBufV + j*strideEL;
+      piDstU = piDstU0 + leftOffset;
+      piDstV = piDstV0 + leftOffset;
+      piSrcU += leftOffset;
+      piSrcV += leftOffset;
+
+      for( i = min<Int>(rightEndC, pcTempPic->getWidth() >> 1) - max<Int>(0, leftStartC); i > 0; i-- )
+      {
+        *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
+        *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift));
+        piSrcU++;
+        piSrcV++;
+        piDstU++;
+        piDstV++;
+      }
+
+      for( i = rightEndC; i < pcTempPic->getWidth() >> 1; i++ )
+      {
+        *piDstU = piDstU0[rightEndC-1];
+        *piDstV = piDstV0[rightEndC-1];
+        piDstU++;
+        piDstV++;
+      }
+
+      piDstU = piDstU0;
+      piDstV = piDstV0;
+      for( i = 0; i < leftStartC; i++ )
+      {
+        *piDstU = piDstU0[leftStartC];
+        *piDstV = piDstV0[leftStartC];
+        piDstU++;
+        piDstV++;
+      }
+#else
 #if 1 // it should provide identical result
       Pel* piDstU0 = piDstBufU + j*strideEL;
@@ -490,4 +623,5 @@
       }
 #endif
+#endif
 #else
       piDstU = piDstBufU + j*strideEL;
Index: trunk/source/Lib/TLibCommon/TComYuv.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComYuv.cpp	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComYuv.cpp	(revision 345)
@@ -184,57 +184,4 @@
 }
 
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-Void TComYuv::copyFromPicLuma  ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiWidth, UInt uiHeight )
-{
-  Int  y;
-
-  Pel* pDst     = getLumaAddr(uiAbsZorderIdx);
-  Pel* pSrc     = pcPicYuvSrc->getLumaAddr ( iCuAddr, uiZorderIdxInCU + uiAbsZorderIdx );
-
-  UInt  iDstStride  = getStride();
-  UInt  iSrcStride  = pcPicYuvSrc->getStride();
-  for ( y = uiHeight; y != 0; y-- )
-  {
-    ::memcpy( pDst, pSrc, sizeof(Pel)*uiWidth);
-    pDst += iDstStride;
-    pSrc += iSrcStride;
-  }
-}
-
-Void TComYuv::copyFromPicChroma( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId  )
-{
-  Int  y;
-
-  if (!uiChromaId)
-  {
-    Pel* pDstU      = getCbAddr(uiAbsZorderIdx); 
-    Pel* pSrcU      = pcPicYuvSrc->getCbAddr( iCuAddr, uiZorderIdxInCU + uiAbsZorderIdx );
-
-    UInt  iDstStride = getCStride();
-    UInt  iSrcStride = pcPicYuvSrc->getCStride();
-    for ( y = uiCHeight; y != 0; y-- )
-    {
-      ::memcpy( pDstU, pSrcU, sizeof(Pel)*(uiCWidth) );
-      pSrcU += iSrcStride;
-      pDstU += iDstStride;
-    }
-  }
-  else
-  {
-    Pel* pDstV      = getCrAddr(uiAbsZorderIdx);
-    Pel* pSrcV      = pcPicYuvSrc->getCrAddr( iCuAddr, uiZorderIdxInCU + uiAbsZorderIdx );
-
-    UInt  iDstStride = getCStride();
-    UInt  iSrcStride = pcPicYuvSrc->getCStride();
-    for ( y = uiCHeight; y != 0; y-- )
-    {
-      ::memcpy( pDstV, pSrcV, sizeof(Pel)*(uiCWidth) );
-      pSrcV += iSrcStride;
-      pDstV += iDstStride;
-    }
-  }
-}
-#endif
-
 Void TComYuv::copyToPartYuv( TComYuv* pcYuvDst, UInt uiDstPartIdx )
 {
Index: trunk/source/Lib/TLibCommon/TComYuv.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComYuv.h	(revision 313)
+++ trunk/source/Lib/TLibCommon/TComYuv.h	(revision 345)
@@ -115,8 +115,4 @@
   Void    copyFromPicLuma      ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
   Void    copyFromPicChroma    ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  Void    copyFromPicLuma  ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiWidth, UInt uiHeight );
-  Void    copyFromPicChroma( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId  );
-#endif
   
   //  Copy Small YUV buffer to the part of other Big YUV buffer
Index: trunk/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/TypeDef.h	(revision 313)
+++ trunk/source/Lib/TLibCommon/TypeDef.h	(revision 345)
@@ -41,9 +41,12 @@
 #define SVC_EXTENSION                    1
 
+#define N0139_POSITION_ROUNDING_OFFSET   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)]
 
 #if SVC_EXTENSION
 #define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
-
+#define RPL_INIT_N0316_N0082             1      ///< N0316, N0082: initial reference picture list construction 
+#define FINAL_RPL_CHANGE_N0082           1      ///< N0082: final ref picture list change (encoder)
 #define M0464_TILE_BOUNDARY_ALIGNED_FLAG 1      ///< VUI flag to indicate tile boundary alignment
 #define M0463_VUI_EXT_ILP_REF            1      ///< VUI extension inter-layer dependency offset signalling
@@ -51,4 +54,8 @@
 #define SCALED_REF_LAYER_OFFSET_FLAG     0      ///< M0309: Signal scaled reference layer offsets in SPS
 #define SCALED_REF_LAYER_OFFSETS         1      ///< M0309: Signal scaled reference layer offsets in SPS
+
+#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
+#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
@@ -74,5 +81,8 @@
 #define SVC_COL_BLK                      1      ///< get co-located block
 #define SVC_UPSAMPLING                   1      ///< upsampling filters
-#define CHROMA_UPSAMPLING                1      ///< L0335: Chroma upsampling with 5 bits coefficients
+#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          0      ///< JCTVC-N0219, JCTVC-N0273: Support arbitrary spatial ratio
+#define BUGFIX_RESAMPLE                  1      ///< JCTVC-N0055: resampling bug fix for positive left scalled offset
 
 #define SIMPLIFIED_MV_POS_SCALING        1      ///< M0133/M0449: inter-layer MV scaling and pixel mapping position calculation
@@ -97,36 +107,20 @@
 #define JCTVC_M0458_INTERLAYER_RPS_SIG   1      ///< implementation of JCTVC-L0178
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
-#define ZERO_NUM_DIRECT_LAYERS           1      ///< support of zero direct reference layers
 #define MAX_ONE_RESAMPLING_DIRECT_LAYERS 1      ///< Allow maximum of one resampling process for direct reference layers
 #endif
 #define JCTVC_M0203_INTERLAYER_PRED_IDC  1      ///< implementation of JCTVC-M0203 Inter-layer Prediction Indication
 #if JCTVC_M0203_INTERLAYER_PRED_IDC
-#define ILR_RESTR                        1     ///< JCTVC-M0209 Inter-layer RPS and RPL
+#define ILR_RESTR                        1      ///< JCTVC-M0209 Inter-layer RPS and RPL
+#define N0120_MAX_TID_REF_PRESENT_FLAG   1      ///< JCTVC-N0120 max_tid_ref_pics_plus1_present_flag
 #endif
 #if REF_IDX_MFM
+#define REMOVE_COL_PICTURE_SIGNALING     1      ///< JCTVC-N0107 remove alternative collocated picture signalling
 #define M0457_COL_PICTURE_SIGNALING      1
 #endif
 
 #if !VPS_EXTN_DIRECT_REF_LAYERS || !M0457_PREDICTION_INDICATIONS || !JCTVC_M0458_INTERLAYER_RPS_SIG
-#define M0457_IL_SAMPLE_PRED_ONLY_FLAG   0
+#define M0457_IL_SAMPLE_PRED_ONLY_FLAG   0      ///< shall be 0, JCTVC-N0107
 #else
-#define M0457_IL_SAMPLE_PRED_ONLY_FLAG   0
-#endif
-
-#else
-#define INTRA_BL                         1      ///< inter-layer texture prediction
-
-#if INTRA_BL
-#define INTRA_BL_DST4x4                  1      ///< L0067/L0204: DST4x4 for Intra BL
-#define NO_RESIDUAL_FLAG_FOR_BLPRED      1      ///< L0437: Root cbf for Intra_BL
-#define IL_MRG_SIMPLIFIED_PRUNING        1      ///< M0124: simplified pruning, Only the left and above candidates are checked with BL-C candidate for redundancy removal 
-#define INTRA_BL_CTX_CHANGE              1      ///< M0075: spatial dependency removal for IntraBL flag context derivation
-
-// Hooks
-#define SVC_MVP                          1      ///< motion hook for merge mode as an example
-#if !AVC_BASE && !AVC_SYNTAX
-#define SVC_BL_CAND_INTRA                0      ///< Intra Base Mode Prediction hook as an example 
-#endif
-
+#define M0457_IL_SAMPLE_PRED_ONLY_FLAG   0      ///< shall be 0, JCTVC-N0107
 #endif
 #endif
@@ -134,8 +128,8 @@
 #define FAST_INTRA_SHVC                  1      ///< M0115: reduction number of intra modes in the EL (encoder only)
 #if FAST_INTRA_SHVC
-  #define NB_REMAIN_MODES                2      ///< nb of remaining modes (M0115)
-#endif
-
-#define RC_SHVC_HARMONIZATION            1  ///< JCTVC-M0037, rate control for SHVC
+#define NB_REMAIN_MODES                  2      ///< nb of remaining modes (M0115)
+#endif
+
+#define RC_SHVC_HARMONIZATION            1      ///< JCTVC-M0037, rate control for SHVC
 
 #else
@@ -472,7 +466,4 @@
   MODE_INTER,           ///< inter-prediction mode
   MODE_INTRA,           ///< intra-prediction mode
-#if INTRA_BL
-  MODE_INTRA_BL,        ///< inter-layer intra-prediction mode
-#endif
   MODE_NONE = 15
 };
