Index: trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 345)
@@ -708,4 +708,16 @@
   }
 
+#if SPL_FLG_CHK
+  if(vps->getSplittingFlag())
+  {
+    UInt splDimSum=0;
+    for(j = 0; j < vps->getNumScalabilityTypes(); j++)
+    {
+      splDimSum+=(vps->getDimensionIdLen(j));
+    }
+    assert(splDimSum<=6);
+  }
+#endif
+
   WRITE_FLAG( vps->getNuhLayerIdPresentFlag(),         "vps_nuh_layer_id_present_flag" );
   for(i = 1; i < vps->getMaxLayers(); i++)
@@ -737,8 +749,22 @@
 #endif
 #if JCTVC_M0203_INTERLAYER_PRED_IDC
+#if N0120_MAX_TID_REF_PRESENT_FLAG
+   WRITE_FLAG( vps->getMaxTidIlRefPicsPlus1PresentFlag(), "max_tid_il_ref_pics_plus1_present_flag");
+   if (vps->getMaxTidIlRefPicsPlus1PresentFlag())
+   {
+     for( i = 0; i < vps->getMaxLayers() - 1; i++)
+     {
+       WRITE_CODE(vps->getMaxSublayerForIlpPlus1(i), 3, "max_sublayer_for_ilp_plus1[i]" );
+     }
+   }
+#else
   for( i = 0; i < vps->getMaxLayers() - 1; i++)
   {
     WRITE_CODE(vps->getMaxSublayerForIlpPlus1(i), 3, "max_sublayer_for_ilp_plus1[i]" );
   }
+#endif
+#endif
+#if ILP_SSH_SIG
+    WRITE_FLAG( vps->getIlpSshSignalingEnabledFlag(), "all_ref_layers_active_flag" );
 #endif
 #if VPS_EXTN_PROFILE_INFO
@@ -1052,6 +1078,10 @@
     }
 
-#if JCTVC_M0458_INTERLAYER_RPS_SIG    
-    if((pcSlice->getSPS()->getLayerId() > 0)  &&  (pcSlice->getNumILRRefIdx() > 0) ) 
+#if JCTVC_M0458_INTERLAYER_RPS_SIG
+#if ILP_SSH_SIG
+    if((pcSlice->getSPS()->getLayerId() > 0) && pcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (pcSlice->getNumILRRefIdx() > 0) )
+#else
+    if((pcSlice->getSPS()->getLayerId() > 0)  &&  (pcSlice->getNumILRRefIdx() > 0) )
+#endif
     {
       WRITE_FLAG(pcSlice->getInterLayerPredEnabledFlag(),"inter_layer_pred_enabled_flag");
@@ -1069,8 +1099,15 @@
             WRITE_CODE(pcSlice->getActiveNumILRRefIdx() - 1, numBits,"num_inter_layer_ref_pics_minus1");
           }       
+#if ILP_NUM_REF_CHK
+          if( pcSlice->getNumILRRefIdx() != pcSlice->getActiveNumILRRefIdx() )
+          {
+#endif
           for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
           {
             WRITE_CODE(pcSlice->getInterLayerPredLayerIdc(i),numBits,"inter_layer_pred_layer_idc[i]");   
           }
+#if ILP_NUM_REF_CHK
+          }
+#endif
         }
       }
@@ -1187,5 +1224,5 @@
     if ( pcSlice->getEnableTMVPFlag() )
     {
-#if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING
+#if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
       if ( !pcSlice->getIdrPicFlag() && pcSlice->getLayerId() > 0 && pcSlice->getActiveNumILRRefIdx() > 0 && pcSlice->getNumMotionPredRefLayers() > 0 )
       {
@@ -1210,5 +1247,5 @@
         WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" );
       }
-#if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING
+#if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
       }
 #endif
@@ -1726,11 +1763,3 @@
   return true;
 }
-
-#if INTRA_BL
-Void TEncCavlc::codeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
-{
-  assert(0);
-}
-
-#endif
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 345)
@@ -112,7 +112,4 @@
   Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if INTRA_BL
-  Void codeIntraBLFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#endif
  
   Void codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode );
Index: trunk/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 345)
@@ -763,11 +763,4 @@
           }
         }
-#if INTRA_BL
-      if(m_pcPicYuvRecBase)
-      {
-        xCheckRDCostIntraBL( rpcBestCU, rpcTempCU );
-        rpcTempCU->initEstData( uiDepth, iQP );
-      }
-#endif
 #if (ENCODER_FAST_MODE)
       if(pcPic->getLayerId() > 0)
@@ -1215,9 +1208,4 @@
     return;
   }
-#if INTRA_BL
-  m_pcEntropyCoder->encodeIntraBLFlag( pcCU, uiAbsPartIdx );
-  if ( !pcCU->isIntraBL( uiAbsPartIdx ) )
-  {
-#endif
   m_pcEntropyCoder->encodePredMode( pcCU, uiAbsPartIdx );
   
@@ -1238,7 +1226,4 @@
   // prediction Info ( Intra : direction mode, Inter : Mv, reference idx )
   m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx );
-#if INTRA_BL
-  }
-#endif
   
   // Encode Coefficients
@@ -1568,7 +1553,5 @@
   
   m_pcEntropyCoder->resetBits();
-#if INTRA_BL
-  m_pcEntropyCoder->encodeIntraBLFlag ( rpcTempCU, 0,       true );
-#endif
+
   if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
   {
@@ -1624,7 +1607,5 @@
 
   m_pcEntropyCoder->resetBits();
-#if INTRA_BL
-  m_pcEntropyCoder->encodeIntraBLFlag ( rpcTempCU, 0,       true );
-#endif
+
   if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
   {
@@ -1879,54 +1860,4 @@
 #endif
 
-#if INTRA_BL
-Void TEncCu::xCheckRDCostIntraBL( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU )
-{
-  UInt uiDepth = rpcTempCU->getDepth( 0 );
-  rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth ); 
-  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
-  rpcTempCU->setPredModeSubParts( MODE_INTRA_BL, 0, uiDepth );  
-  rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uiDepth );
-
-  m_pcPredSearch->setBaseRecPic( m_pcPicYuvRecBase ); 
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  rpcTempCU->setDepthSubParts( uiDepth, 0 );
-  //   rpcTempCU->setLumaIntraDirSubParts( DC_IDX, 0, uiDepth );
-  //   rpcTempCU->setChromIntraDirSubParts( DC_IDX, 0, uiDepth );
-  m_ppcPredYuvTemp[uiDepth]->copyFromPicLuma  ( rpcTempCU->getSlice()->getFullPelBaseRec(rpcTempCU->getLayerId() - 1),  rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, rpcTempCU->getWidth(0), rpcTempCU->getHeight(0));
-  m_ppcPredYuvTemp[uiDepth]->copyFromPicChroma( rpcTempCU->getSlice()->getFullPelBaseRec(rpcTempCU->getLayerId() - 1),  rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, (rpcTempCU->getWidth(0)>>1), (rpcTempCU->getHeight(0)>>1), 0);
-  m_ppcPredYuvTemp[uiDepth]->copyFromPicChroma( rpcTempCU->getSlice()->getFullPelBaseRec(rpcTempCU->getLayerId() - 1),  rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, (rpcTempCU->getWidth(0)>>1), (rpcTempCU->getHeight(0)>>1), 1);
-  m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcResiYuvBest[uiDepth], m_ppcRecoYuvTemp[uiDepth], false );
-  rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
-#else
-
-  m_pcPredSearch->estIntraBLPredQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth] );
-
-  m_pcEntropyCoder->resetBits();
-  m_pcEntropyCoder->encodeIntraBLFlag ( rpcTempCU, 0,       true );
-  m_pcEntropyCoder->encodeSkipFlag( rpcTempCU, 0,       true );
-  if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
-  {
-    m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0,          true );
-  }
-
-  // Encode Coefficients
-  Bool bCodeDQP = getdQPFlag();
-  m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP );
-  setdQPFlag( bCodeDQP );
-  
-  if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
-  
-  rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
-  if(m_pcEncCfg->getUseSBACRD())
-  {
-    rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
-  }
-  rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
-#endif
-  
-  xCheckDQP( rpcTempCU );
-  xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth);
-}
-#endif
 #if (ENCODER_FAST_MODE)
 Void TEncCu::xCheckRDCostILRUni(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, UInt refLayerId)
Index: trunk/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncCu.h	(revision 345)
@@ -84,7 +84,4 @@
   //  Access channel
   TEncCfg*                m_pcEncCfg;
-#if INTRA_BL
-  TComPicYuv*             m_pcPicYuvRecBase;       ///< reconstructed base layer
-#endif 
   TEncSearch*             m_pcPredSearch;
   TComTrQuant*            m_pcTrQuant;
@@ -134,7 +131,5 @@
   Int   updateLCUDataISlice ( TComDataCU* pcCU, Int LCUIdx, Int width, Int height );
 #endif
-#if INTRA_BL 
-  Void  setBaseRecPic       ( TComPicYuv* p ) { m_pcPicYuvRecBase = p; }   
-#endif
+
 protected:
   Void  finishCU            ( TComDataCU*  pcCU, UInt uiAbsPartIdx,           UInt uiDepth        );
@@ -157,7 +152,4 @@
 #endif
   Void  xCheckRDCostIntra   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
-#if INTRA_BL
-  Void  xCheckRDCostIntraBL ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU  );
-#endif
 #if ENCODER_FAST_MODE
   Void  xCheckRDCostILRUni  ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId);
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 345)
@@ -166,11 +166,4 @@
   }
 
-#if INTRA_BL
-  if( pcCU->isIntraBL( uiAbsPartIdx ) )
-  {
-    return;
-  }
-#endif
-
   m_pcEntropyCoderIf->codePredMode( pcCU, uiAbsPartIdx );
 }
@@ -251,10 +244,6 @@
     }
   }
-#if INTRA_BL
-    if( pcCU->isIntra(uiAbsPartIdx) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
-#else
   
   if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
-#endif
   {
     assert( uiSubdiv );
@@ -342,13 +331,5 @@
     }
     
-#if INTRA_BL
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-    if( ( !pcCU->isIntra( uiAbsPartIdx ) || pcCU->isIntraBL(uiAbsPartIdx)) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
-#else
-    if( ( !pcCU->isIntra( uiAbsPartIdx ) ) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
-#endif
-#else
     if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
-#endif
     {
       assert( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, 0 ) );
@@ -431,7 +412,4 @@
 Void TEncEntropy::encodePredInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
 {
-#if INTRA_BL
-  assert ( !pcCU->isIntraBL( uiAbsPartIdx ) );
-#endif
   if( bRD )
   {
@@ -607,9 +585,5 @@
   UInt uiChromaOffset = uiLumaOffset>>2;
     
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  if( pcCU->isIntra(uiAbsPartIdx) && !pcCU->isIntraBL(uiAbsPartIdx) )
-#else
   if( pcCU->isIntra(uiAbsPartIdx) )
-#endif
   {
     DTRACE_CABAC_VL( g_nSymbolCounter++ )
@@ -759,18 +733,3 @@
 }
 
-#if INTRA_BL
-Void TEncEntropy::encodeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
-{
-  if( pcCU->getLayerId() == 0 )
-  {
-    return;
-  }
-
-  if( bRD )
-  {
-    uiAbsPartIdx = 0;
-  }
-  m_pcEntropyCoderIf->codeIntraBLFlag( pcCU, uiAbsPartIdx );
-}
-#endif
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.h	(revision 345)
@@ -85,8 +85,5 @@
   virtual Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
   virtual Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
-  
-#if INTRA_BL
-  virtual Void codeIntraBLFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
-#endif
+
   virtual Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
   virtual Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
@@ -164,7 +161,4 @@
   Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
-#if INTRA_BL
-  Void encodeIntraBLFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
-#endif
   Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
   Void encodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
Index: trunk/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 345)
@@ -511,5 +511,7 @@
 #if M0457_COL_PICTURE_SIGNALING
       pcSlice->setMFMEnabledFlag(false);
+#if !REMOVE_COL_PICTURE_SIGNALING
       pcSlice->setAltColIndicationFlag(false);
+#endif
 #endif
     }
@@ -645,12 +647,10 @@
       pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA);
     }
-#if ZERO_NUM_DIRECT_LAYERS
+
     if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     {
       pcSlice->setSliceType(I_SLICE);
     }
-    else
-#endif
-    if( m_layerId > 0 && !m_pcEncTop->getElRapSliceTypeB() )
+    else if( m_layerId > 0 && !m_pcEncTop->getElRapSliceTypeB() )
     {
       if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
@@ -760,9 +760,5 @@
 
 #if REF_IDX_FRAMEWORK
-#if ZERO_NUM_DIRECT_LAYERS
     if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
-#else
-    if(m_layerId > 0)
-#endif
     {
 #if RESTR_CHK
@@ -820,9 +816,5 @@
     //  Set reference list
 #if REF_IDX_FRAMEWORK
-#if ZERO_NUM_DIRECT_LAYERS
     if(m_layerId ==  0 || ( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 ) )
-#else
-    if(m_layerId ==  0)
-#endif
     {
       pcSlice->setRefPicList( rcListPic);
@@ -832,9 +824,5 @@
 #endif
 #if REF_IDX_FRAMEWORK
-#if ZERO_NUM_DIRECT_LAYERS
     if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
-#else
-    if(m_layerId > 0)
-#endif
     {
       m_pcEncTop->setILRPic(pcPic);
@@ -848,5 +836,5 @@
       {
         pcSlice->setRefPOCListILP(m_pcEncTop->getIlpList(), pcSlice->getBaseColPic());
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
         pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice));
 #endif
@@ -858,5 +846,9 @@
 #if REF_IDX_MFM
 #if M0457_COL_PICTURE_SIGNALING
+#if REMOVE_COL_PICTURE_SIGNALING
+      if( pcSlice->getMFMEnabledFlag() && pcSlice->getActiveNumILRRefIdx() > 0 && m_pcEncTop->getNumMotionPredRefLayers() > 0 )
+#else
       if( pcSlice->getMFMEnabledFlag() && !(pcSlice->getActiveNumILRRefIdx() > 0 && m_pcEncTop->getNumMotionPredRefLayers() > 0) )
+#endif
 #else
       if( pcSlice->getSPS()->getMFMEnabledFlag() )
@@ -3005,5 +2997,5 @@
 }
 
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
 TComPic* TEncGOP::getMotionPredIlp(TComSlice* pcSlice)
 {
Index: trunk/source/Lib/TLibEncoder/TEncGOP.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.h	(revision 345)
@@ -198,5 +198,5 @@
   }
   Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
   TComPic* getMotionPredIlp(TComSlice* pcSlice);
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 345)
@@ -83,7 +83,4 @@
 , m_cTransformSkipSCModel     ( 1,             2,               NUM_TRANSFORMSKIP_FLAG_CTX    , m_contextModels + m_numContextModels, m_numContextModels)
 , m_CUTransquantBypassFlagSCModel( 1,          1,               NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)
-#if INTRA_BL
-, m_cIntraBLPredFlagSCModel   (1,              1,               NUM_INTRA_BL_PRED_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
 {
   assert( m_numContextModels <= MAX_NUM_CTX_MOD );
@@ -134,7 +131,4 @@
   m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
   m_cSaoMergeSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG );
-#if INTRA_BL
-  m_cIntraBLPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
-#endif
   m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
   m_cTransformSkipSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
@@ -169,7 +163,4 @@
       curCost  = m_cCUSplitFlagSCModel.calcCost       ( curSliceType, qp, (UChar*)INIT_SPLIT_FLAG );
       curCost += m_cCUSkipFlagSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_SKIP_FLAG );
-#if INTRA_BL
-      curCost += m_cIntraBLPredFlagSCModel.calcCost   ( curSliceType, qp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
-#endif
       curCost += m_cCUMergeFlagExtSCModel.calcCost    ( curSliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT);
       curCost += m_cCUMergeIdxExtSCModel.calcCost     ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT);
@@ -243,7 +234,4 @@
   m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
   m_cSaoMergeSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG );
-#if INTRA_BL
-  m_cIntraBLPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
-#endif
   m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
   m_cTransformSkipSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
@@ -428,7 +416,5 @@
 {
   PartSize eSize         = pcCU->getPartitionSize( uiAbsPartIdx );
-#if INTRA_BL
-  assert( !pcCU->isIntraBL( uiAbsPartIdx ) );
-#endif
+
   if ( pcCU->isIntra( uiAbsPartIdx ) )
   {
@@ -1600,23 +1586,3 @@
 }
 
-#if INTRA_BL
-/** code intra_bl flag
- * \param pcCU
- * \param uiAbsPartIdx 
- * \returns Void
- */
-Void TEncSbac::codeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
-{
-  // get context function is here
-  UInt uiSymbol = pcCU->isIntraBL( uiAbsPartIdx ) ? 1 : 0;
-
-  UInt uiCtxIntraBL = pcCU->getCtxIntraBLFlag( uiAbsPartIdx ) ;
-  m_pcBinIf->encodeBin(uiSymbol, m_cIntraBLPredFlagSCModel.get( 0, 0, uiCtxIntraBL )); 
-
-  DTRACE_CABAC_VL( g_nSymbolCounter++ );
-  DTRACE_CABAC_T( "\tuiSymbol: ");
-  DTRACE_CABAC_V( uiSymbol );
-  DTRACE_CABAC_T( "\n");
-}
-#endif
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 345)
@@ -132,8 +132,5 @@
   Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void codeMVPIdx        ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
-  
-#if INTRA_BL
-  Void codeIntraBLFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#endif
+
   Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
@@ -206,7 +203,4 @@
   ContextModel3DBuffer m_cTransformSkipSCModel;
   ContextModel3DBuffer m_CUTransquantBypassFlagSCModel;
-#if INTRA_BL
-  ContextModel3DBuffer m_cIntraBLPredFlagSCModel;
-#endif
 };
 
Index: trunk/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 345)
@@ -906,11 +906,5 @@
         m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
       }
-#if INTRA_BL
-      m_pcEntropyCoder->encodeIntraBLFlag ( pcCU, 0, true );
-      if( pcCU->isIntraBL( 0 ) )
-      {
-        return;
-      }
-#endif      
+    
       m_pcEntropyCoder  ->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
 
@@ -950,10 +944,5 @@
     }
   }
-#if INTRA_BL
-  if( pcCU->isIntraBL( 0 ) )
-  {
-    return;
-  }
-#endif
+
   if( bChroma )
   {
@@ -1055,11 +1044,4 @@
     pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
     //===== get prediction signal =====
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
-    if(pcCU->isIntraBL ( uiAbsPartIdx ) )
-    {
-      pcCU->getBaseLumaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride );
-    }
-    else
-#endif
     predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
     // save prediction 
@@ -1247,14 +1229,6 @@
 
     //===== get prediction signal =====
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
-  if(pcCU->isIntraBL ( uiAbsPartIdx ) )
-  {
-    pcCU->getBaseChromaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride, uiChromaId );
-  }
-  else
-#endif
-    {
-      predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
-    }
+    predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
+
     // save prediction 
     if( default0Save1Load2 == 1 )
@@ -4567,9 +4541,5 @@
 Void TEncSearch::encodeResAndCalcRdInterCU( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* pcYuvPred, TComYuv*& rpcYuvResi, TComYuv*& rpcYuvResiBest, TComYuv*& rpcYuvRec, Bool bSkipRes )
 {
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  if ( pcCU->isIntra(0) && !pcCU->isIntraBL(0))
-#else
   if ( pcCU->isIntra(0) )
-#endif
   {
     return;
@@ -4682,18 +4652,4 @@
       pcCU->setTransformSkipSubParts ( 0, 0, 0, 0, pcCU->getDepth(0) );
     }
-#if NO_RESIDUAL_FLAG_FOR_BLPRED 
-    else if(pcCU->getLayerId() > 0 && pcCU->isIntraBL(0) && uiZeroDistortion == uiDistortion) // all zeros
-    {
-      const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (pcCU->getDepth(0) << 1);
-      ::memset( pcCU->getTransformIdx()      , 0, uiQPartNum * sizeof(UChar) );
-      ::memset( pcCU->getCbf( TEXT_LUMA )    , 0, uiQPartNum * sizeof(UChar) );
-      ::memset( pcCU->getCbf( TEXT_CHROMA_U ), 0, uiQPartNum * sizeof(UChar) );
-      ::memset( pcCU->getCbf( TEXT_CHROMA_V ), 0, uiQPartNum * sizeof(UChar) );
-      ::memset( pcCU->getCoeffY()            , 0, uiWidth * uiHeight * sizeof( TCoeff )      );
-      ::memset( pcCU->getCoeffCb()           , 0, uiWidth * uiHeight * sizeof( TCoeff ) >> 2 );
-      ::memset( pcCU->getCoeffCr()           , 0, uiWidth * uiHeight * sizeof( TCoeff ) >> 2 );
-      pcCU->setTransformSkipSubParts ( 0, 0, 0, 0, pcCU->getDepth(0) );
-    }
-#endif
     else
     {
@@ -4994,17 +4950,5 @@
       Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA];
       assert(scalingListType < 6);     
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-      if(pcCU->isIntraBL(uiAbsPartIdx) )
-      {
-        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,DC_IDX, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
-      }
-      else
-      {
-        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
-      }
-#else
       m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
-#endif
-      
       const UInt uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),
       pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth,trHeight );
@@ -5275,16 +5219,5 @@
         assert(scalingListType < 6);     
 
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-        if(pcCU->isIntraBL(uiAbsPartIdx) )
-        {
-          m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,DC_IDX, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType, true );
-        }
-        else
-        {
-          m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType, true );
-        }
-#else
         m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType, true );
-#endif
 
         uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),
@@ -5617,13 +5550,5 @@
 
   {
-#if INTRA_BL
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-    assert( !pcCU->isIntra(uiAbsPartIdx) || pcCU->isIntraBL(uiAbsPartIdx));
-#else
-    assert( !pcCU->isIntra(uiAbsPartIdx) );
-#endif
-#else
     assert( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA );
-#endif
     if( bSubdivAndCbf )
     {
@@ -5859,23 +5784,8 @@
     }
     m_pcEntropyCoder->encodeSkipFlag ( pcCU, 0, true );
-#if INTRA_BL
-    if(m_pcEncCfg->getLayerId())
-    {
-      m_pcEntropyCoder->encodeIntraBLFlag(pcCU, 0, true);
-#if !NO_RESIDUAL_FLAG_FOR_BLPRED
-      assert( pcCU->isIntraBL( 0 ) == false );
-#endif
-    }
-#endif
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-    if( !pcCU->isIntraBL(0))
-    {
-#endif
     m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
     m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
     m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-    }
-#endif
+
     Bool bDummy = false;
     m_pcEntropyCoder->encodeCoeff   ( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0), bDummy );
@@ -6295,58 +6205,3 @@
 #endif
 
-#if INTRA_BL
-Void 
-TEncSearch::estIntraBLPredQT( TComDataCU* pcCU, 
-                           TComYuv*    pcOrgYuv, 
-                           TComYuv*    pcPredYuv, 
-                           TComYuv*    pcResiYuv,
-                           TComYuv*    pcRecoYuv )
-{
-  UInt    uiDepth        = pcCU->getDepth(0);
-  UInt    uiOverallDistY = 0;
-  UInt    uiOverallDistC = 0;
-  
-  //===== set QP and clear Cbf =====
-  if ( pcCU->getSlice()->getPPS()->getUseDQP() == true)
-  {
-    pcCU->setQPSubParts( pcCU->getQP(0), 0, uiDepth );
-  }
-  else
-  {
-    pcCU->setQPSubParts( pcCU->getSlice()->getSliceQp(), 0, uiDepth );
-  }
-  
-  //===== init pattern for luma prediction =====
-  Bool bAboveAvail = false;
-  Bool bLeftAvail  = false;
-  pcCU->getPattern()->initPattern   ( pcCU, 0, 0 );
-  pcCU->getPattern()->initAdiPattern( pcCU, 0, 0, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
-  
-  pcCU->setLumaIntraDirSubParts ( DC_IDX, 0, uiDepth );
-  
-  // set context models
-  if( m_bUseSBACRD )
-  {
-    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
-  }
-  
-  // determine residual for partition
-  Double dPUCost   = 0.0;
-  xRecurIntraCodingQT( pcCU, 0, 0, false, pcOrgYuv, pcPredYuv, pcResiYuv, uiOverallDistY, uiOverallDistC, false, dPUCost );
-  xSetIntraResultQT( pcCU, 0, 0, false, pcRecoYuv );
-  
-  //=== update PU data ====
-  pcCU->copyToPic( uiDepth, 0, 0 );
-   
-  //===== reset context models =====
-  if(m_bUseSBACRD)
-  {
-    m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
-  }
-
-  //===== set distortion (rate and r-d costs are determined later) =====
-  pcCU->getTotalDistortion() = uiOverallDistY + uiOverallDistC;
-}
-
-#endif
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 345)
@@ -99,7 +99,4 @@
 #if SVC_EXTENSION
   TEncTop**       m_ppcTEncTop;
-#if INTRA_BL
-  TComPicYuv*     m_pcPicYuvRecBase;       ///< reconstructed base layer
-#endif
 #endif
   
@@ -192,14 +189,4 @@
                                   TComYuv*    pcRecoYuv,
                                   UInt        uiPreCalcDistC );
-  
-#if INTRA_BL
-  Void setBaseRecPic            ( TComPicYuv* pcPicYuvRecBase ) { m_pcPicYuvRecBase = pcPicYuvRecBase; }  
-  TComPicYuv* getBaseRecPic     ()                              { return m_pcPicYuvRecBase; }
-  Void  estIntraBLPredQT        ( TComDataCU* pcCU, 
-                                  TComYuv*    pcOrgYuv, 
-                                  TComYuv*    pcPredYuv, 
-                                  TComYuv*    pcResiYuv, 
-                                  TComYuv*    pcRecoYuv );
-#endif
   
   /// encoder estimation - inter prediction (non-skip)
Index: trunk/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 345)
@@ -345,5 +345,5 @@
 
 #if JCTVC_M0259_LAMBDAREFINEMENT
-  if( rpcSlice->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() && depth >= 3 && m_pcCfg->getGOPSize() == ( 1 << depth ) )
+  if( rpcSlice->getLayerId() > 0 && m_ppcTEncTop[layerId]->getNumActiveRefLayers() && depth >= 3 && m_pcCfg->getGOPSize() == ( 1 << depth ) )
   {
     Int nCurLayer = rpcSlice->getLayerId();
@@ -373,5 +373,5 @@
   weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
 #if JCTVC_M0259_LAMBDAREFINEMENT
-  if( rpcSlice->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() && m_pcCfg->getGOPSize() >= 8 && rpcSlice->isIntra() == false && depth == 0 )
+  if( rpcSlice->getLayerId() > 0 && m_ppcTEncTop[layerId]->getNumActiveRefLayers() && m_pcCfg->getGOPSize() >= 8 && rpcSlice->isIntra() == false && depth == 0 )
   {
     dLambda *= 1.1;
@@ -503,5 +503,7 @@
 #if M0457_COL_PICTURE_SIGNALING
     rpcSlice->setMFMEnabledFlag(m_ppcTEncTop[layerId]->getMFMEnabledFlag());
+#if !REMOVE_COL_PICTURE_SIGNALING
     rpcSlice->setAltColIndicationFlag(rpcSlice->getMFMEnabledFlag());
+#endif
 #endif
   }
@@ -979,8 +981,4 @@
   UInt uiTileStartLCU = 0;
   UInt uiTileLCUX     = 0;
-
-#if INTRA_BL
-  m_pcCuEncoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec(rpcPic->getLayerId()-1) : NULL);
-#endif
 
   Bool depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag();
Index: trunk/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 345)
@@ -886,5 +886,9 @@
   for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) 
   {
+#if FINAL_RPL_CHANGE_N0082
+    GOPEntry ge = m_ppcTEncTop[m_cSPS.getLayerId()]->getGOPEntry(i);
+#else
     GOPEntry ge = getGOPEntry(i);
+#endif
     rps = rpsList->getReferencePictureSet(i);
     rps->setNumberOfPictures(ge.m_numRefPics);
@@ -1204,9 +1208,5 @@
   if( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() <= 0 )
   {
-#if ZERO_NUM_DIRECT_LAYERS
     return (TEncTop *)getLayerEnc( 0 );
-#else
-    return NULL;
-#endif
   }
 
