Index: trunk/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 964)
+++ trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 976)
@@ -71,5 +71,5 @@
 #endif
 
-#if H_MV_HLS_7_VPS_P0300_27
+#if H_MV
     m_markedForOutput = false; 
 #endif
@@ -161,7 +161,5 @@
   Int  pocLastPic        = -MAX_INT;   
 
-#if H_MV_HLS_7_VPS_P0300_27
   Int  layerIdLastPic    = -MAX_INT; 
-#endif
   Int  layerIdCurrPic    = 0; 
 
@@ -216,7 +214,5 @@
           || (nalu.m_nalUnitType == NAL_UNIT_VPS && nalu.m_layerId > 0)           
           || (nalu.m_nalUnitType == NAL_UNIT_EOB && nalu.m_layerId > 0)    
-#if H_MV_HLS_8_MIS_Q0177_47
           || (nalu.m_nalUnitType == NAL_UNIT_EOS && nalu.m_layerId > 0)    
-#endif
          ) 
       {
@@ -237,5 +233,4 @@
         // - nalu.isSlice() == true      
 
-#if H_MV_HLS_7_VPS_P0300_27
         if ( nalu.m_nalUnitType == NAL_UNIT_VPS )
         {
@@ -244,10 +239,4 @@
           {
             TComVPS* vps = m_vps; 
-#else
-        // Update TargetDecLayerIdList only when not specified by layer id file, specification by file might actually out of conformance. 
-        if (nalu.m_nalUnitType == NAL_UNIT_VPS && m_targetDecLayerIdSetFileEmpty )
-        {
-          TComVPS* vps = m_tDecTop[decIdx]->getPrefetchedVPS(); 
-#endif
           if ( m_targetOptLayerSetIdx == -1 )
           {
@@ -255,10 +244,9 @@
             m_targetOptLayerSetIdx = vps->getVpsNumLayerSetsMinus1(); 
           }
-#if H_MV_HLS_8_HRD_Q0102_08
+
           for (Int dI = 0; dI < m_numDecoders; dI++ )
           {
             m_tDecTop[decIdx]->setTargetOptLayerSetIdx( m_targetOptLayerSetIdx ); 
           }
-#endif
 
           if ( m_targetOptLayerSetIdx < 0 || m_targetOptLayerSetIdx >= vps->getNumOutputLayerSets() )
@@ -269,7 +257,5 @@
           m_targetDecLayerIdSet = vps->getTargetDecLayerIdList( m_targetOptLayerSetIdx ); 
         }
-#if H_MV_HLS_7_VPS_P0300_27
-      }
-#endif
+      }
 #if H_3D
         if (nalu.m_nalUnitType == NAL_UNIT_VPS )
@@ -289,7 +275,5 @@
         if ( bNewPicture || !bitstreamFile )
         { 
-#if H_MV_HLS_7_VPS_P0300_27
           layerIdLastPic    = layerIdCurrPic; 
-#endif
           layerIdCurrPic    = nalu.m_layerId; 
           pocLastPic        = pocCurrPic; 
@@ -340,7 +324,5 @@
         assert( decIdxLastPic != -1 ); 
         m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet );
-#if H_MV_HLS_7_VPS_P0300_27
         xMarkForOutput( allLayersDecoded, poc, layerIdLastPic ); 
-#endif
 #else
         m_cTDecTop.executeLoopFilters(poc, pcListPic);
@@ -664,4 +646,188 @@
           const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
 
+          const Bool isTff = pcPicTop->isTopField();
+#if H_MV
+        assert( conf   .getScaledFlag() );
+        assert( defDisp.getScaledFlag() );
+#if ENC_DEC_TRACE 
+        g_bJustDoIt = true;  
+        writeToTraceFile( "OutputPic Poc"   , pcPic->getPOC    (), g_decTracePicOutput  ); 
+        writeToTraceFile( "OutputPic LayerId", pcPic->getLayerId(), g_decTracePicOutput );         
+        g_bJustDoIt = false;  
+#endif
+        m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
+#else
+          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
+#endif
+                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
+                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
+                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
+                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
+        }
+        
+        // update POC of display order
+#if H_MV
+        m_pocLastDisplay[decIdx] = pcPic->getPOC();
+#else
+        m_iPOCLastDisplay = pcPicBottom->getPOC();
+#endif
+        
+        // erase non-referenced picture in the reference picture list after display
+        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
+        {
+#if !DYN_REF_FREE
+          pcPicTop->setReconMark(false);
+          
+          // mark it should be extended later
+          pcPicTop->getPicYuvRec()->setBorderExtension( false );
+          
+#else
+          pcPicTop->destroy();
+          pcListPic->erase( iterPic );
+          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
+          continue;
+#endif
+        }
+        if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
+        {
+#if !DYN_REF_FREE
+          pcPicBottom->setReconMark(false);
+          
+          // mark it should be extended later
+          pcPicBottom->getPicYuvRec()->setBorderExtension( false );
+          
+#else
+          pcPicBottom->destroy();
+          pcListPic->erase( iterPic );
+          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
+          continue;
+#endif
+        }
+        pcPicTop->setOutputMark(false);
+        pcPicBottom->setOutputMark(false);
+      }
+    }
+  }
+  else if (!pcPic->isField()) //Frame Decoding
+  {
+    iterPic = pcListPic->begin();
+    while (iterPic != pcListPic->end())
+    {
+      pcPic = *(iterPic);
+
+#if H_MV
+      if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx] &&
+        (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid))
+#else      
+      if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay &&
+        (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid))
+#endif
+      {
+        // write to file
+        numPicsNotYetDisplayed--;
+        if(pcPic->getSlice(0)->isReferenced() == false)
+        {
+          dpbFullness--;
+        }
+#if H_MV
+      if ( m_pchReconFiles[decIdx] )
+#else
+        if ( m_pchReconFile )
+#endif
+        {
+          const Window &conf = pcPic->getConformanceWindow();
+          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
+#if H_MV
+        assert( conf   .getScaledFlag() );
+        assert( defDisp.getScaledFlag() );
+#if ENC_DEC_TRACE
+        g_bJustDoIt = true;  
+        writeToTraceFile( "OutputPic Poc"   , pcPic->getPOC    (), g_decTracePicOutput  ); 
+        writeToTraceFile( "OutputPic LayerId", pcPic->getLayerId(), g_decTracePicOutput );         
+        g_bJustDoIt = false; 
+#endif
+        m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
+#else
+          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
+#endif
+                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
+                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
+                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
+                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
+        }
+        
+        // update POC of display order
+#if H_MV
+        m_pocLastDisplay[decIdx] = pcPic->getPOC();
+#else
+        m_iPOCLastDisplay = pcPic->getPOC();
+#endif
+        
+        // erase non-referenced picture in the reference picture list after display
+        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
+        {
+#if !DYN_REF_FREE
+          pcPic->setReconMark(false);
+          
+          // mark it should be extended later
+          pcPic->getPicYuvRec()->setBorderExtension( false );
+          
+#else
+          pcPic->destroy();
+          pcListPic->erase( iterPic );
+          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
+          continue;
+#endif
+        }
+        pcPic->setOutputMark(false);
+#if H_MV
+        pcPic->setPicOutputFlag(false);
+#endif
+      }
+      
+      iterPic++;
+    }
+  }
+}
+/** \param pcListPic list of pictures to be written to file
+    \todo            DYN_REF_FREE should be revised
+ */
+#if H_MV
+Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int decIdx )
+#else
+Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic )
+#endif
+{
+  if(!pcListPic || pcListPic->empty())
+  {
+    return;
+  }
+  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
+  
+  iterPic   = pcListPic->begin();
+  TComPic* pcPic = *(iterPic);
+  
+  if (pcPic->isField()) //Field Decoding
+  {
+    TComList<TComPic*>::iterator endPic   = pcListPic->end();
+    endPic--;
+    TComPic *pcPicTop, *pcPicBottom = NULL;
+    while (iterPic != endPic)
+    {
+      pcPicTop = *(iterPic);
+      iterPic++;
+      pcPicBottom = *(iterPic);
+      
+      if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) )
+      {
+        // write to file
+#if H_MV
+      if ( m_pchReconFiles[decIdx] )
+#else
+        if ( m_pchReconFile )
+#endif
+        {
+          const Window &conf = pcPicTop->getConformanceWindow();
+          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
           const Bool isTff = pcPicTop->isTopField();
 #if H_MV
@@ -686,9 +852,8 @@
         // update POC of display order
 #if H_MV
-        m_pocLastDisplay[decIdx] = pcPic->getPOC();
-#else
-        m_iPOCLastDisplay = pcPicBottom->getPOC();
-#endif
-        
+      m_pocLastDisplay[decIdx] = pcPic->getPOC();
+#else
+      m_iPOCLastDisplay = pcPicBottom->getPOC();
+#endif        
         // erase non-referenced picture in the reference picture list after display
         if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
@@ -724,28 +889,31 @@
         pcPicTop->setOutputMark(false);
         pcPicBottom->setOutputMark(false);
-      }
-    }
-  }
-  else if (!pcPic->isField()) //Frame Decoding
-  {
-    iterPic = pcListPic->begin();
+        
+#if !DYN_REF_FREE
+        if(pcPicTop)
+        {
+          pcPicTop->destroy();
+          delete pcPicTop;
+          pcPicTop = NULL;
+        }
+#endif
+      }
+    }
+    if(pcPicBottom)
+    {
+      pcPicBottom->destroy();
+      delete pcPicBottom;
+      pcPicBottom = NULL;
+    }
+  }
+  else //Frame decoding
+  {
     while (iterPic != pcListPic->end())
     {
       pcPic = *(iterPic);
-
-#if H_MV
-      if(pcPic->getOutputMark() && pcPic->getPOC() > m_pocLastDisplay[decIdx] &&
-        (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid))
-#else      
-      if(pcPic->getOutputMark() && pcPic->getPOC() > m_iPOCLastDisplay &&
-        (numPicsNotYetDisplayed >  numReorderPicsHighestTid || dpbFullness > maxDecPicBufferingHighestTid))
-#endif
+      
+      if ( pcPic->getOutputMark() )
       {
         // write to file
-        numPicsNotYetDisplayed--;
-        if(pcPic->getSlice(0)->isReferenced() == false)
-        {
-          dpbFullness--;
-        }
 #if H_MV
       if ( m_pchReconFiles[decIdx] )
@@ -756,97 +924,4 @@
           const Window &conf = pcPic->getConformanceWindow();
           const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
-#if H_MV
-        assert( conf   .getScaledFlag() );
-        assert( defDisp.getScaledFlag() );
-#if ENC_DEC_TRACE
-        g_bJustDoIt = true;  
-        writeToTraceFile( "OutputPic Poc"   , pcPic->getPOC    (), g_decTracePicOutput  ); 
-        writeToTraceFile( "OutputPic LayerId", pcPic->getLayerId(), g_decTracePicOutput );         
-        g_bJustDoIt = false; 
-#endif
-        m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
-#else
-          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
-#endif
-                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
-                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
-                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
-                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
-        }
-        
-        // update POC of display order
-#if H_MV
-        m_pocLastDisplay[decIdx] = pcPic->getPOC();
-#else
-        m_iPOCLastDisplay = pcPic->getPOC();
-#endif
-        
-        // erase non-referenced picture in the reference picture list after display
-        if ( !pcPic->getSlice(0)->isReferenced() && pcPic->getReconMark() == true )
-        {
-#if !DYN_REF_FREE
-          pcPic->setReconMark(false);
-          
-          // mark it should be extended later
-          pcPic->getPicYuvRec()->setBorderExtension( false );
-          
-#else
-          pcPic->destroy();
-          pcListPic->erase( iterPic );
-          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
-          continue;
-#endif
-        }
-        pcPic->setOutputMark(false);
-#if H_MV_HLS_7_VPS_P0300_27
-        pcPic->setPicOutputFlag(false);
-#endif
-      }
-      
-      iterPic++;
-    }
-  }
-}
-/** \param pcListPic list of pictures to be written to file
-    \todo            DYN_REF_FREE should be revised
- */
-#if H_MV
-Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic, Int decIdx )
-#else
-Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic )
-#endif
-{
-  if(!pcListPic || pcListPic->empty())
-  {
-    return;
-  }
-  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
-  
-  iterPic   = pcListPic->begin();
-  TComPic* pcPic = *(iterPic);
-  
-  if (pcPic->isField()) //Field Decoding
-  {
-    TComList<TComPic*>::iterator endPic   = pcListPic->end();
-    endPic--;
-    TComPic *pcPicTop, *pcPicBottom = NULL;
-    while (iterPic != endPic)
-    {
-      pcPicTop = *(iterPic);
-      iterPic++;
-      pcPicBottom = *(iterPic);
-      
-      if ( pcPicTop->getOutputMark() && pcPicBottom->getOutputMark() && !(pcPicTop->getPOC()%2) && (pcPicBottom->getPOC() == pcPicTop->getPOC()+1) )
-      {
-        // write to file
-#if H_MV
-      if ( m_pchReconFiles[decIdx] )
-#else
-        if ( m_pchReconFile )
-#endif
-        {
-          const Window &conf = pcPicTop->getConformanceWindow();
-          const Window &defDisp = m_respectDefDispWindow ? pcPicTop->getDefDisplayWindow() : Window();
-          const Bool isTff = pcPicTop->isTopField();
 #if H_MV
         assert( conf   .getScaledFlag() );
@@ -858,97 +933,4 @@
         g_bJustDoIt = false;  
 #endif
-        m_tVideoIOYuvReconFile[decIdx]->write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
-#else
-          m_cTVideoIOYuvReconFile.write( pcPicTop->getPicYuvRec(), pcPicBottom->getPicYuvRec(),
-#endif
-                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
-                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
-                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
-                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset(), isTff );
-        }
-        
-        // update POC of display order
-#if H_MV
-      m_pocLastDisplay[decIdx] = pcPic->getPOC();
-#else
-      m_iPOCLastDisplay = pcPicBottom->getPOC();
-#endif        
-        // erase non-referenced picture in the reference picture list after display
-        if ( !pcPicTop->getSlice(0)->isReferenced() && pcPicTop->getReconMark() == true )
-        {
-#if !DYN_REF_FREE
-          pcPicTop->setReconMark(false);
-          
-          // mark it should be extended later
-          pcPicTop->getPicYuvRec()->setBorderExtension( false );
-          
-#else
-          pcPicTop->destroy();
-          pcListPic->erase( iterPic );
-          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
-          continue;
-#endif
-        }
-        if ( !pcPicBottom->getSlice(0)->isReferenced() && pcPicBottom->getReconMark() == true )
-        {
-#if !DYN_REF_FREE
-          pcPicBottom->setReconMark(false);
-          
-          // mark it should be extended later
-          pcPicBottom->getPicYuvRec()->setBorderExtension( false );
-          
-#else
-          pcPicBottom->destroy();
-          pcListPic->erase( iterPic );
-          iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
-          continue;
-#endif
-        }
-        pcPicTop->setOutputMark(false);
-        pcPicBottom->setOutputMark(false);
-        
-#if !DYN_REF_FREE
-        if(pcPicTop)
-        {
-          pcPicTop->destroy();
-          delete pcPicTop;
-          pcPicTop = NULL;
-        }
-#endif
-      }
-    }
-    if(pcPicBottom)
-    {
-      pcPicBottom->destroy();
-      delete pcPicBottom;
-      pcPicBottom = NULL;
-    }
-  }
-  else //Frame decoding
-  {
-    while (iterPic != pcListPic->end())
-    {
-      pcPic = *(iterPic);
-      
-      if ( pcPic->getOutputMark() )
-      {
-        // write to file
-#if H_MV
-      if ( m_pchReconFiles[decIdx] )
-#else
-        if ( m_pchReconFile )
-#endif
-        {
-          const Window &conf = pcPic->getConformanceWindow();
-          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
-#if H_MV
-        assert( conf   .getScaledFlag() );
-        assert( defDisp.getScaledFlag() );
-#if ENC_DEC_TRACE
-        g_bJustDoIt = true;  
-        writeToTraceFile( "OutputPic Poc"   , pcPic->getPOC    (), g_decTracePicOutput  ); 
-        writeToTraceFile( "OutputPic LayerId", pcPic->getLayerId(), g_decTracePicOutput );         
-        g_bJustDoIt = false;  
-#endif
         m_tVideoIOYuvReconFile[decIdx]->write( pcPic->getPicYuvRec(),
 #else
@@ -985,5 +967,5 @@
         }
         pcPic->setOutputMark(false);
-#if H_MV_HLS_7_VPS_P0300_27
+#if H_MV
         pcPic->setPicOutputFlag(false);
 #endif
@@ -1061,7 +1043,5 @@
     m_tDecTop[ decIdx ]->setIvPicLists( &m_ivPicLists ); 
     m_tDecTop[ decIdx ]->setLayerInitilizedFlags( m_layerInitilizedFlags );
-#if    H_MV_HLS_8_HRD_Q0102_08
     m_tDecTop[ decIdx ]->setTargetOptLayerSetIdx( m_targetOptLayerSetIdx );    
-#endif
 
 #if H_3D
@@ -1099,6 +1079,4 @@
 }
 
-
-#if H_MV_HLS_7_VPS_P0300_27
 Void TAppDecTop::xMarkForOutput( Bool allLayersDecoded, Int pocLastPic, Int layerIdLastPic )
 {  
@@ -1152,5 +1130,39 @@
   }
 }
-#endif
+
+Void TAppDecTop::xMarkAltOutPic( Int targetOutputLayer, Int pocLastPic )
+{
+  Int optLayerIdxInVps = m_vps->getLayerIdInNuh( targetOutputLayer ); 
+  Int highestNuhLayerId = -1; 
+  TComPic* picWithHighestNuhLayerId = NULL; 
+  for (Int dIdx = 0; dIdx < m_numDecoders; dIdx++)
+  {
+    Int curLayerId = m_tDecTop[dIdx]->getLayerId();
+    Int curLayerIdxInVps = m_vps->getLayerIdInNuh( curLayerId  ); 
+    if ( m_vps->getInDirectDependencyFlag(optLayerIdxInVps, curLayerIdxInVps ) )
+    {
+      TComPic* curPic = m_ivPicLists.getPic( curLayerId, pocLastPic ); 
+      if (curPic != NULL)
+      {
+        if (curPic->getReconMark() && curPic->getPicOutputFlag() )
+        {
+          curPic->setOutputMark   ( false ); 
+          curPic->setPicOutputFlag( false ); 
+          if ( curLayerId > highestNuhLayerId)
+          {
+            highestNuhLayerId = curLayerId ; 
+            picWithHighestNuhLayerId = curPic; 
+          }            
+        }
+      }
+    }
+  }
+  if ( picWithHighestNuhLayerId != NULL )
+  {
+    picWithHighestNuhLayerId->setPicOutputFlag(true); 
+    picWithHighestNuhLayerId->setOutputMark   (true); 
+  }
+}
+
 #endif
 //! \}
Index: trunk/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- trunk/source/App/TAppDecoder/TAppDecTop.h	(revision 964)
+++ trunk/source/App/TAppDecoder/TAppDecTop.h	(revision 976)
@@ -68,7 +68,5 @@
   TComPicLists                    m_ivPicLists;                                ///< picture buffers of decoder instances
   Bool                            m_layerInitilizedFlags[ MAX_NUM_LAYER_IDS ]; ///< for layerwise startup 
-#if H_MV_HLS_7_VPS_P0300_27
   TComVPS*                        m_vps;                                ///< active VPS
-#endif
 #else
   TDecTop                         m_cTDecTop;                     ///< decoder class
@@ -79,11 +77,8 @@
   Int                             m_pocLastDisplay      [ MAX_NUM_LAYERS ]; ///< last POC in display order
   Bool                            m_reconOpen           [ MAX_NUM_LAYERS ]; ///< reconstruction file opened
+  Bool                            m_markedForOutput; 
 #else
   Int                             m_iPOCLastDisplay;              ///< last POC in display order
 #endif
-#if H_MV_HLS_7_VPS_P0300_27
-  Bool                            m_markedForOutput; 
-#endif
-
 
 #if H_3D
@@ -107,40 +102,6 @@
   Void  xWriteOutput      ( TComList<TComPic*>* pcListPic, Int layerId, Int tId ); ///< write YUV to file
 
-#if H_MV_HLS_7_VPS_P0300_27
   Void  xMarkForOutput   ( Bool allLayersDecoded, Int pocLastPic, Int layerIdLastPic );         
-  Void  xMarkAltOutPic    ( Int targetOutputLayer, Int pocLastPic )
-  {
-    Int optLayerIdxInVps = m_vps->getLayerIdInNuh( targetOutputLayer ); 
-    Int highestNuhLayerId = -1; 
-    TComPic* picWithHighestNuhLayerId = NULL; 
-    for (Int dIdx = 0; dIdx < m_numDecoders; dIdx++)
-    {
-      Int curLayerId = m_tDecTop[dIdx]->getLayerId();
-      Int curLayerIdxInVps = m_vps->getLayerIdInNuh( curLayerId  ); 
-      if ( m_vps->getInDirectDependencyFlag(optLayerIdxInVps, curLayerIdxInVps ) )
-      {
-        TComPic* curPic = m_ivPicLists.getPic( curLayerId, pocLastPic ); 
-        if (curPic != NULL)
-        {
-          if (curPic->getReconMark() && curPic->getPicOutputFlag() )
-          {
-            curPic->setOutputMark   ( false ); 
-            curPic->setPicOutputFlag( false ); 
-            if ( curLayerId > highestNuhLayerId)
-            {
-              highestNuhLayerId = curLayerId ; 
-              picWithHighestNuhLayerId = curPic; 
-            }            
-          }
-        }
-      }
-    }
-    if ( picWithHighestNuhLayerId != NULL )
-    {
-      picWithHighestNuhLayerId->setPicOutputFlag(true); 
-      picWithHighestNuhLayerId->setOutputMark   (true); 
-    }
-  }
-#endif
+  Void  xMarkAltOutPic    ( Int targetOutputLayer, Int pocLastPic );
 
   Void  xFlushOutput      ( TComList<TComPic*>* pcListPic, Int layerId ); ///< flush all remaining decoded pictures to file
Index: trunk/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 964)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 976)
@@ -393,7 +393,5 @@
   ("LayerIdsInAddOutputLayerSet_%d", m_layerIdsInAddOutputLayerSet      , std::vector<Int>(0,0), MAX_VPS_ADD_OUTPUT_LAYER_SETS, "Indices in VPS of output layers in additional output layer set")  
   ("LayerIdsInDefOutputLayerSet_%d", m_layerIdsInDefOutputLayerSet      , std::vector<Int>(0,0), MAX_VPS_OP_SETS_PLUS1, "Indices in VPS of output layers in layer set")  
-#if H_MV_HLS_7_VPS_P0300_27
   ("AltOutputLayerFlag",    m_altOutputLayerFlag , std::vector<Bool>(1,0), "Alt output layer flag")
-#endif
   ("ProfileLevelTierIdx",   m_profileLevelTierIdx, std::vector<Int>(1,0), "Indices to profile level tier")
   
@@ -523,7 +521,5 @@
 #if H_3D_IC
   ("IlluCompEnable",           m_abUseIC, true, "Enable illumination compensation")
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
   ("IlluCompLowLatencyEnc",    m_bUseLowLatencyICEnc, false, "Enable low-latency illumination compensation encoding")
-#endif
 #endif
 #if H_3D_INTER_SDC
@@ -1058,10 +1054,8 @@
   xResizeVector( m_wppInUseFlag ); 
 
-#if H_MV_HLS_7_VPS_P0300_27
   for (Int olsIdx = 0; olsIdx < m_vpsNumLayerSets + (Int) m_outputLayerSetIdx.size(); olsIdx++)
   {    
     m_altOutputLayerFlag.push_back( false );      
   }
-#endif
 #else
   m_aidQP = new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ];
@@ -1465,7 +1459,5 @@
   }
 
-#if H_MV_HLS_7_VPS_P0300_27
   xConfirmPara( m_altOutputLayerFlag.size() < m_vpsNumLayerSets + m_outputLayerSetIdx.size(), "The number of Profile Level Tier indices must be equal to the number of layer set plus the number of output layer set indices" );
-#endif
   xConfirmPara( m_profileLevelTierIdx.size() < m_vpsNumLayerSets + m_outputLayerSetIdx.size(), "The number of Profile Level Tier indices must be equal to the number of layer set plus the number of output layer set indices" );
 
@@ -2515,7 +2507,5 @@
 #if H_3D_IC
   printf( "IlluCompEnable:%d ", m_abUseIC);
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
   printf ("IlluCompLowLatencyEnc:%d ",  m_bUseLowLatencyICEnc);
-#endif
 #endif
 #if H_3D_NBDV_REF
Index: trunk/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 964)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 976)
@@ -94,7 +94,5 @@
   std::vector< std::vector<Int> > m_layerIdsInDefOutputLayerSet; ///< Indices in vps of output layers in layer sets
   std::vector<Int>       m_profileLevelTierIdx;               ///< Indices of of profile level tier
-  #if H_MV_HLS_7_VPS_P0300_27
   std::vector<Bool>      m_altOutputLayerFlag;                ///< Alt output layer flag
-#endif
 
   // Dependencies
@@ -140,7 +138,5 @@
 #if H_3D_IC
   Bool   m_abUseIC;
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
-  Bool  m_bUseLowLatencyICEnc;
-#endif
+  Bool   m_bUseLowLatencyICEnc;
 #endif
 #if H_3D_NBDV_REF
Index: trunk/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 964)
+++ trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 976)
@@ -58,8 +58,7 @@
 {
 
-#if H_MV_HLS_8
+#if H_MV
   m_vps = new TComVPS; 
-#endif
-#if !H_MV
+#else
   m_iFrameRcvd = 0;
 #endif
@@ -70,5 +69,5 @@
 TAppEncTop::~TAppEncTop()
 {
-#if H_MV_HLS_8
+#if H_MV
   if (m_vps)
   {
@@ -82,9 +81,5 @@
 {
 #if H_MV
-#if H_MV_HLS_8
   TComVPS& vps = (*m_vps);   
-#else
-  TComVPS& vps = m_vps;   
-#endif
 #else
   TComVPS vps;
@@ -193,9 +188,4 @@
     m_cTEncTop.setDWeight                      ( isDepth ? m_iDWeight             : 0     );
 #endif // H_3D_VSO
-#if H_3D_ARP && !QC_IV_PRED_CONSTRAINT_H0137
-    //====== Advanced Inter-view Residual Prediction =========
-    m_cTEncTop.setUseAdvRP                     ( ( isDepth || 0==layerIdInVps ) ? 0 : m_uiUseAdvResPred );
-    m_cTEncTop.setARPStepNum                   ( ( isDepth || 0==layerIdInVps ) ? 1 : H_3D_ARP_WFNR     );
-#endif
 #if H_3D_SPIVMP
     m_cTEncTop.setSubPULog2Size                 (( isDepth || 0==layerIdInVps ) ? 0 : m_iSubPULog2Size   );
@@ -204,7 +194,5 @@
 #if H_3D_IC
     m_cTEncTop.setUseIC                        ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_abUseIC );
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
     m_cTEncTop.setUseICLowLatencyEnc           ( m_bUseLowLatencyICEnc );
-#endif
 #endif
   //========== Depth intra modes ==========
@@ -708,15 +696,8 @@
 {
 #if H_3D
-#if H_MV_HLS_8
   for ( Int viewIndex = 0; viewIndex < m_vps->getNumViews(); viewIndex++ )
   {
     m_vps->initCamParaVPS( viewIndex, true, m_cCameraData.getCamParsCodedPrecision(), 
       m_cCameraData.getVaryingCameraParameters(), m_cCameraData.getCodedScale(), m_cCameraData.getCodedOffset() );
-#else
-  for ( Int viewIndex = 0; viewIndex < m_vps.getNumViews(); viewIndex++ )
-  {
-  m_vps.initCamParaVPS( viewIndex, true, m_cCameraData.getCamParsCodedPrecision(), 
-      m_cCameraData.getVaryingCameraParameters(), m_cCameraData.getCodedScale(), m_cCameraData.getCodedOffset() );
-#endif
   }
 #endif
@@ -1299,9 +1280,5 @@
 
   Int  defaultDirectDependencyType = -1; 
-#if MV_FIX_DEP_TYPES
   Bool defaultDirectDependencyFlag = false; 
-#else
-  Bool defaultDirectDependencyFlag = true; 
-#endif
 
   for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ )
@@ -1322,7 +1299,5 @@
       {
         defaultDirectDependencyType = curDirectDependencyType; 
-#if MV_FIX_DEP_TYPES
         defaultDirectDependencyFlag = true; 
-#endif
       }
       
@@ -1514,9 +1489,5 @@
 Void TAppEncTop::xSetRepFormat( TComVPS& vps )
 {
-#if H_MV_HLS_8_PMS_Q0195_20
   vps.setRepFormatIdxPresentFlag( false ); 
-#else
-  vps.setRepFormatIdxPresentFlag( true ); 
-#endif
   vps.setVpsNumRepFormatsMinus1 ( 0    ); 
 
@@ -1534,11 +1505,4 @@
   assert( vps.getRepFormat( 0 ) == NULL ); 
   vps.setRepFormat( 0 , repFormat );
-
-#if !H_MV_HLS_8_PMS_Q0195_20
-  for(Int i = 0; i <= vps.getMaxLayersMinus1(); i++ )
-  {
-    vps.setVpsRepFormatIdx( i , 0 ); 
-  }
-#endif
 }
 
@@ -1551,35 +1515,17 @@
   assert ( dpbSize != 0 ); 
 
-#if H_MV_HLS_8_HRD_Q0102_08
   for( Int i = 0; i < vps.getNumOutputLayerSets(); i++ )
-#else
-  for( Int i = 1; i < vps.getNumOutputLayerSets(); i++ )
-#endif
   {  
-#if H_MV_HLS_8_MIS_Q0102_30
     Int currLsIdx = vps.olsIdxToLsIdx( i ); 
-#endif
     std::vector<Int> targetDecLayerIdList = vps.getTargetDecLayerIdList( i ); 
     Bool subLayerFlagInfoPresentFlag = false; 
 
-#if H_MV_HLS_8_MIS_Q0102_30
     for( Int j = 0; j  <=  vps.getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ )
-#else
-    for( Int j = 0; j  <=  vps.getMaxSubLayersInLayerSetMinus1( i ); j++ )
-#endif
     {   
       Bool subLayerDpbInfoPresentFlag = false; 
-#if H_MV_HLS_8_MIS_Q0102_30 || H_MV_HLS_8_DBP_NODOC_42
       assert( vps.getNumLayersInIdList( currLsIdx ) == targetDecLayerIdList.size() ); 
       for( Int k = 0; k < vps.getNumLayersInIdList( currLsIdx ); k++ )   
-#else
-      assert( vps.getNumSubDpbs( vps.olsIdxToLsIdx( i ) ) == targetDecLayerIdList.size() ); 
-      for( Int k = 0; k < vps.getNumSubDpbs( vps.olsIdxToLsIdx( i )); k++ )   
-#endif
       {
         Int layerIdInVps = vps.getLayerIdInVps( targetDecLayerIdList[k] );           
-#if H_MV_HLS7_GEN
-        // TBD. Some derivation based on output layer set might be added here. 
-#endif
         dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, m_maxDecPicBufferingMvc[ layerIdInVps ][ j ] - 1 );
         if ( j > 0 )
@@ -1642,10 +1588,6 @@
   // Additional output layer sets + profileLevelTierIdx
   vps.setDefaultOutputLayerIdc      ( m_defaultOutputLayerIdc );   
-#if H_MV_HLS_8_SYN_39_19
   vps.setNumAddLayerSets            ( 0                             );  
   vps.setNumAddOlss                 ( numAddOuputLayerSets          ); 
-#else
-  vps.setNumAddLayerSets            ( numAddOuputLayerSets          ); 
-#endif
   vps.initTargetLayerIdLists(); 
 
@@ -1696,5 +1638,5 @@
       vps.setProfileLevelTierIdx( olsIdx, m_profileLevelTierIdx[ olsIdx ] ); 
     }
-#if H_MV_HLS_7_VPS_P0300_27
+   
     if ( vps.getNumOutputLayersInOutputLayerSet( olsIdx ) == 1 && 
         vps.getNumDirectRefLayers( vps.getOlsHighestOutputLayerId( olsIdx ) ) )
@@ -1710,7 +1652,4 @@
       }
     }
-#else
-    vps.setAltOutputLayerFlag( olsIdx , false);     
-#endif
   }
 }
@@ -1869,11 +1808,6 @@
 
 #if H_3D_ARP
-#if QC_IV_PRED_CONSTRAINT_H0137
     vps.setUseAdvRP        ( layer, ( isDepth || isLayerZero || !vps.getNumDirectRefLayers(layer) ) ? 0 : m_uiUseAdvResPred );
     vps.setARPStepNum      ( layer, ( isDepth || isLayerZero || !vps.getNumDirectRefLayers(layer) ) ? 1 : H_3D_ARP_WFNR     );
-#else
-    vps.setUseAdvRP        ( layer, ( isDepth || isLayerZero ) ? 0 : m_uiUseAdvResPred );
-    vps.setARPStepNum      ( layer, ( isDepth || isLayerZero ) ? 1 : H_3D_ARP_WFNR     );
-#endif  
 #endif  
 #if H_3D_SPIVMP
@@ -1893,5 +1827,4 @@
 
 #if H_3D_IV_MERGE
-#if QC_IV_PRED_CONSTRAINT_H0137
     if( !vps.getNumDirectRefLayers(layer) )
     {
@@ -1900,16 +1833,13 @@
     else
     {
-#endif
-    if( isDepth )
-    {
-      vps.setIvMvPredFlag         ( layer, (layer != 1) && m_ivMvPredFlag[1] ); 
-    }
-    else
-    {
-      vps.setIvMvPredFlag         ( layer, !isLayerZero && m_ivMvPredFlag[0] ); 
-    }
-#if QC_IV_PRED_CONSTRAINT_H0137
-    }
-#endif
+      if( isDepth )
+      {
+        vps.setIvMvPredFlag         ( layer, (layer != 1) && m_ivMvPredFlag[1] ); 
+      }
+      else
+      {
+        vps.setIvMvPredFlag         ( layer, !isLayerZero && m_ivMvPredFlag[0] ); 
+      }
+    }
 #endif
 #if H_3D_NBDV_REF
@@ -1917,9 +1847,5 @@
 #endif
 #if H_3D_VSP
-#if QC_IV_PRED_CONSTRAINT_H0137
     vps.setViewSynthesisPredFlag( layer, !isLayerZero && !isDepth && vps.getNumDirectRefLayers(layer) && m_viewSynthesisPredFlag );         
-#else
-    vps.setViewSynthesisPredFlag( layer, !isLayerZero && !isDepth && m_viewSynthesisPredFlag );         
-#endif
 #endif
 #if H_3D_DBBP
Index: trunk/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 964)
+++ trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 976)
@@ -75,5 +75,5 @@
 
   TComPicLists               m_ivPicLists;                  ///< picture buffers of encoder instances
-#if H_MV_HLS_8
+#if H_MV
   TComVPS*                   m_vps;                         ///< vps
 #else
Index: trunk/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/CommonDef.h	(revision 964)
+++ trunk/source/Lib/TLibCommon/CommonDef.h	(revision 976)
@@ -60,5 +60,5 @@
 
 #if H_MV
-#define NV_VERSION        "11.1"                ///< Current software version
+#define NV_VERSION        "11.2"                ///< Current software version
 #define HM_VERSION        "14.0"                ///< 
 #else
Index: trunk/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- trunk/source/Lib/TLibCommon/ContextTables.h	(revision 964)
+++ trunk/source/Lib/TLibCommon/ContextTables.h	(revision 976)
@@ -110,9 +110,5 @@
 #define NUM_DMM1_DATA_CTX             1       ///< number of context models for DMM1 data
 #endif
-#if LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135
 #define NUM_ANGLE_FLAG_CTX            1
-#else
-#define NUM_ANGLE_FLAG_CTX            3
-#endif
 #endif
 
@@ -372,5 +368,4 @@
 };
 
-#if LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135
 static const UChar 
 INIT_ANGLE_FLAG[3][NUM_ANGLE_FLAG_CTX] =
@@ -380,13 +375,4 @@
   { 155 },
 };
-#else
-static const UChar 
-INIT_ANGLE_FLAG[3][NUM_ANGLE_FLAG_CTX] =
-{
-  { 154, 155, 156 },
-  { 141, 185, 214 },
-  { 155, 170, 157 },
-};
-#endif
 
 static const UChar 
@@ -444,5 +430,4 @@
 
 #if H_3D_DBBP
-#if MTK_DBBP_SIGNALING_H0094
 static const UChar INIT_DBBP_FLAG[3][DBBP_NUM_FLAG_CTX] =
 {
@@ -451,13 +436,5 @@
   { 161 },
 };
-#else
-static const UChar INIT_DBBP_FLAG[3][DBBP_NUM_FLAG_CTX] =
-{
-  { CNU },
-  { CNU },
-  { CNU },
-};
-#endif
-#endif
-
-#endif
+#endif
+
+#endif
Index: trunk/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 964)
+++ trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 976)
@@ -610,8 +610,6 @@
     memset( m_apSegmentDCOffset[1]  + firstElement,     0,                numElements * sizeof( *m_apSegmentDCOffset[1] ) );
 #endif
-#if HS_DMM_SDC_PREDICTOR_UNIFY_H0108
     m_apDmmPredictor[0] = 0;
     m_apDmmPredictor[1] = 0;
-#endif
 #endif
 #if H_3D_DBBP
@@ -788,8 +786,6 @@
       m_apSegmentDCOffset[1][ui] = 0;
 #endif
-#if HS_DMM_SDC_PREDICTOR_UNIFY_H0108
       m_apDmmPredictor[0] = 0;
       m_apDmmPredictor[1] = 0;
-#endif
 #endif
 #if H_3D_DBBP
@@ -907,8 +903,6 @@
   memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition   );
 #endif
-#if HS_DMM_SDC_PREDICTOR_UNIFY_H0108
   m_apDmmPredictor[0] = 0;
   m_apDmmPredictor[1] = 0;
-#endif
 #endif
 #if H_3D_DBBP
@@ -2364,10 +2358,8 @@
     
     TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV;
-#if SEC_VER_DONBDV_H0103
     if( depthRefineFlag )
     {
       cDv.setVer(0);
     }
-#endif
     
     Int depthPosX = Clip3(0,   iPictureWidth - iWidth,  iBlkX + ((cDv.getHor()+2)>>2));
@@ -2399,24 +2391,4 @@
 }
 
-UInt TComDataCU::getCtxAngleFlag( UInt uiAbsPartIdx )
-{
-#if LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135
-  return 0;
-#else
-  TComDataCU* pcTempCU;
-  UInt        uiTempPartIdx;
-  UInt        uiCtx = 0;
-
-  // Get BCBP of left PU
-  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
-  uiCtx    = ( pcTempCU && pcTempCU->isIntra( uiTempPartIdx ) ) ? ( pcTempCU->getLumaIntraDir( uiTempPartIdx ) < NUM_INTRA_MODE ? 1 : 0 ) : 0;
-
-  // Get BCBP of above PU
-  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
-  uiCtx   += ( pcTempCU && pcTempCU->isIntra( uiTempPartIdx ) ) ? ( pcTempCU->getLumaIntraDir( uiTempPartIdx ) < NUM_INTRA_MODE ? 1 : 0 ) : 0;
-
-  return uiCtx;
-#endif
-}
 #endif
 
@@ -3280,10 +3252,5 @@
  *   false: otherwise
  */
-#if ETRIKHU_CLEANUP_H0083
 inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount)
-#else
-inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
-  Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag, Int& iCount3DV, InheritedVSPDisInfo*  inheritedVSPDisInfo  )
-#endif
 {
   if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) || m_pcSlice->getIsDepth() || pDInfo->m_aVIdxCan == -1)
@@ -3301,11 +3268,6 @@
   }
 
-#if ETRIKHU_CLEANUP_H0083
   TComMvField mvVSP[2];
   UChar dirVSP;
-#else
-  rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
-#endif
-
   Bool  refViewAvailFlag = false;
   UChar predFlag[2]      = {0, 0};
@@ -3321,29 +3283,14 @@
         refViewAvailFlag      = true;
         predFlag[iRefListIdX] = 1;
-#if ETRIKHU_CLEANUP_H0083
         mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i );
 #if H_3D_NBDV
         mvVSP[0+iRefListIdX].getMv().setIDVFlag (false);
 #endif
-#else
-        pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acNBDV, i );
-#if H_3D_NBDV
-        pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].getMv().setIDVFlag (false);
-#endif
-#endif
-      }
-    }
-  }
-
-#if ETRIKHU_CLEANUP_H0083
+      }
+    }
+  }
+
   dirVSP = (predFlag[0] | (predFlag[1] << 1));
   m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true, false);
-#else
-  // Set values to be returned
-  abCandIsInter        [iCount] = true;
-  puhInterDirNeighbours[iCount] = (predFlag[0] | (predFlag[1] << 1));
-  vspFlag              [iCount] = 1;
-#endif
-
   if ( mrgCandIdx == iCount )
   {
@@ -3359,10 +3306,5 @@
 
 #if H_3D_IV_MERGE
-#if ETRIKHU_CLEANUP_H0083
 inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx )
-#else
-inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* ivCandDir, TComMv* ivCandMv, 
-  Int* ivCandRefIdx, Int iPosIvDC, Int* vspFlag, Int &iCount3DV, InheritedVSPDisInfo*  inheritedVSPDisInfo  )
-#endif
 {
   for(Int iLoop = 0; iLoop < 2; iLoop ++ ) 
@@ -3372,19 +3314,11 @@
     {
       Int iFirDispCand = -1;
-#if ETRIKHU_CLEANUP_H0083
       TComMvField mvIvDcShift[2];
       UChar dirIvDcShift;
 
       if (xGetPosFirstAvailDmvCand(MRG_IVSHIFT, iFirDispCand))
-#else
-      if (xGetPosFirstAvailDmvCand(iCount, pcMvFieldNeighbours, ivCandDir, iPosIvDC, vspFlag, iFirDispCand))
-#endif
       {
         TComMv cMv;
-#if ETRIKHU_CLEANUP_H0083
         cMv = m_mergCands[iFirDispCand].m_cMvField[0].getMv();
-#else
-        cMv = pcMvFieldNeighbours[(iFirDispCand<<1)].getMv();
-#endif
         cMv.setHor(cMv.getHor()+4);
         if(m_pcSlice->getVPS()->getViewSynthesisPredFlag(m_pcSlice->getLayerIdInVps()))
@@ -3396,17 +3330,8 @@
 #endif
 
-#if ETRIKHU_CLEANUP_H0083
         dirIvDcShift = m_mergCands[iFirDispCand].m_uDir;
         mvIvDcShift[0].setMvField(cMv, m_mergCands[iFirDispCand].m_cMvField[0].getRefIdx() );
         mvIvDcShift[1].setMvField(m_mergCands[iFirDispCand].m_cMvField[1].getMv(), m_mergCands[iFirDispCand].m_cMvField[1].getRefIdx() );
         m_mergCands[MRG_IVSHIFT].setCand(mvIvDcShift, dirIvDcShift, false, false);
-#else
-        rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
-
-        abCandIsInter        [ iCount ] = true;
-        puhInterDirNeighbours[ iCount ] = puhInterDirNeighbours[iFirDispCand];
-        pcMvFieldNeighbours  [ iCount << 1      ].setMvField(cMv, pcMvFieldNeighbours[( iFirDispCand << 1)].getRefIdx() );
-        pcMvFieldNeighbours  [(iCount << 1) + 1 ].setMvField(pcMvFieldNeighbours[(iFirDispCand << 1) + 1].getMv(), pcMvFieldNeighbours[( iFirDispCand << 1) + 1].getRefIdx() );
-#endif
         
         if( mrgCandIdx == iCount ) 
@@ -3414,5 +3339,4 @@
           return true;
         }
-
         iCount++;
         break;
@@ -3439,9 +3363,5 @@
       if( !iLoop && ivCandDir[0] > 0)
       {
-#if ETRIKHU_CLEANUP_H0083
         if(tmpDir == m_mergCands[MRG_IVMC].m_uDir && m_mergCands[MRG_IVMC].m_cMvField[0]==tmpMV[0] && m_mergCands[MRG_IVMC].m_cMvField[1]==tmpMV[1])
-#else
-        if(tmpDir == puhInterDirNeighbours[0] && pcMvFieldNeighbours[0]==tmpMV[0] && pcMvFieldNeighbours[1]==tmpMV[1])
-#endif
         {
             bRemove                         = true;
@@ -3450,5 +3370,4 @@
       if(!bRemove)
       {
-#if ETRIKHU_CLEANUP_H0083
 #if H_3D_NBDV
         if(iLoop) // For IvMcShift candidate
@@ -3459,25 +3378,4 @@
 #endif
         m_mergCands[MRG_IVSHIFT].setCand(tmpMV, tmpDir, false, false);
-#else
-        rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
-
-        abCandIsInter[ iCount ] = true;
-        puhInterDirNeighbours[ iCount ] = ivCandDir[iLoop + 2];
-        if( ( ivCandDir[iLoop + 2] & 1 ) == 1 )
-        {
-          pcMvFieldNeighbours[ iCount<<1 ].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] ); 
-        }
-        if( ( ivCandDir[iLoop + 2] & 2 ) == 2 )
-        {
-          pcMvFieldNeighbours[ (iCount<<1)+1 ].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] );
-        }
-#if H_3D_NBDV
-        if(iLoop) // For IvMcShift candidate
-        {
-          pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
-          pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
-        }
-#endif
-#endif
         if( mrgCandIdx == iCount )
         {
@@ -3492,5 +3390,4 @@
 } 
 
-#if ETRIKHU_CLEANUP_H0083
 inline Bool TComDataCU::xGetPosFirstAvailDmvCand(Int iCount, Int& posFirstAvailDmvCand )
 {
@@ -3509,29 +3406,8 @@
   return false;  
 }
-#else
-inline Bool TComDataCU::xGetPosFirstAvailDmvCand( Int iCount, TComMvField* pcMvFieldNeighbours, Int* ivCandDir, Int posIvDC, Int* vspFlag, Int& posFirstAvailDmvCand )
-{
-  // ivCandDir[0] == true --> IvMC is available and excluded in loop over merge list. 
-  for ( Int currListPos = (ivCandDir[0] ? 1 : 0); currListPos < iCount; currListPos++ )
-  {
-    if ( ( currListPos == posIvDC ) || ( vspFlag[ currListPos ] != 0 ) )
-    {
-      continue;
-    }
-    else if((pcMvFieldNeighbours[currListPos<<1].getRefIdx() != -1 ) && (getSlice()->getViewIndex() != getSlice()->getRefPic(RefPicList(0), pcMvFieldNeighbours[currListPos<<1].getRefIdx())->getViewIndex()))
-    {
-      posFirstAvailDmvCand = currListPos;
-      return true;
-    }
-  }
- return false;  
-}
-#endif
                                       
 #endif
 
 #if H_3D
-#if ETRIKHU_CLEANUP_H0083
-
 Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
 #if H_3D_VSP
@@ -3606,26 +3482,4 @@
   assert(iCount == getSlice()->getMaxNumMergeCand());
 }
-#else
-Void TComDataCU::rightShiftMergeCandList( TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* iVSPIndexTrue, InheritedVSPDisInfo*  inheritedVSPDisInfo, UInt start, UInt num, Int &iCount3DV)
-{
-  iCount3DV++;
-  for (int i=num; i>0; i--)
-  {
-    pcMvFieldNeighbours[(start+i)<<1].setMvField(pcMvFieldNeighbours[(start+i-1)<<1].getMv(), pcMvFieldNeighbours[(start+i-1)<<1].getRefIdx());
-    pcMvFieldNeighbours[((start+i)<<1)+1].setMvField(pcMvFieldNeighbours[((start+i-1)<<1)+1].getMv(), pcMvFieldNeighbours[((start+i-1)<<1)+1].getRefIdx());
-    puhInterDirNeighbours[start+i] = puhInterDirNeighbours[start+i-1];
-    iVSPIndexTrue[start+i] = iVSPIndexTrue[start+i-1];
-    inheritedVSPDisInfo[start+i].m_acDvInfo   = inheritedVSPDisInfo[start+i-1].m_acDvInfo;
-  }
-  TComMv  cZeroMv;
-  pcMvFieldNeighbours[start<<1].setMvField( cZeroMv, NOT_VALID );
-  pcMvFieldNeighbours[(start<<1)+1].setMvField( cZeroMv, NOT_VALID );
-  puhInterDirNeighbours[start] = 0;
-  iVSPIndexTrue[start] = 0;
-  inheritedVSPDisInfo[start].m_acDvInfo = m_cDefaultDisInfo;
-
-  return;
-}
-#endif
 
 /** Constructs a list of merging candidates
@@ -4001,15 +3855,8 @@
 #endif
 #if H_3D_VSP
-#if !ETRIKHU_CLEANUP_H0083
-      , Int* vspFlag
-#endif
       , InheritedVSPDisInfo*  inheritedVSPDisInfo
 #endif
 #if H_3D_SPIVMP
-#if ETRIKHU_CLEANUP_H0083
       , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
-#else
-      , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
-#endif
 #endif
       , Int& numValidMergeCand, Int mrgCandIdx
@@ -4022,7 +3869,4 @@
   ////////////////////////////
   TComMv cZeroMv;
-#if !ETRIKHU_CLEANUP_H0083
-  Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
-#endif
 #else
   Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
@@ -4090,18 +3934,8 @@
 #if H_3D_DBBP
   Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx);
-#if MTK_DIS_SPBIP8X4_H0205
   assert(bDBBPFlag == getDBBPFlag(0));  
 #endif
-#endif
 
 #if H_3D
-#if !ETRIKHU_CLEANUP_H0083
-  Int  iPosLeftAbove[2] = {-1, -1};
-
-  Int iCountHEVC = 0;
-  Int iCount3DV = 0;
-  Int numA1B1B0 = 0;
-  Int numA0B2 = 0;
-#endif
 #if H_3D_NBDV
   for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++)  
@@ -4111,9 +3945,4 @@
   }
 #endif
-
-
-#if ETRIKHU_CLEANUP_H0083
-
-
   // Clean version for MCL construction align with WD
   // init mergCands list
@@ -4142,5 +3971,5 @@
       && !bARPFlag
 #endif
-#if RWTH_DBBP_NO_SPU_H0057
+#if H_3D_DBBP
       && !bDBBPFlag
 #endif
@@ -4169,5 +3998,5 @@
       && !bARPFlag
 #endif
-#if RWTH_DBBP_NO_SPU_H0057
+#if H_3D_DBBP
       && !bDBBPFlag
 #endif
@@ -4196,5 +4025,5 @@
       && !bARPFlag
 #endif
-#if RWTH_DBBP_NO_SPU_H0057
+#if H_3D_DBBP
       && !bDBBPFlag
 #endif
@@ -4222,5 +4051,5 @@
       && !bARPFlag
 #endif
-#if RWTH_DBBP_NO_SPU_H0057
+#if H_3D_DBBP
       && !bDBBPFlag
 #endif
@@ -4249,5 +4078,5 @@
       && !bARPFlag
 #endif
-#if RWTH_DBBP_NO_SPU_H0057
+#if H_3D_DBBP
       && !bDBBPFlag
 #endif
@@ -4259,143 +4088,4 @@
   }
 
-
-#if !ETRIKHU_BUGFIX_H0083
-  Bool A1_was_available = m_mergCands[MRG_A1].m_bAvailable;
-  Bool B1_was_available = m_mergCands[MRG_B1].m_bAvailable;
-#endif
-
-
-#else
-  //left
-  UInt uiLeftPartIdx = 0;
-  TComDataCU* pcCULeft = 0;
-  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );  
-  if (getAvailableFlagA1())
-  {
-    iPosLeftAbove[0] = numA1B1B0;
-#if H_3D_VSP
-    if (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0
-#if H_3D_IC
-      && !bICFlag
-#endif
-#if H_3D_ARP
-      && !bARPFlag
-#endif
-#if RWTH_DBBP_NO_SPU_H0057
-      && !bDBBPFlag
-#endif
-      )
-    {
-      vspFlag[numA1B1B0] = 1;
-    }
-#endif
-    numA1B1B0++;
-  }
-
-  // above
-  UInt uiAbovePartIdx = 0;
-  TComDataCU* pcCUAbove = 0;
-  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
-  if ( getAvailableFlagB1())
-  {
-    iPosLeftAbove[1] = numA1B1B0;
-#if H_3D_VSP
-    if ( ( ( getAddr() - pcCUAbove->getAddr() ) == 0) && (pcCUAbove->getVSPFlag(uiAbovePartIdx) != 0) 
-#if H_3D_IC
-      && !bICFlag
-#endif
-#if H_3D_ARP
-      && !bARPFlag
-#endif
-#if RWTH_DBBP_NO_SPU_H0057
-      && !bDBBPFlag
-#endif
-      )
-    {
-      vspFlag[numA1B1B0] = 1;
-    }
-#endif
-
-    numA1B1B0++;
-  }
-
-  // above right
-  UInt uiAboveRightPartIdx = 0;
-  TComDataCU* pcCUAboveRight = 0;
-  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
-  if ( getAvailableFlagB0())
-  {
-#if H_3D_VSP
-    if ( ( ( getAddr() - pcCUAboveRight->getAddr() ) == 0) && (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) != 0) 
-#if H_3D_IC
-      && !bICFlag
-#endif
-#if H_3D_ARP
-      && !bARPFlag
-#endif
-#if RWTH_DBBP_NO_SPU_H0057
-      && !bDBBPFlag
-#endif
-      )
-    {
-      vspFlag[numA1B1B0] = 1;
-    }
-#endif
-    numA1B1B0++;
-  }
-  
-  // left bottom
-  UInt uiLeftBottomPartIdx = 0;
-  TComDataCU* pcCULeftBottom = getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
-  if ( getAvailableFlagA0())
-  {
-#if H_3D_VSP
-    if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) != 0
-#if H_3D_IC
-      && !bICFlag
-#endif
-#if H_3D_ARP
-      && !bARPFlag
-#endif
-#if RWTH_DBBP_NO_SPU_H0057
-      && !bDBBPFlag
-#endif
-      )
-    {
-      vspFlag[numA1B1B0] = 1;
-    }
-#endif
-    iCountHEVC++;
-    numA0B2++;
-  }
-  
-  // above left
-  UInt uiAboveLeftPartIdx = 0;
-  TComDataCU* pcCUAboveLeft = 0;
-  pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
-  if (getAvailableFlagB2())
-  {
-#if H_3D_VSP
-    if ( ( ( getAddr() - pcCUAboveLeft->getAddr() ) == 0) && (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) != 0) 
-#if H_3D_IC
-      && !bICFlag
-#endif
-#if H_3D_ARP
-      && !bARPFlag
-#endif
-#if RWTH_DBBP_NO_SPU_H0057
-      && !bDBBPFlag
-#endif
-      )
-    {
-      vspFlag[numA1B1B0+iCountHEVC] = 1;
-    }
-#endif
-    iCountHEVC++;
-    numA0B2++;
-  }
-
-  iCountHEVC = numValidMergeCand;
-#endif
 #endif
 
@@ -4407,7 +4097,5 @@
   /////////////////////////////////////////////
 
-#if SHARP_SIMPLE_MERGE_H0062
   bMPIFlag &= (nPSW + nPSH > 12);
-#endif
   if( bMPIFlag)
   {
@@ -4416,7 +4104,5 @@
     tmpDir        =  0;
 
-#if ETRIKHU_CLEANUP_H0083
     Bool bSPIVMPFlag = false;
-#endif
 
     TComPic * pcTexPic = m_pcSlice->getTexturePic();
@@ -4457,5 +4143,4 @@
       Int         iTexPosX, iTexPosY;
       const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
-#if MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133
       
       Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iPUWidth ) >> 1 )  * iPUWidth + ( iPUWidth >> 1 );
@@ -4476,38 +4161,30 @@
       if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA )
       {
-          for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
+        for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
+        {
+          RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
+
+          TComMvField cDefaultMvField;
+          pcDefaultCU->getMvField( pcDefaultCU, iTexCenterAbsPartIdx, eCurrRefPicList, cDefaultMvField );
+          Int         iDefaultRefIdx     = cDefaultMvField.getRefIdx();
+          if (iDefaultRefIdx >= 0)
           {
-              RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
-
-              TComMvField cDefaultMvField;
-              pcDefaultCU->getMvField( pcDefaultCU, iTexCenterAbsPartIdx, eCurrRefPicList, cDefaultMvField );
-              Int         iDefaultRefIdx     = cDefaultMvField.getRefIdx();
-              if (iDefaultRefIdx >= 0)
+            Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eCurrRefPicList, iDefaultRefIdx);
+            for (Int iRefPicList = 0; iRefPicList < m_pcSlice->getNumRefIdx( eCurrRefPicList ); iRefPicList++)
+            {
+              if (iDefaultRefPOC == m_pcSlice->getRefPOC(eCurrRefPicList, iRefPicList))
               {
-                  Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eCurrRefPicList, iDefaultRefIdx);
-                  for (Int iRefPicList = 0; iRefPicList < m_pcSlice->getNumRefIdx( eCurrRefPicList ); iRefPicList++)
-                  {
-                      if (iDefaultRefPOC == m_pcSlice->getRefPOC(eCurrRefPicList, iRefPicList))
-                      {
-#if ETRIKHU_CLEANUP_H0083
-                        bSPIVMPFlag = true;
-#else
-                          pbSPIVMPFlag[iCount] = true;
-#endif
-                          TComMv cMv = cDefaultMvField.getMv() + cMvRounding;
-                          cMv >>= 2;
-                          clipMv( cMv );
-                          cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ;
-                          break;
-                      }
-                  }
+                bSPIVMPFlag = true;
+                TComMv cMv = cDefaultMvField.getMv() + cMvRounding;
+                cMv >>= 2;
+                clipMv( cMv );
+                cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ;
+                break;
               }
+            }
           }
-      }
-#if ETRIKHU_CLEANUP_H0083
+        }
+      }
       if ( bSPIVMPFlag == true )
-#else
-      if ( pbSPIVMPFlag[iCount] == true )
-#endif
       {   
           iInterDirSaved = (cMvFieldSaved[0].getRefIdx()!=-1 ? 1: 0) + (cMvFieldSaved[1].getRefIdx()!=-1 ? 2: 0);
@@ -4519,86 +4196,55 @@
       if ( iInterDirSaved != 0 )
       {
-#endif
-      for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iPUHeight)
-      {
-        for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iPUWidth)
+        for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iPUHeight)
         {
-          iTexPosX     = j + iOffsetX;
-          iTexPosY     = i + iOffsetY; 
-          pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx );
-          pcTexCU  = pcTexPic->getCU( iTexCUAddr );
-
-          if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) )
+          for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iPUWidth)
           {
-            for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
+            iTexPosX     = j + iOffsetX;
+            iTexPosY     = i + iOffsetY; 
+            pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx );
+            pcTexCU  = pcTexPic->getCU( iTexCUAddr );
+
+            if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) )
             {
-              RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
-              TComMvField cTexMvField;
-              pcTexCU->getMvField( pcTexCU, iTexAbsPartIdx, eCurrRefPicList, cTexMvField );
-              Int iValidDepRef = getPic()->isTextRefValid( eCurrRefPicList, cTexMvField.getRefIdx() );
-              if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) )
+              for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
               {
-                TComMv cMv = cTexMvField.getMv() + cMvRounding;
-                cMv >>=2;          
+                RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
+                TComMvField cTexMvField;
+                pcTexCU->getMvField( pcTexCU, iTexAbsPartIdx, eCurrRefPicList, cTexMvField );
+                Int iValidDepRef = getPic()->isTextRefValid( eCurrRefPicList, cTexMvField.getRefIdx() );
+                if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) )
+                {
+                  TComMv cMv = cTexMvField.getMv() + cMvRounding;
+                  cMv >>=2;          
 #if !(NTT_BUG_FIX_TK54)
-                this->clipMv( cMv );
-#endif
-                pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef);
-              }
-            }
-          }
-          puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0);
-          if (puhInterDirSP[iPartition] == 0)
-          {
-            if (iInterDirSaved != 0)
-            {
-              puhInterDirSP[iPartition] = iInterDirSaved;
-              pcMvFieldSP[2*iPartition] = cMvFieldSaved[0];
-              pcMvFieldSP[2*iPartition + 1] = cMvFieldSaved[1];
-            }
-          }
-#if MTK_DIS_SPBIP8X4_H0205
-              if (iPUHeight + iPUWidth == 12)
-              {
-                if (puhInterDirSP[iPartition] == 3)
-                {
-                  puhInterDirSP[iPartition] = 1;
-                  pcMvFieldSP[2*iPartition + 1].setMvField(TComMv(0,0), -1);
-                }
-              }
-#endif
-#if !MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133
-          else
-          {
-            if (iInterDirSaved ==0)
-            {
-#if ETRIKHU_CLEANUP_H0083
-                  bSPIVMPFlag = true;
-#else
-              pbSPIVMPFlag[iCount] = true;
-#endif
-              tmpDir = puhInterDirSP[iPartition];
-              tmpMV[0] = pcMvFieldSP[2*iPartition];
-              tmpMV[1] = pcMvFieldSP[2*iPartition+1];
-
-              if (iPartition != 0)
-              {
-                for (Int iPart = iPartition-1; iPart >= 0; iPart--)
-                {
-                  puhInterDirSP[iPart] = puhInterDirSP[iPartition];
-                  pcMvFieldSP[2*iPart] = pcMvFieldSP[2*iPartition];
-                  pcMvFieldSP[2*iPart + 1] = pcMvFieldSP[2*iPartition + 1];
+                  this->clipMv( cMv );
+#endif
+                  pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef);
                 }
               }
             }
-            iInterDirSaved = puhInterDirSP[iPartition];
-            cMvFieldSaved[0] = pcMvFieldSP[2*iPartition];
-            cMvFieldSaved[1] = pcMvFieldSP[2*iPartition + 1];
+            puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0);
+            if (puhInterDirSP[iPartition] == 0)
+            {
+              if (iInterDirSaved != 0)
+              {
+                puhInterDirSP[iPartition] = iInterDirSaved;
+                pcMvFieldSP[2*iPartition] = cMvFieldSaved[0];
+                pcMvFieldSP[2*iPartition + 1] = cMvFieldSaved[1];
+              }
+            }
+            if (iPUHeight + iPUWidth == 12)
+            {
+              if (puhInterDirSP[iPartition] == 3)
+              {
+                puhInterDirSP[iPartition] = 1;
+                pcMvFieldSP[2*iPartition + 1].setMvField(TComMv(0,0), -1);
+              }
+            }
+
+            iPartition ++;
           }
-#endif
-          iPartition ++;
         }
-      }
-#if MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133
+#if H_3D
       }
 #endif
@@ -4609,5 +4255,4 @@
     {
       Int iCnloop = 0;
-#if ETRIKHU_CLEANUP_H0083
       for(iCnloop = 0; iCnloop < 2; iCnloop ++)
       {
@@ -4624,65 +4269,4 @@
       m_mergCands[MRG_T].setCand( tmpMV, tmpDir, false, bSPIVMPFlag);
 
-#else
-      Bool bRemoveSpa = false; //pruning
-
-      for(Int i = 0; i < 2; i ++)
-      {
-        iCnloop = iPosLeftAbove[i];
-        if ( iCnloop == -1 ) 
-        {
-          continue;
-        }
-        if(tmpDir == puhInterDirNeighbours[iCnloop] && tmpMV[0]==pcMvFieldNeighbours[(iCnloop<<1)] && tmpMV[1]==pcMvFieldNeighbours[(iCnloop<<1)+1])
-        {
-          bRemoveSpa                      = true;
-          break;
-        }      
-      }
-
-      if (!bRemoveSpa)
-      {
-        rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, 5-iCount, iCount3DV);
-      }
-      else
-      {
-        rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (iCnloop-iCount), iCount3DV);
-        if (iCnloop<numA1B1B0)
-        {
-          numA1B1B0--;
-        }
-        iCountHEVC--;
-
-        if (iPosLeftAbove[0] != -1)
-        {
-          if (iCnloop == iPosLeftAbove[0])
-          {
-            iPosLeftAbove[0] = -1;
-          }
-          else
-          {
-            iPosLeftAbove[0]++;
-          }
-        }
-        if (iPosLeftAbove[1] != -1)
-        {
-          if (iCnloop == iPosLeftAbove[1])
-          {
-            iPosLeftAbove[1] = -1;
-          }
-          else
-          {
-            if (iCnloop > iPosLeftAbove[1])
-            {
-              iPosLeftAbove[1]++;
-            }
-          }
-        }
-      }
-      pcMvFieldNeighbours[iCount<<1].setMvField(tmpMV[0].getMv(), tmpMV[0].getRefIdx());
-      pcMvFieldNeighbours[(iCount<<1)+1].setMvField(tmpMV[1].getMv(), tmpMV[1].getRefIdx());
-
-      puhInterDirNeighbours[iCount] = tmpDir;
-#endif
       if ( mrgCandIdx == iCount )
       {
@@ -4763,11 +4347,7 @@
       if( tmpDir != 0 )
       {
-#if !ETRIKHU_CLEANUP_H0083
-        rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, 5-iCount, iCount3DV);
-#endif
         m_ucDDTmpDepth = m_pcSlice->getDepthFromDV( iDV,  iViewIdx );
         m_iUseDDDCandIdx = iCount;
 
-#if ETRIKHU_CLEANUP_H0083
         m_mergCands[MRG_D].setCand( tmpMV, tmpDir, false, false);
         if ( mrgCandIdx == iCount )
@@ -4776,34 +4356,4 @@
         }
         iCount ++;
-#else
-        if( tmpDir == 1 )
-        {
-          pcMvFieldNeighbours[ iCount << 1 ] = tmpMV[ 0 ];
-        }
-        else if( tmpDir == 2  )
-        {
-          pcMvFieldNeighbours[( iCount << 1 ) + 1 ] = tmpMV[ 1 ];
-        }
-
-        abCandIsInter        [ iCount ] = true;
-        puhInterDirNeighbours[ iCount ] = tmpDir;
-
-        if ( mrgCandIdx == iCount )
-        {
-          return;
-        }
-        iCount ++;
-
-        Int iLeftAboveAvail = 0;
-        if( iPosLeftAbove[ 0 ] != -1 )
-        {
-          iPosLeftAbove[ 0 ] = iCount;
-          iLeftAboveAvail = 1;
-        }
-        if( iPosLeftAbove[ 1 ] != -1 )
-        {
-          iPosLeftAbove[ 1 ] = iCount + iLeftAboveAvail;
-        }
-#endif
       }
     }
@@ -4813,8 +4363,4 @@
   //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC  Candidates /////
   /////////////////////////////////////////////////////////////////
-
-#if !ETRIKHU_CLEANUP_H0083
-  Int  posIvDC          = -1;
-#endif
 
   // { IvMCL0, IvMCL1, IvDCL0, IvDCL1, IvMCL0Shift, IvMCL1Shift, IvDCL0Shift, IvDCL1Shift };  
@@ -4828,14 +4374,8 @@
   Bool ivMvPredFlag   = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() );
 
-#if SHARP_SIMPLE_MERGE_H0062
   ivMvPredFlag &= (nPSW + nPSH > 12);
-#endif
   if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1)
   {
-#if SEC_ADAPT_DISABLE_IVMP
     getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag );
-#else
-    getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP );
-#endif
   }  
 
@@ -4863,8 +4403,4 @@
 
     Bool bRemoveSpa = false; //pruning
-#if !ETRIKHU_CLEANUP_H0083
-    Bool bIvMC = false;
-    Int iCnloop=0;
-#endif
 
     if (!bIsDepth)
@@ -4872,5 +4408,4 @@
       for(Int i = 0; i < 2; i ++)
       {
-#if ETRIKHU_CLEANUP_H0083
         if ( !m_mergCands[MRG_A1 + i].m_bAvailable ) // prunning to A1, B1
         {
@@ -4882,107 +4417,17 @@
           break;
         }      
-#else
-        iCnloop = iPosLeftAbove[i];
-        if ( iCnloop == -1 ) 
-        {
-          continue;
-        }
-        if(ivCandDir[0] == puhInterDirNeighbours[iCnloop] && tmpMV[0]==pcMvFieldNeighbours[(iCnloop<<1)] && tmpMV[1]==pcMvFieldNeighbours[(iCnloop<<1)+1])
-        {
-          bRemoveSpa                      = true;
-          break;
-        }      
-#endif
       }
     }
     if (bIsDepth)
     {
-#if ETRIKHU_CLEANUP_H0083
       if (m_mergCands[MRG_T].m_bAvailable && ivCandDir[0] == m_mergCands[MRG_T].m_uDir && tmpMV[0]==m_mergCands[MRG_T].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_T].m_cMvField[1])
       {
         bRemoveSpa                      = true;
       }
-#else
-      iCnloop = iCount-1;
-      for(; iCnloop >= 0; iCnloop --)
-      {
-#if H_3D_DDD
-          if( iCnloop == m_iUseDDDCandIdx )
-          {
-              continue;
-          }
-#endif
-        if(ivCandDir[0] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==tmpMV[0] && pcMvFieldNeighbours[(iCnloop<<1)+1]==tmpMV[1])  // F0125 compatible with F0093
-        {
-          bRemoveSpa                      = true;
-          break;
-        }
-      }
-#endif
-    }
-
+    }
     if (!bRemoveSpa)
     {
-#if !ETRIKHU_CLEANUP_H0083
-      bIvMC = true;
-      rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
-
-      if (iPosLeftAbove[0] != -1)
-      {
-        iPosLeftAbove[0]++;
-      }
-      if (iPosLeftAbove[1] != -1)
-      {
-        iPosLeftAbove[1]++;
-      }
-    }
-    else if (bRemoveSpa && !bIsDepth)
-    {
-      bIvMC = true;
-      rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (iCnloop-iCount), iCount3DV);
-
-      if (iCnloop<numA1B1B0)
-      {
-        numA1B1B0--;
-      }
-      iCountHEVC--;
-
-      if (iPosLeftAbove[0] != -1)
-      {
-        if (iCnloop == iPosLeftAbove[0])
-        {
-          iPosLeftAbove[0] = -1;
-        }
-        else
-        {
-          iPosLeftAbove[0]++;
-        }
-      }
-      if (iPosLeftAbove[1] != -1)
-      {
-        if (iCnloop == iPosLeftAbove[1])
-        {
-          iPosLeftAbove[1] = -1;
-        }
-        else
-        {
-          if (iCnloop > iPosLeftAbove[1])
-          {
-            iPosLeftAbove[1]++;
-          }
-        }
-      }
-    }
-
-    if (bIvMC)
-    {
-#endif
-#if ETRIKHU_CLEANUP_H0083
       Bool SPIVMPFlag = false;
-#if MTK_DIS_SPBIP8X4_H0205
       if(!m_pcSlice->getIsDepth())
-#else
-      if(!m_pcSlice->getIsDepth() && getPartitionSize(0) == SIZE_2Nx2N )
-#endif
       {
         SPIVMPFlag = true;
@@ -4991,27 +4436,6 @@
       SPIVMPFlag &= !bDBBPFlag;
 #endif
-#else
-      if(!m_pcSlice->getIsDepth() && getPartitionSize(0) == SIZE_2Nx2N )
-      {
-          pbSPIVMPFlag[iCount] = true;
-      }
-#if H_3D_DBBP
-      pbSPIVMPFlag[iCount] &= !bDBBPFlag;
-#endif
-#endif
-#if ETRIKHU_CLEANUP_H0083
+
       m_mergCands[MRG_IVMC].setCand( tmpMV, ivCandDir[0], false, SPIVMPFlag);
-#else
-      if( ( ivCandDir[0] & 1 ) == 1 )
-      {
-        pcMvFieldNeighbours[iCount<<1].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] );
-      }
-      if( ( ivCandDir[0] & 2 ) == 2 )
-      {
-        pcMvFieldNeighbours[(iCount<<1)+1].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] );
-      }
-
-      puhInterDirNeighbours[ iCount ] = ivCandDir[0];
-#endif
 
       if ( mrgCandIdx == iCount )
@@ -5031,9 +4455,5 @@
 
 #if H_3D
-#if ETRIKHU_CLEANUP_H0083
   iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable + m_mergCands[MRG_B0].m_bAvailable;
-#else
-  iCount += numA1B1B0;
-#endif
 #else
   //left
@@ -5164,26 +4584,9 @@
     for(Int i = 0; i < 2; i ++)
     {
-#if ETRIKHU_CLEANUP_H0083
       if ( !m_mergCands[MRG_A1+i].m_bAvailable ) 
-#else
-      Int iCnloop = iPosLeftAbove[i];
-      if ( iCnloop == -1 ) 
-#endif
       {
         continue;
       }
-#if ETRIKHU_CLEANUP_H0083
-#if ETRIKHU_BUGFIX_H0083
       if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1])
-#else
-      Int offset = 0;
-      offset += A1_was_available;
-      offset += B1_was_available;
-      offset += m_mergCands[MRG_B0].m_bAvailable;
-      if (puhInterDirNeighbours[offset] == m_mergCands[MRG_A1+i].m_uDir && pcMvFieldNeighbours[(offset<<1)]==m_mergCands[MRG_A1+i].m_cMvField[0] && pcMvFieldNeighbours[(offset<<1)+1]==m_mergCands[MRG_A1+i].m_cMvField[1])
-#endif
-#else
-      if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
-#endif
       {
         bRemoveSpa                      = true;
@@ -5193,5 +4596,4 @@
     if(!bRemoveSpa)
     {
-#if ETRIKHU_CLEANUP_H0083
 #if H_3D_NBDV
       tmpMV[0].getMv().setIDVFlag (false);
@@ -5199,21 +4601,5 @@
 #endif
       m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false);
-#else
-      rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
-      puhInterDirNeighbours[ iCount ] = ivCandDir[1];
-      if( ( ivCandDir[1] & 1 ) == 1 )
-      {
-        pcMvFieldNeighbours[ iCount<<1    ].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
-      }
-      if( ( ivCandDir[1] & 2 ) == 2 )
-      {
-        pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
-      }
-#if H_3D_NBDV
-      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
-      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
-#endif
-      posIvDC  = iCount;
-#endif
+
       if ( mrgCandIdx == iCount )
         return;
@@ -5243,15 +4629,11 @@
       !bARPFlag &&
 #endif
-#if SHARP_SIMPLE_MERGE_H0062
+#if H_3D
       (nPSW + nPSH > 12) &&
 #endif
-#if RWTH_DBBP_NO_SPU_H0057
+#if H_3D_DBBP
       !bDBBPFlag &&
 #endif
-#if ETRIKHU_CLEANUP_H0083
       xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) )
-#else
-      xAddVspCand( mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, iCount3DV, inheritedVSPDisInfo ) )
-#endif
   {
     return;
@@ -5269,9 +4651,5 @@
 
 #if H_3D
-#if ETRIKHU_CLEANUP_H0083
   iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable;
-#else
-  iCount += numA0B2;
-#endif
 #else
   //left bottom
@@ -5347,9 +4725,5 @@
   if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) 
   {
-#if ETRIKHU_CLEANUP_H0083
     if(xAddIvMRGCand( mrgCandIdx,  iCount, ivCandDir, ivCandMv, ivCandRefIdx ) )
-#else
-    if(xAddIvMRGCand( mrgCandIdx,  iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, ivCandDir, ivCandMv, ivCandRefIdx, posIvDC, vspFlag, iCount3DV, inheritedVSPDisInfo ) )
-#endif
     {
       return;
@@ -5362,18 +4736,5 @@
   }
 #endif
-
-#if H_3D
-#if !ETRIKHU_CLEANUP_H0083
-  if (iCountHEVC + iCount3DV > getSlice()->getMaxNumMergeCand())
-  {
-    iCount = getSlice()->getMaxNumMergeCand();
-  }
-  else
-  {
-    iCount = iCountHEVC + iCount3DV;
-  }
-  numValidMergeCand = iCount;
-#endif
-#else
+#if !H_3D
   if ( getSlice()->getEnableTMVPFlag())
   {
@@ -5463,5 +4824,5 @@
     }
   }
-  // early termination
+  // early termination  
   if (iCount == getSlice()->getMaxNumMergeCand()) 
   {
@@ -7232,10 +6593,8 @@
 
   TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; 
-#if SEC_VER_DONBDV_H0103
   if( depthRefineFlag )
   {
     cDv.setVer(0);
   }
-#endif
 
   Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
@@ -7346,7 +6705,5 @@
 , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
 #endif
-#if SEC_ADAPT_DISABLE_IVMP
 , Bool bICFlag
-#endif
 )
 {
@@ -7377,10 +6734,8 @@
 
   TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; 
-#if SEC_VER_DONBDV_H0103
   if( depthRefineFlag )
   {
     cDv.setVer(0);
   }
-#endif
 
   Bool abPdmAvailable[8] =  {false, false, false, false, false, false, false, false};
@@ -7392,79 +6747,244 @@
 #endif
 
-#if SEC_ADAPT_DISABLE_IVMP
   if(!bICFlag)
   {
-#endif
 
 #if H_3D_SPIVMP
-  ////////////////////////////////
-  //////////sub-PU IvMC///////////
-  ////////////////////////////////
-  if(!m_pcSlice->getIsDepth())
-  {
-#if MTK_DIS_SPBIP8X4_H0205
-    if (!getDBBPFlag(0))
+    ////////////////////////////////
+    //////////sub-PU IvMC///////////
+    ////////////////////////////////
+    if(!m_pcSlice->getIsDepth())
+    {
+      if (!getDBBPFlag(0))
+      {
+        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
+        getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
+
+        for (Int i=0; i<iNumSP; i++)
+        {
+          puhInterDirSP[i] = 0;
+          pcMvFieldSP[2*i].getMv().set(0, 0);
+          pcMvFieldSP[2*i+1].getMv().set(0,0);
+          pcMvFieldSP[2*i].setRefIdx(-1);
+          pcMvFieldSP[2*i+1].setRefIdx(-1);
+        }
+
+        Int         iBaseCUAddr;
+        Int         iBaseAbsPartIdx;
+        TComDataCU* pcBaseCU;
+        Int iPartition = 0;
+
+        Int iDelX = iSPWidth/2;
+        Int iDelY = iSPHeight/2;
+
+        Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iSPWidth ) >> 1 )  * iSPWidth + ( iSPWidth >> 1 );
+        Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iSPHeight ) >> 1 )  * iSPHeight + (iSPHeight >> 1);
+        Int         iRefCenterCUAddr, iRefCenterAbsPartIdx;
+
+        if(iWidth == iSPWidth && iHeight == iSPHeight)
+        {
+          iCenterPosX = iCurrPosX + (iWidth >> 1);
+          iCenterPosY = iCurrPosY + (iHeight >> 1);
+        }
+
+        Int iRefCenterPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
+        Int iRefCenterPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) ); 
+
+        pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx );
+        TComDataCU* pcDefaultCU    = pcBasePic->getCU( iRefCenterCUAddr );
+        if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA ))
+        {
+          for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )       
+          {
+            RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
+            Bool stopLoop = false;
+            for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop)
+            {
+              RefPicList eDefaultRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
+              TComMvField cDefaultMvField;
+              pcDefaultCU->getMvField( pcDefaultCU, iRefCenterAbsPartIdx, eDefaultRefPicList, cDefaultMvField );
+              Int         iDefaultRefIdx     = cDefaultMvField.getRefIdx();
+              if (iDefaultRefIdx >= 0)
+              {
+                Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eDefaultRefPicList, iDefaultRefIdx);
+                if (iDefaultRefPOC != pcSlice->getPOC())    
+                {
+                  for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
+                  {
+                    if (iDefaultRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
+                    {
+                      abPdmAvailable[ uiCurrRefListId ] = true;
+                      TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer());
+#if H_3D_NBDV 
+#if H_3D_IV_MERGE
+                      if( !bIsDepth )
+                      {
+#endif
+                        cMv.setIDVFlag   (true);
+                        cMv.setIDVHor    (cDv.getHor());                  
+                        cMv.setIDVVer    (cDv.getVer());  
+                        cMv.setIDVVId    (iViewIndex); 
+#if H_3D_IV_MERGE
+                      }
+#endif
+#endif
+#if !(NTT_BUG_FIX_TK54)
+                      clipMv( cMv );
+#endif
+                      paiPdmRefIdx  [ uiCurrRefListId ] = iPdmRefIdx;
+                      pacPdmMv      [ uiCurrRefListId ] = cMv;
+                      stopLoop = true;
+                      break;
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+        availableMcDc[0] = ( abPdmAvailable[0]? 1 : 0) + (abPdmAvailable[1]? 2 : 0);
+
+        if(availableMcDc[0])
+        {
+
+          Int         iBasePosX, iBasePosY;
+          for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iSPHeight)
+          {
+            for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth)
+            {
+              iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));
+              iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 )); 
+
+              pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx );
+              pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
+              if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
+              {
+                for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
+                {
+                  RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
+                  Bool bLoop_stop = false;
+                  for(Int iLoop = 0; iLoop < 2 && !bLoop_stop; ++iLoop)
+                  {
+                    RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
+                    TComMvField cBaseMvField;
+                    pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
+                    Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
+                    if (iBaseRefIdx >= 0)
+                    {
+                      Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
+                      if (iBaseRefPOC != pcSlice->getPOC())    
+                      {
+                        for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
+                        {
+                          if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
+                          {
+                            abPdmAvailable[ uiCurrRefListId ] = true;
+                            TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
+
+                            if( !bIsDepth )
+                            {
+                              cMv.setIDVFlag   (true);
+                              cMv.setIDVHor    (cDv.getHor());                  
+                              cMv.setIDVVer    (cDv.getVer());  
+                              cMv.setIDVVId    (iViewIndex); 
+                            }
+
+#if !(NTT_BUG_FIX_TK54)
+                            clipMv( cMv );
+#endif
+                            bLoop_stop = true;
+
+                            pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iPdmRefIdx);
+                            break;
+                          }
+                        }
+                      }
+                    }
+                  }
+                }
+              }
+
+              puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0);
+              if (puhInterDirSP[iPartition] == 0)
+              {
+                puhInterDirSP[iPartition] = availableMcDc[0];
+                pcMvFieldSP[2*iPartition].setMvField(pacPdmMv[0], paiPdmRefIdx[0]);
+                pcMvFieldSP[2*iPartition + 1].setMvField(pacPdmMv[1], paiPdmRefIdx[1]);
+
+              }
+              if (iSPHeight + iSPWidth == 12)
+              {
+                if (puhInterDirSP[iPartition] == 3)
+                {
+                  puhInterDirSP[iPartition] = 1;
+                  pcMvFieldSP[2*iPartition + 1].setMvField(TComMv(0,0), -1);
+                }
+              }
+              iPartition ++;
+            }
+          }
+        }
+      }
+
+      iCurrPosX  += ( iWidth  >> 1 );
+      iCurrPosY  += ( iHeight >> 1 );
+    }
+#endif
+
+    ////////////////////////////////
+    /////// IvMC + IvMCShift ///////
+    ////////////////////////////////
+
+#if H_3D_SPIVMP
+    if(m_pcSlice->getIsDepth())
+    {
+      iCurrPosX  += ( iWidth  >> 1 );
+      iCurrPosY  += ( iHeight >> 1 );
+    }
+    for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
 #else
-    if( getPartitionSize(0) == SIZE_2Nx2N )
-#endif
-    {
-      Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
-      getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
-
-      for (Int i=0; i<iNumSP; i++)
-      {
-        puhInterDirSP[i] = 0;
-        pcMvFieldSP[2*i].getMv().set(0, 0);
-        pcMvFieldSP[2*i+1].getMv().set(0,0);
-        pcMvFieldSP[2*i].setRefIdx(-1);
-        pcMvFieldSP[2*i+1].setRefIdx(-1);
-      }
+    for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
+#endif
+    {
+      // iLoopCan == 0 --> IvMC
+      // iLoopCan == 1 --> IvMCShift 
 
       Int         iBaseCUAddr;
       Int         iBaseAbsPartIdx;
-      TComDataCU* pcBaseCU;
-      Int iPartition = 0;
-
-      Int iDelX = iSPWidth/2;
-      Int iDelY = iSPHeight/2;
-
-      Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iSPWidth ) >> 1 )  * iSPWidth + ( iSPWidth >> 1 );
-      Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iSPHeight ) >> 1 )  * iSPHeight + (iSPHeight >> 1);
-      Int         iRefCenterCUAddr, iRefCenterAbsPartIdx;
-
-      if(iWidth == iSPWidth && iHeight == iSPHeight)
-      {
-        iCenterPosX = iCurrPosX + (iWidth >> 1);
-        iCenterPosY = iCurrPosY + (iHeight >> 1);
-      }
-
-      Int iRefCenterPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
-      Int iRefCenterPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) ); 
-
-      pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx );
-      TComDataCU* pcDefaultCU    = pcBasePic->getCU( iRefCenterCUAddr );
-      if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA ))
-      {
+
+      Int offsetW = (iLoopCan == 0) ? 0 : ( ((iWidth /2)*4) + 4 );
+      Int offsetH = (iLoopCan == 0) ? 0 : ( ((iHeight/2)*4) + 4 );
+
+      Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
+      Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); 
+      pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
+
+      TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
+      if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
+      {
+        // Loop reference picture list of current slice (X in spec). 
         for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )       
         {
           RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
+
           Bool stopLoop = false;
+          // Loop reference picture list of candidate slice (Y in spec)
           for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop)
           {
-            RefPicList eDefaultRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
-            TComMvField cDefaultMvField;
-            pcDefaultCU->getMvField( pcDefaultCU, iRefCenterAbsPartIdx, eDefaultRefPicList, cDefaultMvField );
-            Int         iDefaultRefIdx     = cDefaultMvField.getRefIdx();
-            if (iDefaultRefIdx >= 0)
+            RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
+            TComMvField cBaseMvField;
+            pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
+            Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
+            if (iBaseRefIdx >= 0)
             {
-              Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eDefaultRefPicList, iDefaultRefIdx);
-              if (iDefaultRefPOC != pcSlice->getPOC())    
+              Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
+              if (iBaseRefPOC != pcSlice->getPOC())    
               {
                 for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
                 {
-                  if (iDefaultRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
+                  if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
                   {
-                    abPdmAvailable[ uiCurrRefListId ] = true;
-                    TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer());
+                    abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true;
+                    TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
 #if H_3D_NBDV 
 #if H_3D_IV_MERGE
@@ -7483,6 +7003,6 @@
                     clipMv( cMv );
 #endif
-                    paiPdmRefIdx  [ uiCurrRefListId ] = iPdmRefIdx;
-                    pacPdmMv      [ uiCurrRefListId ] = cMv;
+                    paiPdmRefIdx  [ (uiCurrRefListId + (iLoopCan<<2)) ] = iPdmRefIdx;
+                    pacPdmMv      [ (uiCurrRefListId + (iLoopCan<<2)) ] = cMv;
                     stopLoop = true;
                     break;
@@ -7494,198 +7014,15 @@
         }
       }
-      availableMcDc[0] = ( abPdmAvailable[0]? 1 : 0) + (abPdmAvailable[1]? 2 : 0);
-
-      if(availableMcDc[0])
-      {
-
-        Int         iBasePosX, iBasePosY;
-        for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iSPHeight)
-        {
-          for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth)
-          {
-            iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));
-            iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 )); 
-
-            pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx );
-            pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
-            if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
-            {
-              for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
-              {
-                RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
-                Bool bLoop_stop = false;
-                for(Int iLoop = 0; iLoop < 2 && !bLoop_stop; ++iLoop)
-                {
-                  RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
-                  TComMvField cBaseMvField;
-                  pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
-                  Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
-                  if (iBaseRefIdx >= 0)
-                  {
-                    Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
-                    if (iBaseRefPOC != pcSlice->getPOC())    
-                    {
-                      for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
-                      {
-                        if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
-                        {
-                          abPdmAvailable[ uiCurrRefListId ] = true;
-                          TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
-
-                          if( !bIsDepth )
-                          {
-                            cMv.setIDVFlag   (true);
-                            cMv.setIDVHor    (cDv.getHor());                  
-                            cMv.setIDVVer    (cDv.getVer());  
-                            cMv.setIDVVId    (iViewIndex); 
-                          }
-                          
-#if !(NTT_BUG_FIX_TK54)
-                          clipMv( cMv );
-#endif
-                          bLoop_stop = true;
-
-                          pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iPdmRefIdx);
-                          break;
-                        }
-                      }
-                    }
-                  }
-                }
-              }
-            }
-
-            puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0);
-            if (puhInterDirSP[iPartition] == 0)
-            {
-              puhInterDirSP[iPartition] = availableMcDc[0];
-              pcMvFieldSP[2*iPartition].setMvField(pacPdmMv[0], paiPdmRefIdx[0]);
-              pcMvFieldSP[2*iPartition + 1].setMvField(pacPdmMv[1], paiPdmRefIdx[1]);
-
-            }
-#if MTK_DIS_SPBIP8X4_H0205
-            if (iSPHeight + iSPWidth == 12)
-            {
-              if (puhInterDirSP[iPartition] == 3)
-              {
-                puhInterDirSP[iPartition] = 1;
-                pcMvFieldSP[2*iPartition + 1].setMvField(TComMv(0,0), -1);
-              }
-            }
-#endif
-            iPartition ++;
-          }
-        }
-      }
-    }
-
-    iCurrPosX  += ( iWidth  >> 1 );
-    iCurrPosY  += ( iHeight >> 1 );
-  }
-#endif
-
-  ////////////////////////////////
-  /////// IvMC + IvMCShift ///////
-  ////////////////////////////////
-
+    }
 #if H_3D_SPIVMP
-  if(m_pcSlice->getIsDepth())
-  {
-    iCurrPosX  += ( iWidth  >> 1 );
-    iCurrPosY  += ( iHeight >> 1 );
-  }
-#if MTK_DIS_SPBIP8X4_H0205
-  for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
+    for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
 #else
-  for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getPartitionSize(uiPartAddr) != SIZE_2Nx2N) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
-#endif
-#else
-  for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
-#endif
-  {
-    // iLoopCan == 0 --> IvMC
-    // iLoopCan == 1 --> IvMCShift 
-
-    Int         iBaseCUAddr;
-    Int         iBaseAbsPartIdx;
-
-    Int offsetW = (iLoopCan == 0) ? 0 : ( ((iWidth /2)*4) + 4 );
-    Int offsetH = (iLoopCan == 0) ? 0 : ( ((iHeight/2)*4) + 4 );
-
-    Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
-    Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); 
-    pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
-
-    TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
-    if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
-    {
-      // Loop reference picture list of current slice (X in spec). 
-      for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )       
-      {
-        RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
-
-        Bool stopLoop = false;
-        // Loop reference picture list of candidate slice (Y in spec)
-        for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop)
-        {
-          RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
-          TComMvField cBaseMvField;
-          pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
-          Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
-          if (iBaseRefIdx >= 0)
-          {
-            Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
-            if (iBaseRefPOC != pcSlice->getPOC())    
-            {
-              for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
-              {
-                if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
-                {
-                  abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true;
-                  TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
-#if H_3D_NBDV 
-#if H_3D_IV_MERGE
-                  if( !bIsDepth )
-                  {
-#endif
-                    cMv.setIDVFlag   (true);
-                    cMv.setIDVHor    (cDv.getHor());                  
-                    cMv.setIDVVer    (cDv.getVer());  
-                    cMv.setIDVVId    (iViewIndex); 
-#if H_3D_IV_MERGE
-                  }
-#endif
-#endif
-#if !(NTT_BUG_FIX_TK54)
-                  clipMv( cMv );
-#endif
-                  paiPdmRefIdx  [ (uiCurrRefListId + (iLoopCan<<2)) ] = iPdmRefIdx;
-                  pacPdmMv      [ (uiCurrRefListId + (iLoopCan<<2)) ] = cMv;
-                  stopLoop = true;
-                  break;
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-#if H_3D_SPIVMP
-#if H_3D_FIX_DBBP_IVMP
-  for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
-#else
-  for(Int iLoopCan = ( 1 - m_pcSlice->getIsDepth() ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
-#endif
-#else
-  for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
-#endif
-  {
-    availableMcDc[(iLoopCan << 1)] = ( abPdmAvailable[(iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[1 + (iLoopCan<<2)] ? 2 : 0);
-  }
-
-#if SEC_ADAPT_DISABLE_IVMP
-  }
-#endif
+    for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
+#endif
+    {
+      availableMcDc[(iLoopCan << 1)] = ( abPdmAvailable[(iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[1 + (iLoopCan<<2)] ? 2 : 0);
+    }
+
+  }
 
   ////////////////////////////////
Index: trunk/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 964)
+++ trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 976)
@@ -70,9 +70,4 @@
   Bool        abMergeFlag[2];       // for two segments
   UChar       auhMergeIndex[2];     // for two segments
-#if !RWTH_DBBP_NO_SPU_H0057
-  Char        ahVSPFlag[2];         // for two segments
-  DisInfo     acDvInfo[2];          // for two segments
-#endif
-  
   PartSize    eVirtualPartSize;
   UInt        uiVirtualPartIndex;
@@ -195,7 +190,5 @@
   Bool*         m_pbSDCFlag;
   Pel*          m_apSegmentDCOffset[2];
-#if HS_DMM_SDC_PREDICTOR_UNIFY_H0108
   Pel          m_apDmmPredictor[2];
-#endif
 #endif
 #endif
@@ -238,5 +231,5 @@
 #endif
 
-#if ETRIKHU_CLEANUP_H0083
+#if H_3D_IV_MERGE
   TComMotionCand  m_mergCands[MRG_IVSHIFT+1];
   Int           m_baseListidc;
@@ -249,23 +242,9 @@
   Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
 #if H_3D_VSP
-#if ETRIKHU_CLEANUP_H0083
   Bool          xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount);
-#else
-  Bool          xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
-                             Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag, Int& iCount3DV, InheritedVSPDisInfo*  inheritedVSPDisInfo);
-#endif
 #endif
 #if H_3D_IV_MERGE
-#if ETRIKHU_CLEANUP_H0083
   Bool          xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int*   ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx ); 
-#else
-  Bool          xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int*   ivCandDir, TComMv* ivCandMv, 
-                               Int* ivCandRefIdx, Int posIvDC, Int* vspFlag, Int &iCount3DV, InheritedVSPDisInfo*  inheritedVSPDisInfo   ); 
-#endif
-#if ETRIKHU_CLEANUP_H0083
   Bool          xGetPosFirstAvailDmvCand( Int iCount, Int& iFirDispCand );
-#else
-  Bool          xGetPosFirstAvailDmvCand( Int iCount, TComMvField* pcMvFieldNeighbours, Int*  ivCandDir, Int posIvDC, Int* vspFlag, Int& iFirDispCand );
-#endif
 #endif
 
@@ -507,7 +486,4 @@
    
 #if H_3D
-#if !ETRIKHU_CLEANUP_H0083
-  Void          rightShiftMergeCandList( TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* iVSPIndexTrue, InheritedVSPDisInfo*  inheritedVSPDisInfo, UInt start, UInt num, Int &iCount3DV);
-#endif
   Bool          getDispforDepth  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
   Bool          getDispMvPredCan(UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDis, Int* iPdm );
@@ -532,8 +508,6 @@
 #if H_3D_SPIVMP
     , TComMvField* pcMFieldSP, UChar* puhInterDirSP
-#endif
-#if SEC_ADAPT_DISABLE_IVMP
+#endif    
     , Bool bICFlag
-#endif
     );   
 #endif
@@ -583,10 +557,7 @@
   Pel           getSDCSegmentDCOffset( UInt uiSeg, UInt uiPartIdx ) { return m_apSegmentDCOffset[uiSeg][uiPartIdx]; }
   Void          setSDCSegmentDCOffset( Pel pOffset, UInt uiSeg, UInt uiPartIdx) { m_apSegmentDCOffset[uiSeg][uiPartIdx] = pOffset; }
-#if HS_DMM_SDC_PREDICTOR_UNIFY_H0108
   Void          setDmmPredictor ( Pel pOffset, UInt uiSeg) { m_apDmmPredictor[uiSeg] = pOffset; }
   Pel           getDmmPredictor ( UInt uiSeg) { return m_apDmmPredictor[uiSeg]; }
-#endif
   UInt          getCtxSDCFlag          ( UInt   uiAbsPartIdx );
-  UInt          getCtxAngleFlag        ( UInt   uiAbsPartIdx );
 #endif
 #endif
@@ -666,5 +637,4 @@
   Bool          getAvailableFlagA0() { return m_bAvailableFlagA0;}
   Bool          getAvailableFlagB2() { return m_bAvailableFlagB2;}
-#if ETRIKHU_CLEANUP_H0083
   Void          initAvailableFlags() { m_bAvailableFlagA1 = m_bAvailableFlagB1 = m_bAvailableFlagB0 = m_bAvailableFlagA0 = m_bAvailableFlagB2 = 0;  }
   Void          buildMCL(TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
@@ -677,7 +647,4 @@
     , Int& numValidMergeCand
     );
-#else
-  Void          initAvailableFlags() { m_bAvailableFlagA1 = m_bAvailableFlagB1 = m_bAvailableFlagB0 = m_bAvailableFlagA0 = m_bAvailableFlagB2 = 0;  }
-#endif
   Void          getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1);
   Void          xGetInterMergeCandidates ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
@@ -686,15 +653,8 @@
 #endif
 #if H_3D_VSP
-#if !ETRIKHU_CLEANUP_H0083
-                                            , Int* vspFlag
-#endif
                                             , InheritedVSPDisInfo*  inheritedVSPDisInfo
 #endif
 #if H_3D_SPIVMP
-#if ETRIKHU_CLEANUP_H0083
                                             , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
-#else
-                                            , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
-#endif
 #endif
                                             , Int& numValidMergeCand, Int mrgCandIdx = -1
Index: trunk/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 964)
+++ trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 976)
@@ -198,5 +198,5 @@
 //! \}
 
-#if ETRIKHU_CLEANUP_H0083
+#if H_3D_IV_MERGE
 class TComMotionCand
 {
Index: trunk/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 964)
+++ trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 976)
@@ -55,5 +55,5 @@
 , m_bReconstructed                        (false)
 , m_bNeededForOutput                      (false)
-#if H_MV_HLS_7_VPS_P0300_27
+#if H_MV
 , m_bPicOutputFlag                        (false)
 #endif
Index: trunk/source/Lib/TLibCommon/TComPic.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComPic.h	(revision 964)
+++ trunk/source/Lib/TLibCommon/TComPic.h	(revision 976)
@@ -69,5 +69,5 @@
   Bool                  m_bReconstructed;
   Bool                  m_bNeededForOutput;
-#if H_MV_HLS_7_VPS_P0300_27
+#if H_MV
   Bool                  m_bPicOutputFlag;         // Semantics variable 
 #endif
@@ -178,5 +178,5 @@
   Void          setOutputMark (Bool b) { m_bNeededForOutput = b;     }
   Bool          getOutputMark ()       { return m_bNeededForOutput;  }
- #if H_MV_HLS_7_VPS_P0300_27
+ #if H_MV
   Void          setPicOutputFlag(Bool b) { m_bPicOutputFlag = b;      }
   Bool          getPicOutputFlag()       { return m_bPicOutputFlag ;  }
Index: trunk/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 964)
+++ trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 976)
@@ -500,8 +500,6 @@
   Pel* pDst = piPred;
   xAssignBiSegDCs( pDst, uiStride, biSegPattern, patternStride, segDC1, segDC2 );
-#if HS_DMM_SDC_PREDICTOR_UNIFY_H0108
   pcCU->setDmmPredictor(segDC1, 0);
   pcCU->setDmmPredictor(segDC2, 1);
-#endif
 
 #if H_3D_DIM_DMM
@@ -523,5 +521,5 @@
       Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC();
       Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC();
-#if MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085
+#if H_3D_ARP
       if(!pcCU->getARPW(PartAddr) && RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
 #else
@@ -647,18 +645,8 @@
   
   // start mapping process
-#if !MTK_DBBP_AMP_REM_H0072
-  Bool bAMPAvail = uiSize > 8;
-  Int matchedPartSum[6][2] = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}; // counter for each part size and boolean option
-  PartSize virtualPartSizes[6] = { SIZE_Nx2N, SIZE_2NxN, SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N };
-#else
   Int matchedPartSum[2][2] = {{0,0},{0,0}}; // counter for each part size and boolean option
   PartSize virtualPartSizes[2] = { SIZE_Nx2N, SIZE_2NxN};
-#endif
   
   UInt uiHalfSize = uiSize>>1;
-#if !MTK_DBBP_AMP_REM_H0072
-  UInt uiQuarterSize = uiSize>>2;
-#endif
-  
   for (Int y=0; y<uiSize; y+=iSubSample)
   {
@@ -691,49 +679,4 @@
         matchedPartSum[1][1-ucSegment]++;
       }
-      
-#if !MTK_DBBP_AMP_REM_H0072
-      if( bAMPAvail )
-      {
-        // SIZE_2NxnU
-        if(y<uiQuarterSize)  // top (1/4)
-        {
-          matchedPartSum[2][ucSegment]++;
-        }
-        else  // bottom (3/4)
-        {
-          matchedPartSum[2][1-ucSegment]++;
-        }
-        
-        // SIZE_2NxnD
-        if(y<(uiQuarterSize*3))  // top (3/4)
-        {
-          matchedPartSum[3][ucSegment]++;
-        }
-        else  // bottom (1/4)
-        {
-          matchedPartSum[3][1-ucSegment]++;
-        }
-        
-        // SIZE_nLx2N
-        if(x<uiQuarterSize)  // left (1/4)
-        {
-          matchedPartSum[4][ucSegment]++;
-        }
-        else  // right (3/4)
-        {
-          matchedPartSum[4][1-ucSegment]++;
-        }
-        
-        // SIZE_nRx2N
-        if(x<(uiQuarterSize*3))  // left (3/4)
-        {
-          matchedPartSum[5][ucSegment]++;
-        }
-        else  // right (1/4)
-        {
-          matchedPartSum[5][1-ucSegment]++;
-        }
-      }
-#endif
     }
     
@@ -745,9 +688,5 @@
   
   Int iMaxMatchSum = 0;
-#if !MTK_DBBP_AMP_REM_H0072
-  for(Int p=0; p<6; p++)  // loop over partition
-#else
   for(Int p=0; p<2; p++)  // loop over partition
-#endif
   {
     for( Int b=0; b<=1; b++ ) // loop over boolean options
@@ -859,9 +798,7 @@
   
   UInt  uiMaskStride= MAX_CU_SIZE;
-#if SEC_DBBP_FILTERING_H0104
   Pel  filSrc = 0;
   Pel* tmpTar = 0;
   tmpTar = (Pel *)xMalloc(Pel, uiWidth*uiHeight);
-#endif
   
   // backup pointer
@@ -877,26 +814,12 @@
       
       // filtering
-#if SEC_DBBP_FILTERING_H0104
       tmpTar[y*uiWidth+x] = piSrc[ucSegment][x];
-#else
-      Bool t = (y==0)?pMaskStart[(y+1)*uiMaskStride+x]:pMaskStart[(y-1)*uiMaskStride+x];
-      Bool l = (x==0)?pMaskStart[y*uiMaskStride+x+1]:pMaskStart[y*uiMaskStride+x-1];
-      Bool b = (y==uiHeight-1)?pMaskStart[(y-1)*uiMaskStride+x]:pMaskStart[(y+1)*uiMaskStride+x];
-      Bool r = (x==uiWidth-1)?pMaskStart[y*uiMaskStride+x-1]:pMaskStart[y*uiMaskStride+x+1];
-      
-      Bool bBlend = !((t&&l&&b&&r) || (!t&&!l&&!b&&!r));
-      piDst[x] = bBlend?((piSrc[0][x]+piSrc[1][x]+1)>>1):piSrc[ucSegment][x];
-#endif
     }
     
     piSrc[0]  += uiSrcStride;
     piSrc[1]  += uiSrcStride;
-#if !SEC_DBBP_FILTERING_H0104
-    piDst     += uiDstStride;
-#endif
     pMask     += uiMaskStride;
   }
   
-#if SEC_DBBP_FILTERING_H0104
   for (Int y=0; y<uiHeight; y++)
   {
@@ -933,5 +856,4 @@
   }
   if ( tmpTar    ) { xFree(tmpTar);             tmpTar        = NULL; }
-#endif
   
   // now combine chroma
@@ -944,10 +866,8 @@
   UInt  uiWidthC        = uiWidth >> 1;
   UInt  uiHeightC       = uiHeight >> 1;
-#if SEC_DBBP_FILTERING_H0104
   Pel  filSrcU = 0, filSrcV = 0;
   Pel* tmpTarU = 0, *tmpTarV = 0;
   tmpTarU = (Pel *)xMalloc(Pel, uiWidthC*uiHeightC);
   tmpTarV = (Pel *)xMalloc(Pel, uiWidthC*uiHeightC);
-#endif
   pMask = pMaskStart;
   
@@ -960,18 +880,6 @@
       
       // filtering
-#if SEC_DBBP_FILTERING_H0104
       tmpTarU[y*uiWidthC+x] = piSrcU[ucSegment][x];
       tmpTarV[y*uiWidthC+x] = piSrcV[ucSegment][x];
-#else
-      Bool t = (y==0)?pMaskStart[(y+1)*2*uiMaskStride+x*2]:pMaskStart[(y-1)*2*uiMaskStride+x*2];
-      Bool l = (x==0)?pMaskStart[y*2*uiMaskStride+(x+1)*2]:pMaskStart[y*2*uiMaskStride+(x-1)*2];
-      Bool b = (y==uiHeightC-1)?pMaskStart[(y-1)*2*uiMaskStride+x*2]:pMaskStart[(y+1)*2*uiMaskStride+x*2];
-      Bool r = (x==uiWidthC-1)?pMaskStart[y*2*uiMaskStride+(x-1)*2]:pMaskStart[y*2*uiMaskStride+(x+1)*2];
-      
-      Bool bBlend = !((t&&l&&b&&r) || (!t&&!l&&!b&&!r));
-      
-      piDstU[x] = bBlend?((piSrcU[0][x]+piSrcU[1][x]+1)>>1):piSrcU[ucSegment][x];
-      piDstV[x] = bBlend?((piSrcV[0][x]+piSrcV[1][x]+1)>>1):piSrcV[ucSegment][x];
-#endif
     }
     
@@ -980,12 +888,7 @@
     piSrcV[0]   += uiSrcStrideC;
     piSrcV[1]   += uiSrcStrideC;
-#if !SEC_DBBP_FILTERING_H0104
-    piDstU      += uiDstStrideC;
-    piDstV      += uiDstStrideC;
-#endif
     pMask       += 2*uiMaskStride;
   }
 
-#if SEC_DBBP_FILTERING_H0104
   for (Int y=0; y<uiHeightC; y++)
   {
@@ -1035,5 +938,4 @@
   if ( tmpTarU    ) { xFree(tmpTarU);             tmpTarU        = NULL; }
   if ( tmpTarV    ) { xFree(tmpTarV);             tmpTarV        = NULL; }
-#endif
 }
 #endif
@@ -2328,59 +2230,10 @@
   if (orgDC == false)
   {
-#if !HS_DMM_SDC_PREDICTOR_UNIFY_H0108
-    if ( getDimType(uiIntraMode) == DMM1_IDX )
-    {
-      UChar ucSegmentLT = pMask[0];
-      UChar ucSegmentRT = pMask[uiSize-1];
-      UChar ucSegmentLB = pMask[uiMaskStride * (uiSize-1)]; 
-      UChar ucSegmentRB = pMask[uiMaskStride * (uiSize-1) + (uiSize-1)]; 
-
-      rpSegMeans[ucSegmentLT] = pOrig[0];
-      rpSegMeans[ucSegmentRT] = pOrig[uiSize-1];
-      rpSegMeans[ucSegmentLB] = pOrig[uiStride * (uiSize-1) ];
-      rpSegMeans[ucSegmentRB] = pOrig[uiStride * (uiSize-1) + (uiSize-1) ];
-    }
-    else if( getDimType( uiIntraMode ) == DMM4_IDX )
-    {
-      Pel *ptmpOrig = pOrig;
-      Bool *ptmpMask = pMask, bBreak = false;
-      UChar ucSegment = ptmpMask? (UChar) ptmpMask[0] : 0;
-      UChar bFirstSeg = ucSegment;
-
-      rpSegMeans[ucSegment] = ptmpOrig[0];
-      for ( Int y = 0; y < uiSize; y++ )
-      {
-        for ( Int x = 0; x < uiSize; x++ )
-        {
-          ucSegment = ptmpMask[x];
-          assert( ucSegment < uiNumSegments );
-
-          if( bFirstSeg != ucSegment )
-          {
-            rpSegMeans[ucSegment] = ptmpOrig[x];
-            bBreak = true;
-            break;
-          }
-        }
-
-        if( bBreak )
-        {
-          break;
-        }
-
-        ptmpOrig  += uiStride;
-        ptmpMask  += uiMaskStride;
-      }
-    }
-    else
-#endif
-    {
-      Pel* pLeftTop = pOrig;
-      Pel* pRightTop = pOrig + (uiSize-1);
-      Pel* pLeftBottom = (pOrig+ (uiStride*(uiSize-1)));
-      Pel* pRightBottom = (pOrig+ (uiStride*(uiSize-1)) + (uiSize-1));
-
-      rpSegMeans[0] = (*pLeftTop + *pRightTop + *pLeftBottom + *pRightBottom + 2)>>2;
-    }
+    Pel* pLeftTop = pOrig;
+    Pel* pRightTop = pOrig + (uiSize-1);
+    Pel* pLeftBottom = (pOrig+ (uiStride*(uiSize-1)));
+    Pel* pRightBottom = (pOrig+ (uiStride*(uiSize-1)) + (uiSize-1));
+
+    rpSegMeans[0] = (*pLeftTop + *pRightTop + *pLeftBottom + *pRightBottom + 2)>>2;
     return;
   }
Index: trunk/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComRom.cpp	(revision 964)
+++ trunk/source/Lib/TLibCommon/TComRom.cpp	(revision 976)
@@ -360,5 +360,5 @@
 Char  g_aucConvertToBit  [ MAX_CU_SIZE+1 ];
 
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
+#if H_3D_IC
 UInt g_aICEnableCANDIDATE[10] = { 0, };
 UInt g_aICEnableNUM[ 10 ] = { 0, };
Index: trunk/source/Lib/TLibCommon/TComRom.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComRom.h	(revision 964)
+++ trunk/source/Lib/TLibCommon/TComRom.h	(revision 976)
@@ -189,8 +189,8 @@
 extern       Char   g_aucConvertToBit  [ MAX_CU_SIZE+1 ];   // from width to log2(width)-2
 
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
+#if H_3D_IC
 extern UInt g_aICEnableCANDIDATE[10];
 extern UInt g_aICEnableNUM[ 10 ]; //10 layers
-extern Int g_lastlayer;
+extern Int  g_lastlayer;
 #endif
 
Index: trunk/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 964)
+++ trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 976)
@@ -48,5 +48,5 @@
 TComSlice::TComSlice()
 : m_iPPSId                        ( -1 )
-#if H_MV_HLS_8_POC_Q0142_32
+#if H_MV
 , m_slicePicOrderCntLsb           ( 0 )
 #endif
@@ -1863,5 +1863,5 @@
 #endif
 {
-#if H_MV_HLS_8_SYN_Q0041_03
+#if H_MV
   m_vpsBaseLayerInternalFlag = true; 
 #endif
@@ -1883,10 +1883,6 @@
   m_vpsNumProfileTierLevelMinus1 = -1; 
     
-#if H_MV_HLS_8_SYN_39_19
   m_numAddLayerSets              = 0;   
   m_numAddOlss                   = 0; 
-#else
-  m_numAddLayerSets              = -1;   
-#endif
   m_defaultOutputLayerIdc     = 0; 
   
@@ -1902,15 +1898,10 @@
   }
 
-#if H_MV_HLS_8_PMS_Q0195_20
   m_repFormatIdxPresentFlag = false; 
-#endif
   m_maxOneActiveRefLayerFlag = false; 
   m_directDepTypeLenMinus2   = 0;         
   
 
-#if H_MV_HLS_8_RPS_Q0100_36
   m_vpsExtensionFlag = true; 
-#endif
-  m_avcBaseLayerFlag = false;
   m_vpsNonVuiExtensionLength = 0;
   m_splittingFlag    = false;
@@ -2032,10 +2023,7 @@
   }
 
-
-#if H_MV_HLS_8_PMS_Q0195_20
   //The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive.
   assert( getVpsNumRepFormatsMinus1() >= 0 ); 
   assert( getVpsNumRepFormatsMinus1() <= 255 ); 
-#endif
 
   return true; 
@@ -2083,5 +2071,4 @@
   }
 
-#if H_MV_HLS_8
   for (Int i = 0 ; i < MAX_NUM_LAYER_IDS; i++ )
   {
@@ -2096,5 +2083,4 @@
     }
   }
-
 
   for( Int i = 0; i  <=  getMaxLayersMinus1(); i++ )
@@ -2107,5 +2093,4 @@
     }
   }
-
 
   for( Int i = 0; i <= getMaxLayersMinus1(); i++ )  // Bug in spec "<" instead of "<=" 
@@ -2149,5 +2134,4 @@
     m_numIndependentLayers = k;
   }
-#endif
 }
 
@@ -2314,9 +2298,5 @@
 Int    TComVPS::getNumOutputLayerSets() 
 {
-#if H_MV_HLS_8_SYN_39_19
   return getNumAddOlss() + getNumLayerSets(); 
-#else
-  return getNumAddLayerSets() + getVpsNumLayerSetsMinus1() + 1; 
-#endif
 }
 
@@ -2384,7 +2364,5 @@
     }
   }  
-#if H_MV_HLS_8_PMS_Q0165_18
   assert( getNumOutputLayersInOutputLayerSet( i ) > 0 ); 
-#endif
 }
 
@@ -2420,20 +2398,12 @@
 {
   Int maxSLMinus1 = 0; 
-#if H_MV_HLS_8_MIS_Q0102_30
   for( Int k = 0; k < getNumLayersInIdList( i ); k++ )
   {
     Int lId = m_layerSetLayerIdList[i][k];
-#else  
-  Int optLsIdx    = olsIdxToLsIdx( i );
-
-  for( Int k = 0; k < getNumLayersInIdList( optLsIdx ); k++ )
-  {
-    Int lId = m_layerSetLayerIdList[optLsIdx][k];
-#endif
     maxSLMinus1 = std::max( maxSLMinus1, getSubLayersVpsMaxMinus1( getLayerIdInVps( lId ) ));
   }
   return maxSLMinus1;
 }
-#if H_MV_HLS_8_RPS_Q0100_36
+
 Void TComVPS::inferDbpSizeLayerSetZero( TComSPS* sps, Bool encoder )
 {
@@ -2458,5 +2428,50 @@
   }
 }
-#endif
+
+Bool TComVPS::getAltOutputLayerFlagVar( Int i )
+{
+  // Semantics variable not syntax element !
+
+  Bool altOptLayerFlag = false;     
+  if ( i > 0 && getNumOutputLayersInOutputLayerSet( i ) == 1 && 
+    getNumDirectRefLayers( getOlsHighestOutputLayerId( i ) ) > 0 )
+  {
+    altOptLayerFlag = getAltOutputLayerFlag( i ); 
+  }
+  return altOptLayerFlag;
+}
+
+Int TComVPS::getMaxNumPics( Int layerId )
+{
+  Int maxNumPics = MAX_INT; 
+  for( Int olsIdx = 0; olsIdx < getNumOutputLayerSets(); olsIdx++)
+  {
+    Int lsIdx = olsIdxToLsIdx( olsIdx ); 
+    for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ )
+    {
+      if( getLayerSetLayerIdList(lsIdx, j ) ==  layerId )
+      {
+        Int maxSL = getMaxSubLayersInLayerSetMinus1( lsIdx ); 
+        maxNumPics = std::min( maxNumPics, getDpbSize()->getMaxVpsDecPicBufferingMinus1( olsIdx , j,  maxSL ) );
+      }
+    }
+  }
+  assert( maxNumPics != MAX_INT ); 
+  return maxNumPics;
+}
+
+Void TComVPS::xSetRefLayerFlags( Int currLayerId )
+{
+  for( Int j = 0; j < getNumDirectRefLayers( currLayerId ); j++ )
+  {
+    Int refLayerId = m_refLayerId[ currLayerId ][ j ];
+    m_recursiveRefLayerFlag[ currLayerId ][ refLayerId ] = 1;
+    for( Int k = 0; k < MAX_NUM_LAYER_IDS; k++ )
+    {
+      m_recursiveRefLayerFlag[ currLayerId ][ k ] = m_recursiveRefLayerFlag[ currLayerId ][ k ]  ||  m_recursiveRefLayerFlag[ refLayerId ][ k ];
+    }
+  }
+}
+
 #endif // H_MV
 
@@ -2530,11 +2545,4 @@
   ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag));
 #if H_MV
-#if !H_MV_HLS_8_SPS_NODOC_48
-  m_spsExtensionPresentFlag = false; 
-  for( Int i = 0; i < PS_EX_T_MAX_NUM; i++ ) 
-  {
-    m_spsExtensionTypeFlag[ i ] = false;
-  }
-#else 
   m_spsRangeExtensionsFlag     = false;
   m_spsMultilayerExtensionFlag = false;
@@ -2544,5 +2552,4 @@
 #else
   m_spsExtension6bits          = 0;
-#endif
 #endif
 
@@ -2726,5 +2733,4 @@
 
 #if H_MV
-#if H_MV_HLS_8_SPS_NODOC_48
   m_ppsRangeExtensionsFlag     = false;
   m_ppsMultilayerExtensionFlag = false;
@@ -2734,10 +2740,4 @@
   m_pps3dExtensionFlag         = false;
   m_ppsExtension5bits          = 0;
-#endif
-#else
-  for( Int i = 0; i < PS_EX_T_MAX_NUM; i++ ) 
-  {
-    m_ppsExtensionTypeFlag[ i ] = false;
-  }
 #endif
 #endif
@@ -2984,4 +2984,55 @@
   }
 }
+
+Void TComSPS::inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder )
+{
+  const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx )); 
+
+  if (getLayerId() > 0 )
+  {
+    Int layerIdx = 0;         
+    while (layerIdx < (Int) targetDecLayerIdList.size() )
+    {
+      if ( targetDecLayerIdList[layerIdx] == currLayerId )
+      { 
+        break; 
+      }
+      layerIdx++; 
+    }
+
+    assert( layerIdx < (Int) targetDecLayerIdList.size() ); 
+
+    for (Int i = 0; i <= getSpsMaxSubLayersMinus1(); i++ ) 
+    {
+      Int maxDecPicBufferingMinus1 = vps->getDpbSize()->getMaxVpsDecPicBufferingMinus1( targetOptLayerSetIdx, layerIdx, i ) ; 
+
+      if ( encoder )
+      {
+        assert( getMaxDecPicBuffering( i ) - 1 == maxDecPicBufferingMinus1 ); 
+      }
+      else
+      {
+        setMaxDecPicBuffering(i, maxDecPicBufferingMinus1 + 1 ); 
+      }
+    }
+  }
+}
+
+Void TComSPS::checkRpsMaxNumPics( TComVPS* vps, Int currLayerId )
+{
+  // In spec, when rps is in SPS, nuh_layer_id of SPS is used instead 
+  // of nuh_layer_id of slice (currLayerId), this seems to be a bug.
+
+  for (Int i = 0; i < getRPSList()->getNumberOfReferencePictureSets(); i++ )
+  {
+    TComReferencePictureSet* rps = getRPSList()->getReferencePictureSet( i ); 
+    if ( !rps->getInterRPSPrediction() )
+    {
+      rps->checkMaxNumPics( vps->getVpsExtensionFlag(), vps->getMaxNumPics( currLayerId ), 
+        getLayerId(), getMaxDecPicBuffering( getSpsMaxSubLayersMinus1() ) - 1 );  
+    }
+  }
+}
+
 #endif
 
@@ -3133,4 +3184,19 @@
   printf("}\n");
 }
+#if H_MV
+Void TComReferencePictureSet::checkMaxNumPics( Bool vpsExtensionFlag, Int maxNumPics, Int nuhLayerId, Int spsMaxDecPicBufferingMinus1 )
+{
+  assert( getNumberOfPictures() >= 0 ); 
+  if ( nuhLayerId == 0 )
+  {
+    assert( getNumberOfPictures() <= spsMaxDecPicBufferingMinus1 ); 
+  }
+
+  if ( vpsExtensionFlag )
+  {
+    assert( getNumberOfPictures() <= maxNumPics );
+  }
+}
+#endif
 
 TComRPSList::TComRPSList()
@@ -3279,60 +3345,4 @@
 }
 
-#if !H_MV_HLS_8_DBP_NODOC_42
-Void TComSlice::markIvRefPicsAsUnused( TComPicLists* ivPicLists, std::vector<Int> targetDecLayerIdSet, TComVPS* vps, Int curLayerId, Int curPoc )
-{
-  // Fill targetDecLayerIdSet with all layers if empty (at encoder side) 
-  if (targetDecLayerIdSet.size() == 0 )    
-  {
-    for ( Int layerIdInVps = 0; layerIdInVps <= vps->getMaxLayersMinus1(); layerIdInVps++ )
-    {
-      targetDecLayerIdSet.push_back( vps->getLayerIdInNuh( layerIdInVps ) ); 
-    }
-  }     
-
-  Int numTargetDecLayers = (Int) targetDecLayerIdSet.size(); 
-  Int latestDecIdx; 
-  for ( latestDecIdx = 0; latestDecIdx < numTargetDecLayers; latestDecIdx++)
-  {
-    if ( targetDecLayerIdSet[ latestDecIdx ] == curLayerId )
-    {
-      break; 
-    }        
-  }        
-
-  for( Int i = 0; i <= latestDecIdx; i++ ) 
-  {
-    if ( vps->nuhLayerIdIncluded( targetDecLayerIdSet[ i ] ) )
-    {
-      TComPic* pcPic = ivPicLists->getPic( targetDecLayerIdSet[ i ], curPoc ); 
-      if ( pcPic )
-      {
-        if( pcPic->getSlice(0)->isReferenced() && pcPic->getSlice(0)->getTemporalLayerNonReferenceFlag() ) 
-        { 
-          Bool remainingInterLayerReferencesFlag = false; 
-          for( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
-          { 
-            TComVPS* vpsSlice = pcPic->getSlice(0)->getVPS(); 
-            if ( vps->nuhLayerIdIncluded( targetDecLayerIdSet[ j ] ) )
-            {
-              for( Int k = 0; k < vpsSlice->getNumDirectRefLayers( targetDecLayerIdSet[ j ] ); k++ )
-              {
-                if ( targetDecLayerIdSet[ i ] == vpsSlice->getRefLayerId( targetDecLayerIdSet[ j ],  k  ) )
-                {
-                  remainingInterLayerReferencesFlag = true;
-                }
-              }
-            }
-          }
-          if( !remainingInterLayerReferencesFlag )
-          {
-            pcPic->getSlice(0)->setReferenced( false );                   
-          }
-        }
-      }
-    }
-  }
-}
-#endif
 Void TComSlice::printRefPicList()
 {  
@@ -3351,23 +3361,9 @@
 Void TComSlice::markCurrPic( TComPic* currPic )
 {
-
-#if !H_MV_HLS_8_DBP_NODOC_42
-  if ( !currPic->getSlice(0)->getDiscardableFlag() )
-  {
-#endif
-    currPic->getSlice(0)->setReferenced( true ) ; 
-    currPic->setIsLongTerm( false ); 
-#if !H_MV_HLS_8_DBP_NODOC_42
-  }
-  else
-  {
-    currPic->getSlice(0)->setReferenced( false ) ; 
-  }
-#endif
-
-#if H_MV_HLS_7_VPS_P0300_27
+  currPic->getSlice(0)->setReferenced( true ) ; 
+  currPic->setIsLongTerm( false ); 
+
   currPic->setReconMark( true );
   currPic->setPicOutputFlag( currPic->getSlice(0)->getPicOutputFlag() );
-#endif
 }
 
@@ -3403,11 +3399,6 @@
   Int refLayerIdx = vps->getLayerIdInVps( vps->getRefLayerId( getLayerId(), i ) ); 
 
-#if H_MV_HLS_8_RPS_Q0060_17
   Bool refLayerPicFlag = ( vps->getSubLayersVpsMaxMinus1( refLayerIdx ) >=  getTLayer() )  && ( getTLayer() == 0  ) &&
     ( vps->getMaxTidIlRefPicsPlus1( refLayerIdx, vps->getLayerIdInVps( getLayerId() )) > getTLayer() ); 
-#else
-  Bool refLayerPicFlag = ( vps->getSubLayersVpsMaxMinus1( refLayerIdx ) >=  getTLayer() )  && 
-    ( vps->getMaxTidIlRefPicsPlus1( refLayerIdx, vps->getLayerIdInVps( getLayerId() )) > getTLayer() ); 
-#endif
 
   return refLayerPicFlag;       
@@ -3541,11 +3532,6 @@
 #endif
 #if H_3D_IC
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
 Void TComSlice::xSetApplyIC(Bool bUseLowLatencyICEnc)
-#else
-Void TComSlice::xSetApplyIC()
-#endif
-{
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
+{
   if(bUseLowLatencyICEnc)
   {
@@ -3592,5 +3578,5 @@
         Double ratio=Double(g_aICEnableNUM[refLayer])/Double(g_aICEnableCANDIDATE[refLayer]);
 
-        if( ratio > MTK_LOW_LATENCY_IC_ENCODING_THRESHOLD_H0086)
+        if( ratio > IC_LOW_LATENCY_ENCODING_THRESHOLD)
 {
           m_bApplyIC=true;
@@ -3608,5 +3594,4 @@
   else
   {
-#endif
   Int iMaxPelValue = ( 1 << g_bitDepthY ); 
   Int *aiRefOrgHist;
@@ -3682,7 +3667,5 @@
   aiCurrHist = NULL;
   aiRefOrgHist = NULL;
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
   }//if(bUseLowLatencyICEnc)
-#endif
 }
 #endif
@@ -3774,5 +3757,5 @@
 
 #if H_3D_DDD
-    InitializeDDDPara( vps->getCamParPrecision(), codScale[ i ], codOffset[ i ], i );
+    initializeDDDPara( vps->getCamParPrecision(), codScale[ i ], codOffset[ i ], i );
 #endif
   }
@@ -3782,5 +3765,5 @@
 
 #if H_3D_DDD
-Void TComSlice::InitializeDDDPara( UInt uiCamParsCodedPrecision, Int  iCodedScale,Int  iCodedOffset, Int iBaseViewIdx )
+Void TComSlice::initializeDDDPara( UInt uiCamParsCodedPrecision, Int  iCodedScale,Int  iCodedOffset, Int iBaseViewIdx )
 {
     UInt uiViewId     = getViewIndex();
@@ -3839,4 +3822,45 @@
 
     return;
+}
+
+
+#endif
+
+#if H_MV
+Void TComSlice::checkCrossLayerBlaFlag()
+{
+  // cross_layer_bla_flag shall be equal to 0 for pictures with nal_unit_type not equal to IDR_W_RADL or IDR_N_LP or with nuh_layer_id not equal to 0.
+  if ( getLayerId() != 0 || getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
+  {
+    assert( m_crossLayerBlaFlag == 0 ); 
+  }
+}
+
+Bool TComSlice::inferPocMsbValPresentFlag()
+{
+  Bool pocMsbValPresentFlag; 
+  if( getSliceSegmentHeaderExtensionLength() == 0 ) 
+  {
+    pocMsbValPresentFlag = false; 
+  }
+  else if ( getPocMsbValRequiredFlag() )
+  {
+    pocMsbValPresentFlag = true; 
+  }
+  else
+  {
+    pocMsbValPresentFlag = false; 
+  }
+
+  return pocMsbValPresentFlag;
+}
+
+
+#endif
+
+#if H_3D_DBBP
+Int TComSlice::getDepthFromDV( Int iDV, Int iBaseViewIdx )
+{
+  return ClipY(( iDV * m_aiDDDInvScale[ iBaseViewIdx ] + m_aiDDDInvOffset[ iBaseViewIdx ] ) >> m_aiDDDShift[ iBaseViewIdx ]);
 }
 #endif
@@ -4331,4 +4355,17 @@
 }
 
+Void TComVpsVuiBspHrdParameters::checkBspCombHrdAndShedIdx( TComVPS* vps, Int h, Int i, Int j )
+{
+  // bsp_comb_hrd_idx
+  assert( getBspCombSchedIdx(h, i, j ) >= 0 );
+  assert( getBspCombSchedIdx(h, i, j ) <= getVpsNumBspHrdParametersMinus1() );
+
+  // bsp_comb_sched_idx
+  assert( getBspCombSchedIdx(h, i, j ) >= 0 );
+
+  //* This check needs to activated,  when HighestTid is available here    
+  //  assert(  getBspCombSchedIdx(h, i, j ) <= vps->getHrdParameters( getBspCombHrdIdx( h, i, j ) )->getCpbCntMinus1( highestTid ) );
+}
+
 Void TComVUI::inferVideoSignalInfo( TComVPS* vps, Int layerIdCurr )
 {
@@ -4370,3 +4407,16 @@
   }
 }
-#endif
+
+Void Window::scaleOffsets( Int scal )
+{
+  if (! m_scaledFlag )
+  {
+    m_scaledFlag         = true; 
+    m_winLeftOffset     *= scal; 
+    m_winRightOffset    *= scal; 
+    m_winTopOffset      *= scal; 
+    m_winBottomOffset   *= scal; 
+  }
+}
+#endif
+
Index: trunk/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.h	(revision 964)
+++ trunk/source/Lib/TLibCommon/TComSlice.h	(revision 976)
@@ -54,7 +54,5 @@
 class TComPicLists; 
 class TComVPS; 
-#if H_MV_HLS_8_RPS_Q0100_36
 class TComSPS; 
-#endif
 #endif
 // ====================================================================================================================
@@ -130,18 +128,6 @@
   Void printDeltaPOC();
 
-#if H_MV_HLS_8_RPS_Q0100_36
-  Void checkMaxNumPics( Bool vpsExtensionFlag, Int maxNumPics, Int nuhLayerId, Int spsMaxDecPicBufferingMinus1 )
-  {
-    assert( getNumberOfPictures() >= 0 ); 
-    if ( nuhLayerId == 0 )
-    {
-      assert( getNumberOfPictures() <= spsMaxDecPicBufferingMinus1 ); 
-    }
-
-    if ( vpsExtensionFlag )
-    {
-      assert( getNumberOfPictures() <= maxNumPics );
-    }
-  }
+#if H_MV
+  Void checkMaxNumPics( Bool vpsExtensionFlag, Int maxNumPics, Int nuhLayerId, Int spsMaxDecPicBufferingMinus1 );
 #endif
 };
@@ -479,22 +465,11 @@
   Void setBspCombHrdIdx( Int h, Int i, Int j, Int  val ) { m_bspCombHrdIdx[h][i][j] = val; } 
   Int  getBspCombHrdIdx( Int h, Int i, Int j ) { return m_bspCombHrdIdx[h][i][j]; } 
-#if H_MV_HLS_8_HRD_Q0101_04
   Int  getBspCombHrdIdxLen() { return gCeilLog2( getVpsNumBspHrdParametersMinus1() + 1);  }; 
-  Void checkBspCombHrdAndShedIdx( TComVPS* vps, Int h, Int i, Int j )  
-  {
-    // bsp_comb_hrd_idx
-    assert( getBspCombSchedIdx(h, i, j ) >= 0 );
-    assert( getBspCombSchedIdx(h, i, j ) <= getVpsNumBspHrdParametersMinus1() );
-
-    // bsp_comb_sched_idx
-    assert( getBspCombSchedIdx(h, i, j ) >= 0 );
-
-    //* This check needs to activated,  when HighestTid is available here    
-    //  assert(  getBspCombSchedIdx(h, i, j ) <= vps->getHrdParameters( getBspCombHrdIdx( h, i, j ) )->getCpbCntMinus1( highestTid ) );
-  }
-#endif
+
 
   Void setBspCombSchedIdx( Int h, Int i, Int j, Int  val ) { m_bspCombSchedIdx[h][i][j] = val; } 
   Int  getBspCombSchedIdx( Int h, Int i, Int j ) { return m_bspCombSchedIdx[h][i][j]; } 
+
+  Void checkBspCombHrdAndShedIdx( TComVPS* vps, Int h, Int i, Int j );
 
   Void setHrdParametermeters( Int k, TComHRD* val  ) {  m_hrdParameters[k] = val; }; 
@@ -695,5 +670,5 @@
 private:
   Int         m_VPSId;
-#if H_MV_HLS_8_SYN_Q0041_03
+#if H_MV
   Bool        m_vpsBaseLayerInternalFlag;
 #endif
@@ -736,9 +711,7 @@
   TimingInfo  m_timingInfo;
 #if H_MV
-  #if H_MV_HLS_8_RPS_Q0100_36
   Bool        m_vpsExtensionFlag;
-#endif
+
   /// VPS EXTENSION SYNTAX ELEMENTS
-  Bool        m_avcBaseLayerFlag;
   Int         m_vpsNonVuiExtensionLength;
   Bool        m_splittingFlag;
@@ -761,8 +734,7 @@
 
   Int         m_numAddLayerSets;    
-#if H_MV_HLS_8_SYN_39_19
   Int         m_highestLayerIdxPlus1     [MAX_VPS_ADD_OUTPUT_LAYER_SETS][MAX_NUM_LAYERS];
   Int         m_numAddOlss;
-#endif
+
   Int         m_defaultOutputLayerIdc;
 
@@ -802,5 +774,4 @@
   Int         m_refLayerId               [MAX_NUM_LAYERS][MAX_NUM_LAYERS];  
 
-#if H_MV_HLS_8
   Int         m_numRefLayers             [MAX_NUM_LAYER_IDS]; 
   Int         m_numPredictedLayers       [MAX_NUM_LAYERS]; 
@@ -810,14 +781,5 @@
   Int         m_treePartitionLayerIdList [MAX_NUM_LAYERS][MAX_NUM_LAYER_IDS];
   Bool        m_recursiveRefLayerFlag    [MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS]; 
-#else
-
-  Int         m_numSamplePredRefLayers   [MAX_NUM_LAYERS];
-  Bool        m_samplePredEnabledFlag    [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
-  Int         m_samplePredRefLayerId     [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
-
-  Int         m_numMotionPredRefLayers   [MAX_NUM_LAYERS];
-  Bool        m_motionPredEnabledFlag    [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
-  Int         m_motionPredRefLayerId     [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
-#endif
+
   Int         m_viewIndex                [MAX_NUM_LAYERS   ];
   
@@ -828,19 +790,5 @@
 
   Int         xGetDimBitOffset( Int j );
-
-#if H_MV_HLS_8
-  Void xSetRefLayerFlags( Int currLayerId )
-  { 
-    for( Int j = 0; j < getNumDirectRefLayers( currLayerId ); j++ )
-    {
-      Int refLayerId = m_refLayerId[ currLayerId ][ j ];
-      m_recursiveRefLayerFlag[ currLayerId ][ refLayerId ] = 1;
-      for( Int k = 0; k < MAX_NUM_LAYER_IDS; k++ )
-      {
-        m_recursiveRefLayerFlag[ currLayerId ][ k ] = m_recursiveRefLayerFlag[ currLayerId ][ k ]  ||  m_recursiveRefLayerFlag[ refLayerId ][ k ];
-      }
-    }
-  }
-#endif
+  Void        xSetRefLayerFlags( Int currLayerId );
   // VPS EXTENSION 2 SYNTAX ELEMENTS
 #if H_3D_ARP
@@ -902,5 +850,5 @@
   Void    setVPSId       (Int i)              { m_VPSId = i;             }
 
-#if H_MV_HLS_8_SYN_Q0041_03
+#if H_MV
   Void    setVpsBaseLayerInternalFlag( Bool flag ) { m_vpsBaseLayerInternalFlag = flag; } 
   Bool    getVpsBaseLayerInternalFlag(  )          { return m_vpsBaseLayerInternalFlag; } 
@@ -957,13 +905,7 @@
   TimingInfo* getTimingInfo() { return &m_timingInfo; }
 #if H_MV
-
-#if H_MV_HLS_8_RPS_Q0100_36
   Void    setVpsExtensionFlag( Bool flag )                                 { m_vpsExtensionFlag = flag; } 
   Bool    getVpsExtensionFlag(  )                                          { return m_vpsExtensionFlag; } 
-#endif
-#if !H_MV_HLS_8_SYN_Q0041_03
-  Void    setAvcBaseLayerFlag( Bool val )                                  { m_avcBaseLayerFlag = val;  }
-  Bool    getAvcBaseLayerFlag()                                            { return m_avcBaseLayerFlag; } 
-#endif 
+
   Void    setVpsNonVuiExtensionLength( Int  val )                          { m_vpsNonVuiExtensionLength = val; } 
   Int     getVpsNonVuiExtensionLength(  )                                  { return m_vpsNonVuiExtensionLength; } 
@@ -1026,5 +968,4 @@
   Int     getNumAddLayerSets( )                                            { return m_numAddLayerSets; } 
   
-#if H_MV_HLS_8_SYN_39_19
   Void    setHighestLayerIdxPlus1( Int i, Int j, Int  val )                { m_highestLayerIdxPlus1[i][j] = val; } 
   Int     getHighestLayerIdxPlus1( Int i, Int j )                          { return m_highestLayerIdxPlus1[i][j]; } 
@@ -1032,5 +973,4 @@
   Void    setNumAddOlss( Int  val )                                        { m_numAddOlss = val; } 
   Int     getNumAddOlss(  )                                                { return m_numAddOlss; } 
-#endif
 
   Void    setDefaultOutputLayerIdc( Int  val )                             { m_defaultOutputLayerIdc = val; } 
@@ -1060,7 +1000,5 @@
   Int     getVpsRepFormatIdx( Int i )                                      { return m_vpsRepFormatIdx[i]; } 
 
-#if H_MV_HLS_8_PMS_Q0195_20
   Int     inferVpsRepFormatIdx( Int i )                                    { return std::min( i, getVpsNumRepFormatsMinus1()  );  }
-#endif
 
   Void    setRepFormat( Int i, TComRepFormat* val )                        { m_repFormat[i] = val;  }
@@ -1077,9 +1015,7 @@
   Void    setDpbSize( TComDpbSize* val )                                   { assert( m_dpbSize != 0 ); m_dpbSize = val; } 
   TComDpbSize* getDpbSize( )                                               { return m_dpbSize;} 
-#if H_MV_HLS_8_RPS_Q0100_36
+  
   Void    inferDbpSizeLayerSetZero( TComSPS* sps, Bool encoder );
-#endif
-
-
+  
   Void    setPocLsbNotPresentFlag( Int i, Bool flag )                      { m_pocLsbNotPresentFlag[i] = flag; } 
   Bool    getPocLsbNotPresentFlag( Int i )                                 { return m_pocLsbNotPresentFlag[i]; } 
@@ -1116,5 +1052,4 @@
   Int     getRefLayerId        ( Int layerIdInNuh, Int idx );; 
 
-#if H_MV_HLS_8
   Int     getNumRefLayers            ( Int i )        { return m_numRefLayers[i]; } 
   Int     getNumPredictedLayers      ( Int i )        { return m_numPredictedLayers[i]; } 
@@ -1124,10 +1059,6 @@
   Int     getTreePartitionLayerIdList( Int i, Int j ) { return m_treePartitionLayerIdList[i][j]; } 
   Bool    getRecursiveRefLayerFlag   ( Int i, Int j ) { return m_recursiveRefLayerFlag[i][j]; } 
-
-#endif
-
-#if H_MV_HLS_8_SYN_39_19
   Int     getNumLayerSets( )                                               { return getVpsNumLayerSetsMinus1() + 1 + getNumAddLayerSets();  };  
-#endif
+  
   Bool    checkVPSExtensionSyntax(); 
   Int     scalTypeToScalIdx   ( ScalabilityType scalType );
@@ -1137,12 +1068,8 @@
 
   Int     getNumLayersInIdList ( Int lsIdx );
-#if H_MV_HLS_8_RPS_Q0100_36
   Int     getLayerSetLayerIdList(Int lsIdx, Int j )                       { return m_layerSetLayerIdList[ lsIdx ][ j ]; }; 
-#endif
 
   Int     getNumOutputLayerSets() ;   
-#if !H_MV_HLS_8_DBP_NODOC_42
-  Int     getNumSubDpbs( Int i )                                           { return getNumLayersInIdList( i ); };  
-#endif
+
   Bool    isOutputLayer( Int outLayerSetIdx, Int layerIdInNuh );   
   Void    deriveLayerSetLayerIdList();
@@ -1160,23 +1087,7 @@
 
   Int     getMaxSubLayersInLayerSetMinus1( Int i );
-
-#if H_MV_HLS_8_SYN_39_19
   Int     getHighestLayerIdxPlus1Len( Int j )                                   { return gCeilLog2( getNumLayersInTreePartition( j ) + 1 );   }; 
-#endif
-
-  
-#if H_MV_HLS_7_VPS_P0300_27
-  Bool     getAltOutputLayerFlagVar( Int i )
-  {  // Semantics variable not syntax element !
-
-    Bool altOptLayerFlag = false;     
-    if ( i > 0 && getNumOutputLayersInOutputLayerSet( i ) == 1 && 
-      getNumDirectRefLayers( getOlsHighestOutputLayerId( i ) ) > 0 )
-    {
-      altOptLayerFlag = getAltOutputLayerFlag( i ); 
-    }
-    return altOptLayerFlag; 
-  };
-#endif
+
+  Bool     getAltOutputLayerFlagVar( Int i );;
 
   // inference
@@ -1186,24 +1097,5 @@
   // helpers
   Bool    getInDirectDependencyFlag( Int depLayeridInVps, Int refLayeridInVps, Int depth = 0 );
-#if H_MV_HLS_8_RPS_Q0100_36
-  Int     getMaxNumPics( Int layerId )
-  {    
-    Int maxNumPics = MAX_INT; 
-    for( Int olsIdx = 0; olsIdx < getNumOutputLayerSets(); olsIdx++)
-    {
-      Int lsIdx = olsIdxToLsIdx( olsIdx ); 
-      for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ )
-      {
-        if( getLayerSetLayerIdList(lsIdx, j ) ==  layerId )
-        {
-          Int maxSL = getMaxSubLayersInLayerSetMinus1( lsIdx ); 
-          maxNumPics = std::min( maxNumPics, getDpbSize()->getMaxVpsDecPicBufferingMinus1( olsIdx , j,  maxSL ) );
-        }
-      }
-    }
-    assert( maxNumPics != MAX_INT ); 
-    return maxNumPics; 
-  }
-#endif
+  Int     getMaxNumPics( Int layerId );
 
   /// VPS EXTENSION 2 SYNTAX ELEMENTS
@@ -1356,15 +1248,5 @@
   Void          setScaledFlag(Bool flag)          { m_scaledFlag = flag;  } 
   Bool          getScaledFlag() const             { return m_scaledFlag;  } 
-  Void          scaleOffsets( Int scal )          
-  {
-    if (! m_scaledFlag )
-    {
-      m_scaledFlag         = true; 
-      m_winLeftOffset     *= scal; 
-      m_winRightOffset    *= scal; 
-      m_winTopOffset      *= scal; 
-      m_winBottomOffset   *= scal; 
-    }
-  }
+  Void          scaleOffsets( Int scal );
 #endif
   Void          setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom)
@@ -1630,5 +1512,5 @@
   // SPS 
   Bool        m_spsExtensionPresentFlag; 
-#if H_MV_HLS_8_SPS_NODOC_48
+
   Bool        m_spsRangeExtensionsFlag;
   Bool        m_spsMultilayerExtensionFlag;
@@ -1639,7 +1521,5 @@
   Int         m_spsExtension6bits;
 #endif
-#else
-  Bool        m_spsExtensionTypeFlag     [PS_EX_T_MAX_NUM];
-#endif
+
   Bool        m_spsInferScalingListFlag;
   Int         m_spsScalingListRefLayerId;
@@ -1755,5 +1635,5 @@
   UInt      getMaxTLayers()                           { return m_uiMaxTLayers; }
   Void      setMaxTLayers( UInt uiMaxTLayers )        { assert( uiMaxTLayers <= MAX_TLAYER ); m_uiMaxTLayers = uiMaxTLayers; }
-#if H_MV_HLS_8
+#if H_MV
   UInt      getSpsMaxSubLayersMinus1()                { return ( m_uiMaxTLayers - 1); }
 #endif
@@ -1789,45 +1669,9 @@
   TComPTL* getPTL()     { return &m_pcPTL; }
 #if H_MV
-
-#if H_MV_HLS_8_HRD_Q0102_08
-  Void inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder )
-  {
-    const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx )); 
-
-    if (getLayerId() > 0 )
-    {
-      Int layerIdx = 0;         
-      while (layerIdx < (Int) targetDecLayerIdList.size() )
-      {
-        if ( targetDecLayerIdList[layerIdx] == currLayerId )
-        { 
-          break; 
-        }
-        layerIdx++; 
-      }
-
-      assert( layerIdx < (Int) targetDecLayerIdList.size() ); 
-
-      for (Int i = 0; i <= getSpsMaxSubLayersMinus1(); i++ ) 
-      {
-        Int maxDecPicBufferingMinus1 = vps->getDpbSize()->getMaxVpsDecPicBufferingMinus1( targetOptLayerSetIdx, layerIdx, i ) ; 
-
-        if ( encoder )
-        {
-          assert( getMaxDecPicBuffering( i ) - 1 == maxDecPicBufferingMinus1 ); 
-        }
-        else
-        {
-          setMaxDecPicBuffering(i, maxDecPicBufferingMinus1 + 1 ); 
-        }
-      }
-    }    
-  }
-#endif
+  Void inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder );
 
   Void setSpsExtensionPresentFlag( Bool flag ) { m_spsExtensionPresentFlag = flag; } 
   Bool getSpsExtensionPresentFlag( )           { return m_spsExtensionPresentFlag; }
 
-#if H_MV_HLS_8_SPS_NODOC_48
   Void setSpsRangeExtensionsFlag( Bool flag )            { m_spsRangeExtensionsFlag = flag; } 
   Bool getSpsRangeExtensionsFlag(  )                     { return m_spsRangeExtensionsFlag; } 
@@ -1844,8 +1688,4 @@
   Void setSpsExtension6bits( Int  val )                  { m_spsExtension6bits = val; } 
   Int  getSpsExtension6bits(  )                          { return m_spsExtension6bits; } 
-#endif
-#else
-  Void setSpsExtensionTypeFlag( Int i, Bool flag )       { m_spsExtensionTypeFlag[i] = flag; } 
-  Bool getSpsExtensionTypeFlag( Int i )                  { return m_spsExtensionTypeFlag[i]; }
 #endif
   
@@ -1886,25 +1726,8 @@
   // Inference 
   Void inferRepFormat( TComVPS* vps, Int layerIdCurr );
-
   Void inferScalingList( TComSPS* spsSrc );
 
-#if H_MV_HLS_8_RPS_Q0100_36
   // others
-  Void checkRpsMaxNumPics( TComVPS* vps, Int currLayerId ) 
-  {
-    // In spec, when rps is in SPS, nuh_layer_id of SPS is used instead 
-    // of nuh_layer_id of slice (currLayerId), this seems to be a bug.
-
-    for (Int i = 0; i < getRPSList()->getNumberOfReferencePictureSets(); i++ )
-    {
-      TComReferencePictureSet* rps = getRPSList()->getReferencePictureSet( i ); 
-      if ( !rps->getInterRPSPrediction() )
-      {
-        rps->checkMaxNumPics( vps->getVpsExtensionFlag(), vps->getMaxNumPics( currLayerId ), 
-          getLayerId(), getMaxDecPicBuffering( getSpsMaxSubLayersMinus1() ) - 1 );  
-      }
-    }
-  }
-#endif
+  Void checkRpsMaxNumPics( TComVPS* vps, Int currLayerId );
 
 #endif
@@ -2019,5 +1842,4 @@
   Int  m_ppsScalingListRefLayerId;
 
-#if H_MV_HLS_8_SPS_NODOC_48
   Bool m_ppsRangeExtensionsFlag;
   Bool m_ppsMultilayerExtensionFlag;
@@ -2029,7 +1851,4 @@
 #endif
 
-#else
-  Bool m_ppsExtensionTypeFlag[PS_EX_T_MAX_NUM];
-#endif
   Bool m_pocResetInfoPresentFlag;
 #endif
@@ -2175,5 +1994,4 @@
   Int  getPpsScalingListRefLayerId(  ) { return m_ppsScalingListRefLayerId; } 
 
-#if H_MV_HLS_8_SPS_NODOC_48
   Void setPpsRangeExtensionsFlag( Bool flag ) { m_ppsRangeExtensionsFlag = flag; } 
   Bool getPpsRangeExtensionsFlag(  ) { return m_ppsRangeExtensionsFlag; } 
@@ -2191,8 +2009,4 @@
   Void setPpsExtension5bits( Int  val ) { m_ppsExtension5bits = val; } 
   Int  getPpsExtension5bits(  ) { return m_ppsExtension5bits; } 
-#endif
-#else
-  Void setPpsExtensionTypeFlag( Int i, Bool flag ) { m_ppsExtensionTypeFlag[i] = flag; } 
-  Bool getPpsExtensionTypeFlag( Int i ) { return m_ppsExtensionTypeFlag[i]; } 
 #endif
 
@@ -2231,5 +2045,5 @@
   Int         m_iPPSId;               ///< picture parameter set ID
   Bool        m_PicOutputFlag;        ///< pic_output_flag 
-#if H_MV_HLS_8_POC_Q0142_32
+#if H_MV
   Int         m_slicePicOrderCntLsb;   
 #endif  
@@ -2414,5 +2228,5 @@
   Void      setPicOutputFlag( Bool b )         { m_PicOutputFlag = b;    }
   Bool      getPicOutputFlag()                 { return m_PicOutputFlag; }
-#if H_MV_HLS_8_POC_Q0142_32
+#if H_MV
   Void      setSlicePicOrderCntLsb( Int i ) { m_slicePicOrderCntLsb = i; }; 
   Int       getSlicePicOrderCntLsb(  )      { return m_slicePicOrderCntLsb; }; 
@@ -2466,7 +2280,5 @@
   Bool      getApplyIC()                                        { return m_bApplyIC; }
   Void      xSetApplyIC();
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
   Void      xSetApplyIC(Bool bUseLowLatencyICEnc);
-#endif
   Void      setIcSkipParseFlag( Bool b )                        { m_icSkipParseFlag = b; }
   Bool      getIcSkipParseFlag()                                { return m_icSkipParseFlag; }
@@ -2569,7 +2381,4 @@
   static Void markIvRefPicsAsShortTerm    ( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 );
   static Void markCurrPic                 ( TComPic* currPic );
-#if !H_MV_HLS_8_DBP_NODOC_42
-  static Void markIvRefPicsAsUnused       ( TComPicLists* ivPicLists, std::vector<Int> targetDecLayerIdSet, TComVPS* vps, Int curLayerId, Int curPoc  );
-#endif
   Void        printRefPicList();
 #endif
@@ -2707,12 +2516,5 @@
   Void setCrossLayerBlaFlag( Bool flag ) { m_crossLayerBlaFlag = flag; } 
   Bool getCrossLayerBlaFlag(  ) { return m_crossLayerBlaFlag; } 
-  Void checkCrossLayerBlaFlag ( )
-  {
-    // cross_layer_bla_flag shall be equal to 0 for pictures with nal_unit_type not equal to IDR_W_RADL or IDR_N_LP or with nuh_layer_id not equal to 0.
-    if ( getLayerId() != 0 || getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
-    {
-      assert( m_crossLayerBlaFlag == 0 ); 
-    }
-  }
+  Void checkCrossLayerBlaFlag ( );
 
 #if !H_MV_HLS7_GEN
@@ -2738,7 +2540,6 @@
   Void setPocResetIdc( Int  val ) { m_pocResetIdc = val; } 
   Int  getPocResetIdc(  ) { return m_pocResetIdc; } 
-#if H_MV_HLS_8_POC_Q0142_32
   Void checkPocResetIdc( ) { assert( !(getVPS()->getPocLsbNotPresentFlag( getLayerIdInVps() ) )  || !(getSlicePicOrderCntLsb() > 0 ) || !( getPocResetIdc() == 2) ); }  
-#endif
+
   Void setPocResetPeriodId( Int  val ) { m_pocResetPeriodId = val; } 
   Int  getPocResetPeriodId(  ) { return m_pocResetPeriodId; } 
@@ -2749,7 +2550,5 @@
   Void setPocLsbVal( Int  val ) { m_pocLsbVal = val; } 
   Int  getPocLsbVal(  ) { return m_pocLsbVal; } 
-#if H_MV_HLS_8_POC_Q0142_32
   Void checkPocLsbVal( ) { assert( !(getVPS()->getPocLsbNotPresentFlag( getLayerIdInVps() ) )  || !getFullPocResetFlag() || ( getPocLsbVal() == 0 ) ); }  
-#endif
 
   Void setPocMsbValPresentFlag( Bool flag ) { m_pocMsbValPresentFlag = flag; } 
@@ -2794,33 +2593,10 @@
   TComPic* getPicFromRefPicSetInterLayer( Int setIdc, Int layerId );
 
-
-#if H_MV_HLS_8_POC_Q0146_15
-// Inference 
-  Bool inferPocMsbValPresentFlag()
-  {
-    Bool pocMsbValPresentFlag; 
-    if( getSliceSegmentHeaderExtensionLength() == 0 ) 
-    {
-      pocMsbValPresentFlag = false; 
-    }
-    else if ( getPocMsbValRequiredFlag() )
-    {
-      pocMsbValPresentFlag = true; 
-    }
-    else
-    {
-      pocMsbValPresentFlag = false; 
-    }
-
-    return pocMsbValPresentFlag; 
-  }  
-#endif
+  // Inference 
+  Bool inferPocMsbValPresentFlag();  
 #endif
 #if H_3D_DDD
-  Void InitializeDDDPara( UInt uiCamParsCodedPrecision, Int  iCodedScale,Int  iCodedOffset, Int iBaseViewIdx );
-  Int  getDepthFromDV( Int iDV, Int iBaseViewIdx )
-  {
-      return ClipY(( iDV * m_aiDDDInvScale[ iBaseViewIdx ] + m_aiDDDInvOffset[ iBaseViewIdx ] ) >> m_aiDDDShift[ iBaseViewIdx ]);
-  }
+  Void initializeDDDPara( UInt uiCamParsCodedPrecision, Int  iCodedScale,Int  iCodedOffset, Int iBaseViewIdx );
+  Int  getDepthFromDV( Int iDV, Int iBaseViewIdx );
 #endif
 
Index: trunk/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/TypeDef.h	(revision 964)
+++ trunk/source/Lib/TLibCommon/TypeDef.h	(revision 976)
@@ -102,4 +102,5 @@
                                               // MTK_NBDV_TN_FIX_E0172     fix the issue of DV derivation from the temporal neighboring blocks, issue 7 in JCT3V-E0172
                                               // MTK_TEXTURE_MRGCAND_BUGFIX_E0182  Bug fix for TEXTURE MERGING CANDIDATE     , JCT3V-E0182
+
 #define H_3D_ARP                          1   // Advanced residual prediction (ARP), JCT3V-D0177
                                               // QC_MTK_INTERVIEW_ARP_F0123_F0108 JCT3V-F0123; JCT3V-F0108
@@ -108,4 +109,5 @@
                                               // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
                                               // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053 
+                                              // MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085  Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
 
 
@@ -119,4 +121,5 @@
                                               // MTK_IC_FLAG_CABAC_SIMP_G0061
                                               // SEC_IC_ARP_SIG_G0072, Disabling IC when ARP is enabled, option 1 in JCT3V-G0072, part 2 in JCT3V-G0121
+                                              // MTK_LOW_LATENCY_IC_ENCODING_H0086  Low-latency IC encoding in JCT3V-H0086
 
 
@@ -128,4 +131,5 @@
                                               // NBDV_DEFAULT_VIEWIDX_BUGFIX Bug fix for invalid default view index for NBDV
                                               // NTT_DoNBDV_VECTOR_CLIP_E0141 disparity vector clipping in DoNBDV, JCT3V-E0141 and JCT3V-E0209
+                                              // SEC_VER_DONBDV_H0103          Vertical DV Restriction for DoNBDV
 #endif
 
@@ -161,5 +165,11 @@
                                               // SEC_DEPTH_DV_DERIVAITON_G0074, Simplification of DV derivation for depth, JCT3V-G0074
                                               // QC_DEPTH_MERGE_SIMP_G0127 Remove DV candidate and shifting candidate for depth coding
-
+                                              // QC_IV_PRED_CONSTRAINT_H0137   Constraint on inter-view (motion) prediction tools
+                                              // ETRIKHU_BUGFIX_H0083          bug-fix for DV candidate pruning
+                                              // ETRIKHU_CLEANUP_H0083         cleaned-up source code for constructing merging candidate list
+                                              // ETRIKHU_CLEANUP_H0083_MISSING missing guard macros added by GT
+                                              // SHARP_SIMPLE_MERGE_H0062      Restrict 3D-HEVC merge cand in small PUs
+                                              // MTK_DIS_SPBIP8X4_H0205        Disable bi-prediction for 8x4 and 4x8 sub PU and remove the SPIVMP 2Nx2N restriction
+                                              // SEC_ADAPT_DISABLE_IVMP        Disalbing IVMP merge candidates when IC is enabled, JCT3V-H0070
 
 #define H_3D_TMVP                         1   // QC_TMVP_C0047 
@@ -196,4 +206,13 @@
                                               // HS_TSINGHUA_SDC_SPLIT_G0111
                                               // QC_PKU_SDC_SPLIT_G0123 Intra SDC Split
+                                              // HS_DMM_SDC_PREDICTOR_UNIFY_H0108  Unification of DMM and SDC predictor derivation
+                                              // LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135  Use only one context for CABAC of dim_not_present_flag
+                                              // QC_SIMP_DELTADC_CODING_H0131   Simplify detaDC entropy coding 
+                                              // MTK_DMM_SIMP_CODE_H0092        Remove CABAC context for DMM1 mode coding
+                                              // MTK_DELTA_DC_FLAG_ONE_CONTEXT_H0084_H0100_H0113 Use only one context for CABAC of delta_dc_flag as in JCTVC-H0084, JCTVC-H0100 and JCTVC-H0113
+                                              // MTK_SDC_FLAG_FIX_H0095                          Remove conditional check of PCM flag based on SDC flag, JCTVC-H0095
+                                              // SEC_NO_RESI_DLT_H0105    
+                                              // MTK_DLT_CODING_FIX_H0091 
+
 
 #define H_3D_INTER_SDC                    1   // INTER SDC, Inter simplified depth coding
@@ -205,7 +224,13 @@
                                               // QC_SPIVMP_MPI_G0119 Sub-PU level MPI merge candidate
                                               // Simplification on Sub-PU level temporal interview motion prediction
-
+                                              // MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133
 
 #define H_3D_DBBP                         1   // DBBP: Depth-based Block Partitioning and Merging
+                                              // MTK_DBBP_AMP_REM_H0072   
+                                              // RWTH_DBBP_NO_SPU_H0057   
+                                              // SEC_DBBP_FILTERING_H0104 
+                                              // MTK_DBBP_SIGNALING_H0094    
+                                              // H_3D_FIX_DBBP_IVMP        Fix . Enable IVMP is always disabled, when DBBP is enabled. The original intention is to disable Sub-PU IVMP when DBBP is enabled, not to disable IVMP itself. 
+
 
 #define H_3D_DDD                          1   // Disparity derived depth coding
@@ -289,4 +314,5 @@
 #define IC_CONST_SHIFT                    5
 #define IC_SHIFT_DIFF                     12
+#define IC_LOW_LATENCY_ENCODING_THRESHOLD 0.1 // Threshold for low-latency IC encoding in JCT3V-H0086
 #endif
 
@@ -310,68 +336,8 @@
 #endif
 
-
-/////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////   HTM-11.0 Integrations                  //////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////
-#if H_3D
-#define  H_3D_FIX_DBBP_IVMP                1  // Fix . Enable IVMP is always disabled, when DBBP is enabled. The original intention is to disable Sub-PU IVMP when DBBP is enabled, not to disable IVMP itself. 
-
-#define MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085 1   // Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
-#define MTK_LOW_LATENCY_IC_ENCODING_H0086   1 // Low-latency IC encoding in JCT3V-H0086
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
-#define MTK_LOW_LATENCY_IC_ENCODING_THRESHOLD_H0086    0.1 // Threshold for low-latency IC encoding in JCT3V-H0086
-#endif
-#define SEC_ADAPT_DISABLE_IVMP            1   // Disalbing IVMP merge candidates when IC is enabled, JCT3V-H0070
-
-#define MTK_DELTA_DC_FLAG_ONE_CONTEXT_H0084_H0100_H0113     1 // Use only one context for CABAC of delta_dc_flag as in JCTVC-H0084, JCTVC-H0100 and JCTVC-H0113
-#define MTK_SDC_FLAG_FIX_H0095            1   // Remove conditional check of PCM flag based on SDC flag, JCTVC-H0095
-#define MTK_DMM_SIMP_CODE_H0092           1   // Remove CABAC context for DMM1 mode coding
-
-
-#define QC_IV_PRED_CONSTRAINT_H0137       1   // Constraint on inter-view (motion) prediction tools
-#define ETRIKHU_BUGFIX_H0083              1   // bug-fix for DV candidate pruning
-#define ETRIKHU_CLEANUP_H0083             1   // cleaned-up source code for constructing merging candidate list
-#define ETRIKHU_CLEANUP_H0083_MISSING     1   // missing guard macros added by GT
-#define SHARP_SIMPLE_MERGE_H0062          1   // Restrict 3D-HEVC merge cand in small PUs
-#define MTK_DIS_SPBIP8X4_H0205            1   // Disable bi-prediction for 8x4 and 4x8 sub PU and remove the SPIVMP 2Nx2N restriction
-
-#if H_3D_NBDV
-#define SEC_VER_DONBDV_H0103              1   // Vertical DV Restriction for DoNBDV
-#endif
-
-#if H_3D_DIM
-#define HS_DMM_SDC_PREDICTOR_UNIFY_H0108  1   // Unification of DMM and SDC predictor derivation
-#define LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135  1 // Use only one context for CABAC of dim_not_present_flag
-#define QC_SIMP_DELTADC_CODING_H0131      1   // Simplify detaDC entropy coding 
-
-#if H_3D_DIM_DLT
-#define SEC_NO_RESI_DLT_H0105             1
-#define MTK_DLT_CODING_FIX_H0091          1
-#endif
-#endif
-#if H_3D_DBBP
-#define MTK_DBBP_AMP_REM_H0072                 1
-#define RWTH_DBBP_NO_SPU_H0057                 1
-#define SEC_DBBP_FILTERING_H0104               1
-#define MTK_DBBP_SIGNALING_H0094               1    
-#endif
-
-#define MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133    1
-#endif
-
-#if H_MV
-#define H0044_POC_LSB_NOT_PRESENT        1      ///< JCT3V-H0044: Add constraint checking on the value of poc_reset_idc and poc_lsb_val
-#define H0056_EOS_CHECKS                 1      ///< JCT3V-H0056: Put checks on handling EOS
-#endif
-/////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////   TBD                  //////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////
-
-
-#define H_MV_HLS_8                           1 // General changes
-#define H_MV_HLS_7_VPS_P0300_27              1 // Output part only. (VPS/P0300/alt output layer flag) #27 Change alt output layer flag to be signalled within the loop of output layer sets, from JCTVC-P0300-v2. Decision: Adopt. 
-#define MV_FIX_DEP_TYPES                     1
-
-
+/////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////   MV_HEVC HLS  //////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
+// TBD: Check if integration is necessary. 
 #define H_MV_HLS7_GEN                        0  // General changes (not tested)
 
@@ -380,8 +346,4 @@
 // #define H_MV_HLS_7_POC_P0041_FIXES        0 // (POC/P0041/Fixes) For each non-IRAP picture that has discardable_flag equal to 1 to have NUT value indicating that it is a sub-layer non-reference picture. 
 // #define H_MV_HLS_7_POC_P0056_4            0 // (POC/P0056/layer tree poc) #4 Proposal 1: If the POC reset approach is adopted as the basis for multi-layer POC derivation, it is proposed to derive the POC anchor picture from the previous TID0 picture (that is not a RASL picture, a RADL picture or a sub-layer non-reference picture and not with discardable_flag equal to 1) of  the current layer or any of its reference layer. This is asserted to improve loss resilience and reduce bit rate overhead. Decision: Adopt Proposal 1 (with the suggested modifications Ewith text provided as P0297).
-
-
-// OTHERS
-// #define H_MV_HLS_7_HRD_P0138_6            0 // (HRD/P0138/HRD parameters for bitstreams excluding) #6 Decision: Adopt (as revised in updated contribution, with the specification of a flag in the BP SEI (HRD/P0192/sub-DPB) #12 Establish sub-DPBs based on the representation format indicated at the VPS level. It was suggested that the expressed shared capacity limit would need to be less than or equal to the sum of the individual capacity limits. Decision: Adopt as modified. Further study is encouraged on profile/level constraint selections. 
 
 // SEI related
@@ -400,5 +362,4 @@
 //#define H_MV_HLS_7_SEI_P0123_25  0 // (SEI/P0123/Alpha channel info) #25 Add alpha channel information SEI message Decision: Adopt. Constrain the bit depth indicated to be equal to the coded bit depth of the aux picture. 
 
-
 // Auxiliary picture related
 //#define H_MV_HLS_8_AUX_NODOC_40  0 // #40 (AUX    /NODOC/primary pic) Clarify that an auxiliary picture can be associated with more than one primary picture. Consider if the language associating an alpha auxiliary picture with a primary picture in the semantics of dimension_id[ ][ ] near the AuxId derivation could be moved to the alpha SEI message.
@@ -419,32 +380,9 @@
 //#define H_MV_HLS_7_OTHER_P0187_1 0 // (OTHER/P0187/NoOutputOfPriorPicsFlag) #1 Inference of NoOutputOfPriorPicsFlag and proposes to take into account colour format and bit depth for the inference in addition to spatial resolution 
 
-// Others
+// OTHERS
 //#define H_MV_HLS_8_HSB_Q0041_03  0 // #3  (HS     /Q0041/hybrid scalability) The proposed text was endorsed, with non-editorial open issues considered as follows 
 :// #define H_MV_HLS_7_OTHER_P0187_1          0 // (OTHER/P0187/NoOutputOfPriorPicsFlag) #1 Inference of NoOutputOfPriorPicsFlag and proposes to take into account colour format and bit depth for the inference in addition to spatial resolution 
 //#define H_MV_HLS_8_MIS_Q0078_24  0 // #24 (MISC   /Q0078/scan and pic type) , Items 3 b,c and 4, clarifying which pictures in an output layer sets are applied the values of general_progressive_source_flag, general_interlaced_source_flag, general_non_packed_constraint_flag and general_frame_only_constraint_flag.
-
-
-#define H_MV_HLS_8_SYN_Q0041_03    1   // #3  Syntax only (HS     /Q0041/hybrid scalability) The proposed text was endorsed, with non-editorial open issues considered as follows 
-:// #define H_MV_HLS_7_OTHER_P0187_1          0 // (OTHER/P0187/NoOutputOfPriorPicsFlag) #1 Inference of NoOutputOfPriorPicsFlag and proposes to take into account colour format and bit depth for the inference in addition to spatial resolution 
-#define H_MV_HLS_8_SYN_39_19       1   // #39 Syntax only + (PS/Q0165,Q0078/presence of num_add_output_layer_sets) proposal 2. change condition for presence of num_add_output_layer_sets to avoid sending it when there is only one layer set.
-#define H_MV_HLS_8_HRD_Q0101_04    1   // #4  (HRD    /Q0101/Bitstream part buffer) On Bitstream Partition Buffer. Decision (BF/Cleanup): Adopt (sub-proposals 111, refined as described).
-#define H_MV_HLS_8_PPS_NODOC_NN    1   // #NN (PPS    /NODOC/reserved flag): Add a flag in PPS for SHVC color gamut scalability
-#define H_MV_HLS_8_MIS_Q0177_47    1   // #47 (MISC   /Q0177/EOS NAL) proposal 2: clarification of description of end of sequence NAL unit
-#define H_MV_HLS_8_HRD_Q0182_05    1   // #5  (HRD    /Q0182/Bitstream part buffer) Decision (BF/Cleanup/Ed): Adopted (such that we use the main proposal for sub-proposal 1, and alternative 1 for sub-proposal 2). + #define H_MV_HLS_8_HRD_Q0182_06  0 // #6  (HRD    /Q0182/hrd_parameters) Sub-proposal 2 Alternative 1: Clarify that the VPS hrd_parameters( ) syntax structure that applies to the layer set which is associated with the bitstream partition initial arrival time SEI message is used to determine the lengths of the nal_initial_arrival_delay[ i ] and vcl_initial_arrival_delay[ i ] syntax elements. Decision (BF/Cleanup/Ed): Adopted alternative 1 for sub-proposal 2
-#define H_MV_HLS_8_SPS_NODOC_48    1   // #48 (SPS    /NODOC/PPS extension cleanups) Alignment with RExt
-#define H_MV_HLS_8_DBP_NODOC_42    1   // #42 (DBP    /NODOC/sharing) Remove sub-DPB sharing and processes that mark inter-layer reference pictures as "unused for reference"
-#define H_MV_HLS_8_RPS_Q0100_36    1   // #36 (RPS    /Q0100/constraint to semantics) v3, add constraint to RPS semantics
-#define H_MV_HLS_8_POC_Q0142_32    1   // #32 (POC    /Q0142/poc_lsb_not_present_flag) v2: Add semantic constraints to poc_lsb_not_present_flag.
-#define H_MV_HLS_8_HRD_Q0102_08    1   // #8  (HRD    /Q0102/sps_max_dec_pic_buffering_minus1) Sub-proposal 2: A semantics bug fix is proposed for sps_max_dec_pic_buffering_minus1 as a bug-fix. In discussion, the first option was preferred. Decision (BF/Cleanup/Ed.): Adopt. 
-#define H_MV_HLS_8_MIS_Q0102_30    1   // #30 (MISC   /Q0102/loop index) proposal 3, change the max loop index for signaling bit rate and pic rate info to MaxSubLayersInLayerSetMinus1
-#define H_MV_HLS_8_GEN_Q0108_13    1   // #13 (GEN    /Q0108/STSA TemporalId) Agreed to remove restriction from proposal 2, to allow STSA pics of non-base layers to have TemporalId equal to 0.
-#define H_MV_HLS_8_PMS_Q0195_21    1   // #21 (PS     /Q0195/constraint update_ref_format_flag) proposal 2: add a semantic constraint on the value of update_ref_format_flag
-#define H_MV_HLS_8_PMS_Q0195_20    1   // #20 (PS     /Q0195/syntax table rep format) proposal 1: restructure syntax table for sending of rep_format_idx_present_flag and vps_num_ref_formats_minus1
-#define H_MV_HLS_8_MIS_Q0177_22    1   // #22 (MISC   /Q0177/inference sps_temporal_id_nesting_flag) proposal 1: modify inference rule for sps_temporal_id_nesting_flag when it is not present
-#define H_MV_HLS_8_PMS_Q0165_18    1   // #18 (PS     /Q0165/disallow an empty layer set) proposal 1.a), add a constraint to disallow an empty layer set
-#define H_MV_HLS_8_RPS_Q0060_17    1   // #17 (RPS    /Q0060/condition refLayerPicIdc) Proposal 2: Add a condition to the derivation of refLayerPicIdc of (TemporalId == 0)
-#define H_MV_HLS_8_POC_Q0146_15    1   // #15 (POC    /Q0146/inference of poc_msb_val_present_flag) Proposal 1.1: Change inference rule in semantics of poc_msb_val_present_flag
-
-
+//#define H_MV_HLS_7_HRD_P0138_6   0 //     (HRD/P0138/HRD parameters for bitstreams excluding) #6 Decision: Adopt (as revised in updated contribution, with the specification of a flag in the BP SEI (HRD/P0192/sub-DPB) #12 Establish sub-DPBs based on the representation format indicated at the VPS level. It was suggested that the expressed shared capacity limit would need to be less than or equal to the sum of the individual capacity limits. Decision: Adopt as modified. Further study is encouraged on profile/level constraint selections. 
 
 /////////////////////////////////////////////////////////////////////////////////////////
@@ -938,5 +876,5 @@
 
 /// merging candidates
-#if ETRIKHU_CLEANUP_H0083
+#if H_3D
 enum DefaultMergCandOrder
 {
@@ -1012,27 +950,4 @@
 #if H_MV
 
-#if !H_MV_HLS_8_SPS_NODOC_48
-enum PpsExtensionTypes
-{
-  PPS_EX_T_MV      = 0,
-#if H_3D
-  PPS_EX_T_3D      = 3,
-#endif
-  PPS_EX_T_ESC     = 7,
-  PPS_EX_T_MAX_NUM = 8
-};
-
-//Below for sps, would be good if this could be aligned
-
-  enum PsExtensionTypes
-  {
-    PS_EX_T_MV   = 1,
-#if H_3D
-    PS_EX_T_3D   = 3,
-#endif
-    PS_EX_T_ESC  = 7,
-    PS_EX_T_MAX_NUM = 8
-  };
-#endif
 /// scalability types
   enum ScalabilityType
Index: trunk/source/Lib/TLibDecoder/NALread.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/NALread.cpp	(revision 964)
+++ trunk/source/Lib/TLibDecoder/NALread.cpp	(revision 976)
@@ -127,5 +127,5 @@
   else
   {
-#if H_MV_HLS_8_GEN_Q0108_13
+#if H_MV
 
     // If nal_unit_type is in the range of BLA_W_LP to RSV_IRAP_VCL23, inclusive, i.e. the coded 
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 964)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 976)
@@ -374,5 +374,4 @@
 
 #if H_MV
-#if H_MV_HLS_8_SPS_NODOC_48
     READ_FLAG( uiCode, "pps_range_extensions_flag" ); pcPPS->setPpsRangeExtensionsFlag( uiCode == 1 );
     READ_FLAG( uiCode, "pps_multilayer_extension_flag" ); pcPPS->setPpsMultilayerExtensionFlag( uiCode == 1 );
@@ -390,8 +389,6 @@
     if ( pcPPS->getPpsMultilayerExtensionFlag() )
     { 
-        READ_FLAG( uiCode, "poc_reset_info_present_flag" ); pcPPS->setPocResetInfoPresentFlag( uiCode == 1 );
-#if H_MV_HLS_8_PPS_NODOC_NN
-        READ_FLAG( uiCode, "pps_extension_reserved_zero_flag" );
-#endif
+      READ_FLAG( uiCode, "poc_reset_info_present_flag" ); pcPPS->setPocResetInfoPresentFlag( uiCode == 1 );
+      READ_FLAG( uiCode, "pps_extension_reserved_zero_flag" );
     }
 #if !H_3D
@@ -406,31 +403,5 @@
     {
 #endif
-#else
-    for ( Int i = 0; i < PPS_EX_T_MAX_NUM; i++ )
-    {
-      READ_FLAG( uiCode, "pps_extension_type_flag" ); pcPPS->setPpsExtensionTypeFlag( i, uiCode == 1 );
-#if H_3D
-      assert( !pcPPS->getPpsExtensionTypeFlag( i ) || i == PPS_EX_T_MV || i == PPS_EX_T_3D || i == PPS_EX_T_ESC ); 
-#else
-      assert( !pcPPS->getPpsExtensionTypeFlag( i ) || i == PPS_EX_T_MV || i == PPS_EX_T_ESC ); 
-#endif
-    }
-    
-
-    if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_MV ) )
-    {
-      READ_FLAG( uiCode, "poc_reset_info_present_flag" ); pcPPS->setPocResetInfoPresentFlag( uiCode == 1 );
-    }
-
-#if H_3D
-    if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_3D ) ) // This probably needs to be aligned with Rext and SHVC
-    {
-      parsePPSExtension( pcPPS, pcVPS );
-    }
-#endif
-
-    if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_ESC ) )
-    {
-#endif
+
 #endif
 
@@ -481,11 +452,8 @@
             READ_FLAG(uiCode, "inter_view_dlt_pred_enable_flag[ i ]"); 
 
-#if  MTK_DLT_CODING_FIX_H0091
             if( uiCode )
             {
                 assert( pcDLT->getUseDLTFlag( 1 ));
             }
-#endif
-
             pcDLT->setInterViewDltPredEnableFlag( i, (uiCode == 1) ? true : false );
 
@@ -795,15 +763,15 @@
   {
 #endif
-  READ_CODE( 3,  uiCode, "sps_max_sub_layers_minus1" );          pcSPS->setMaxTLayers   ( uiCode+1 );
-  assert(uiCode <= 6);
-  
-  READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" );               pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );
-  if ( pcSPS->getMaxTLayers() == 1 )
-  {
-    // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0
-    assert( uiCode == 1 );
-  }
-  
-  parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
+    READ_CODE( 3,  uiCode, "sps_max_sub_layers_minus1" );          pcSPS->setMaxTLayers   ( uiCode+1 );
+    assert(uiCode <= 6);
+
+    READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" );               pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );
+    if ( pcSPS->getMaxTLayers() == 1 )
+    {
+      // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0
+      assert( uiCode == 1 );
+    }
+
+    parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
 #if H_MV
   }
@@ -823,15 +791,15 @@
   {
 #endif
-  READ_UVLC(     uiCode, "chroma_format_idc" );                  pcSPS->setChromaFormatIdc( uiCode );
-  assert(uiCode <= 3);
-  // in the first version we only support chroma_format_idc equal to 1 (4:2:0), so separate_colour_plane_flag cannot appear in the bitstream
-  assert (uiCode == 1);
-  if( uiCode == 3 )
-  {
-    READ_FLAG(     uiCode, "separate_colour_plane_flag");        assert(uiCode == 0);
-  }
-
-  READ_UVLC (    uiCode, "pic_width_in_luma_samples" );          pcSPS->setPicWidthInLumaSamples ( uiCode    );
-  READ_UVLC (    uiCode, "pic_height_in_luma_samples" );         pcSPS->setPicHeightInLumaSamples( uiCode    );
+    READ_UVLC(     uiCode, "chroma_format_idc" );                  pcSPS->setChromaFormatIdc( uiCode );
+    assert(uiCode <= 3);
+    // in the first version we only support chroma_format_idc equal to 1 (4:2:0), so separate_colour_plane_flag cannot appear in the bitstream
+    assert (uiCode == 1);
+    if( uiCode == 3 )
+    {
+      READ_FLAG(     uiCode, "separate_colour_plane_flag");        assert(uiCode == 0);
+    }
+
+    READ_UVLC (    uiCode, "pic_width_in_luma_samples" );          pcSPS->setPicWidthInLumaSamples ( uiCode    );
+    READ_UVLC (    uiCode, "pic_height_in_luma_samples" );         pcSPS->setPicHeightInLumaSamples( uiCode    );
 #if H_MV
   }
@@ -860,13 +828,13 @@
   { 
 #endif
-  READ_UVLC(     uiCode, "bit_depth_luma_minus8" );
-  assert(uiCode <= 6);
-  pcSPS->setBitDepthY( uiCode + 8 );
-  pcSPS->setQpBDOffsetY( (Int) (6*uiCode) );
-
-  READ_UVLC( uiCode,    "bit_depth_chroma_minus8" );
-  assert(uiCode <= 6);
-  pcSPS->setBitDepthC( uiCode + 8 );
-  pcSPS->setQpBDOffsetC( (Int) (6*uiCode) );
+    READ_UVLC(     uiCode, "bit_depth_luma_minus8" );
+    assert(uiCode <= 6);
+    pcSPS->setBitDepthY( uiCode + 8 );
+    pcSPS->setQpBDOffsetY( (Int) (6*uiCode) );
+
+    READ_UVLC( uiCode,    "bit_depth_chroma_minus8" );
+    assert(uiCode <= 6);
+    pcSPS->setBitDepthC( uiCode + 8 );
+    pcSPS->setQpBDOffsetC( (Int) (6*uiCode) );
 #if H_MV
   }
@@ -880,27 +848,27 @@
   {  
 #endif
-  UInt subLayerOrderingInfoPresentFlag;
-  READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag");
-  
-  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
-  {
-    READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]");
-    pcSPS->setMaxDecPicBuffering( uiCode + 1, i);
-    READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" );
-    pcSPS->setNumReorderPics(uiCode, i);
-    READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]");
-    pcSPS->setMaxLatencyIncrease( uiCode, i );
-
-    if (!subLayerOrderingInfoPresentFlag)
-    {
-      for (i++; i <= pcSPS->getMaxTLayers()-1; i++)
-      {
-        pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i);
-        pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i);
-        pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i);
-      }
-      break;
-    }
-  }
+    UInt subLayerOrderingInfoPresentFlag;
+    READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag");
+
+    for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
+    {
+      READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]");
+      pcSPS->setMaxDecPicBuffering( uiCode + 1, i);
+      READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" );
+      pcSPS->setNumReorderPics(uiCode, i);
+      READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]");
+      pcSPS->setMaxLatencyIncrease( uiCode, i );
+
+      if (!subLayerOrderingInfoPresentFlag)
+      {
+        for (i++; i <= pcSPS->getMaxTLayers()-1; i++)
+        {
+          pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i);
+          pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i);
+          pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i);
+        }
+        break;
+      }
+    }
 #if H_MV
   }
@@ -912,10 +880,10 @@
   READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" );
   pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode);
-  
+
   if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5)
   {
     assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5);
   }
-  
+
   Int maxCUDepthDelta = uiCode;
   pcSPS->setMaxCUWidth  ( 1<<(log2MinCUSize + maxCUDepthDelta) ); 
@@ -948,9 +916,9 @@
     {    
 #endif
-    READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" );                 pcSPS->setScalingListPresentFlag ( uiCode );
-    if(pcSPS->getScalingListPresentFlag ())
-    {
-      parseScalingList( pcSPS->getScalingList() );
-    }
+      READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" );                 pcSPS->setScalingListPresentFlag ( uiCode );
+      if(pcSPS->getScalingListPresentFlag ())
+      {
+        parseScalingList( pcSPS->getScalingList() );
+      }
 #if H_MV
     }
@@ -1017,5 +985,4 @@
   {
 #if H_MV
-#if H_MV_HLS_8_SPS_NODOC_48
     READ_FLAG( uiCode, "sps_range_extensions_flag" ); pcSPS->setSpsRangeExtensionsFlag( uiCode == 1 );
     READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); pcSPS->setSpsMultilayerExtensionFlag( uiCode == 1 );
@@ -1050,38 +1017,10 @@
   { 
 #endif
-#else
-    for (Int i = 0; i < PS_EX_T_MAX_NUM; i++)
-    {
-      READ_FLAG( uiCode, "sps_extension_type_flag" ); pcSPS->setSpsExtensionTypeFlag( i, uiCode );
-#if H_3D
-      assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV || i == PS_EX_T_3D || i == PS_EX_T_ESC ); 
-#else
-      assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV || i == PS_EX_T_ESC ); 
-#endif
-    }  
-
-    if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_MV ))
-    {
-      parseSPSExtension( pcSPS ); 
-    }
-
-#if H_3D
-    if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_3D ))
-    {
-      parseSPSExtension2( pcSPS, viewIndex, depthFlag  ); 
-    }
-#endif
-
-    if ( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_ESC ))
-    {   
-#endif
-#endif
-        while ( xMoreRbspData() )
-        {
-          READ_FLAG( uiCode, "sps_extension_data_flag");
-        }
-#if H_MV && !H_MV_HLS_8_SPS_NODOC_48
-    }
-#endif
+
+#endif
+    while ( xMoreRbspData() )
+    {
+      READ_FLAG( uiCode, "sps_extension_data_flag");
+    }
   }
 }
@@ -1132,5 +1071,5 @@
   
   READ_CODE( 4,  uiCode,  "vps_video_parameter_set_id" );         pcVPS->setVPSId( uiCode );
-#if H_MV_HLS_8_SYN_Q0041_03
+#if H_MV
   READ_FLAG( uiCode, "vps_base_layer_internal_flag" );            pcVPS->setVpsBaseLayerInternalFlag( uiCode == 1 );
   READ_FLAG( uiCode, "vps_reserved_one_bit" );                    assert( uiCode == 1 ); 
@@ -1221,5 +1160,5 @@
     }
   }
-#if H_MV_HLS_8_RPS_Q0100_36
+#if H_MV
   READ_FLAG( uiCode,  "vps_extension_flag" );                      pcVPS->setVpsExtensionFlag( uiCode == 1 ? true : false );
   if ( pcVPS->getVpsExtensionFlag() )
@@ -1262,7 +1201,4 @@
 {
   UInt uiCode; 
-#if !H_MV_HLS_8_SYN_Q0041_03
-  READ_FLAG( uiCode, "avc_base_layer_flag" );                     pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false );
-#endif
 
   READ_FLAG( uiCode, "splitting_flag" );                          pcVPS->setSplittingFlag( uiCode == 1 ? true : false );
@@ -1384,5 +1320,4 @@
   }
 
-#if H_MV_HLS_8_SYN_39_19
   if ( pcVPS->getNumIndependentLayers() > 1 ) 
   {
@@ -1404,12 +1339,4 @@
   pcVPS->initTargetLayerIdLists( ); 
 
-#else
-  READ_UVLC( uiCode, "num_add_layer_sets"      ); pcVPS->setNumAddLayerSets( uiCode );
-  pcVPS->initTargetLayerIdLists( ); 
-  if( pcVPS->getNumOutputLayerSets() > 1)
-  {
-    READ_CODE( 2, uiCode, "default_output_layer_idc" ); pcVPS->setDefaultOutputLayerIdc( std::min( uiCode, (UInt) 2 ) );    
-  }  
-#endif
 
   pcVPS->setOutputLayerFlag(0, 0, pcVPS->inferOutputLayerFlag( 0, 0 )); 
@@ -1420,9 +1347,5 @@
   for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ )
   {
-#if H_MV_HLS_8_SYN_39_19
     if( i >= pcVPS->getNumLayerSets( ) )    
-#else
-    if( i > pcVPS->getVpsNumLayerSetsMinus1( ) )    
-#endif
     {        
       READ_UVLC( uiCode,      "layer_set_idx_for_ols_minus1[i]" ); pcVPS->setLayerSetIdxForOlsMinus1( i, uiCode ); 
@@ -1455,13 +1378,5 @@
   }
 
-#if !H_MV_HLS_8_PMS_Q0195_20
-  READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 );
-  if ( pcVPS->getRepFormatIdxPresentFlag() )
-  {
-    READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode );
-  }
-#else
   READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode );
-#endif
 
   for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ )
@@ -1474,41 +1389,22 @@
   }
 
-#if H_MV_HLS_8_PMS_Q0195_20
   if ( pcVPS->getVpsNumRepFormatsMinus1() > 0 )
   {
     READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 );
   }
-#endif
   if( pcVPS->getRepFormatIdxPresentFlag() ) 
   {
-#if H_MV_HLS_8_SYN_Q0041_03
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-#else
-    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-#endif
-    {
-#if !H_MV_HLS_8_PMS_Q0195_20
-      if( pcVPS->getVpsNumRepFormatsMinus1() > 0 )
-      {
-#endif
+    {
         READ_CODE( pcVPS->getVpsRepFormatIdxLen(), uiCode, "vps_rep_format_idx[i]" ); pcVPS->setVpsRepFormatIdx( i, uiCode );
-#if !H_MV_HLS_8_PMS_Q0195_20
-      }
-#endif
-    }
-  }
-#if H_MV_HLS_8_PMS_Q0195_20
+    }
+  }
   else
   {
-#if H_MV_HLS_8_SYN_Q0041_03
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-#else
-    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-#endif
     {
       pcVPS->setVpsRepFormatIdx( i, pcVPS->inferVpsRepFormatIdx( i ) );
     }
   }
-#endif
 
   READ_FLAG( uiCode, "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag ( uiCode == 1 ); 
@@ -1535,13 +1431,7 @@
   }
 
-#if H_MV_HLS_8_SYN_Q0041_03
   for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ?  1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ )
   {
     for( Int j = pcVPS->getVpsBaseLayerInternalFlag() ?  0 : 1; j < i; j++ )
-#else
-  for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
-  {
-    for( Int j = 0; j < i; j++ )
-#endif
     {
       if (pcVPS->getDirectDependencyFlag( i, j) )
@@ -1629,15 +1519,7 @@
   if( pcVPSVUI->getBitRatePresentVpsFlag( )  ||  pcVPSVUI->getPicRatePresentVpsFlag( ) )
   {
-#if H_MV_HLS_8_SYN_Q0041_03
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i  <=  pcVPS->getVpsNumLayerSetsMinus1(); i++ )
-#else
-    for( Int i = 0; i  <=  pcVPS->getVpsNumLayerSetsMinus1(); i++ )
-#endif
-    {
-#if H_MV_HLS_8_MIS_Q0102_30
+    {
       for( Int j = 0; j  <=  pcVPS->getMaxSubLayersInLayerSetMinus1( i ); j++ ) 
-#else        
-      for( Int j = 0; j  <=  pcVPS->getMaxTLayers(); j++ ) 
-#endif
       {
         if( pcVPSVUI->getBitRatePresentVpsFlag( ) )
@@ -1699,9 +1581,5 @@
   if( !pcVPSVUI->getTilesNotInUseFlag() ) 
   {      
-#if H_MV_HLS_8_SYN_Q0041_03
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
-#else
-    for( Int i = 0; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
-#endif
     {
       READ_FLAG( uiCode, "tiles_in_use_flag[i]" ); pcVPSVUI->setTilesInUseFlag( i, uiCode == 1 );
@@ -1711,9 +1589,5 @@
       }
     }  
-#if H_MV_HLS_8_SYN_Q0041_03
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i  <=  pcVPS->getMaxLayersMinus1(); i++ )  
-#else
-    for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )      
-#endif
     {
       for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ )
@@ -1746,8 +1620,6 @@
       for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ )
       {
-#if H_MV_HLS_8_SYN_Q0041_03
         if( pcVPS->getVpsBaseLayerInternalFlag() || pcVPS->getRefLayerId( pcVPS->getLayerIdInNuh( i ), j ) > 0 )
         {        
-#endif
           READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, uiCode );
           if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 )
@@ -1759,7 +1631,5 @@
             }
           }
-#if H_MV_HLS_8_SYN_Q0041_03
-        }
-#endif
+        }
       }
     }
@@ -1808,20 +1678,7 @@
     for( Int i = 0; i < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); i++ )  
     {
-#if H_MV_HLS_8_HRD_Q0101_04
       for( Int j = 0; j < pcVPS->getNumLayersInIdList( h ); j++ )  
       {
         READ_FLAG( uiCode, "layer_in_bsp_flag" ); vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, uiCode == 1 );
-#else
-      for( Int j = 0; j <= pcVPS->getMaxLayersMinus1(); j++ )  
-      {
-        if( pcVPS->getLayerIdIncludedFlag( h ,j ) )
-        {
-          READ_FLAG( uiCode, "layer_in_bsp_flag" ); vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, uiCode == 1 );
-        }
-        else
-        {
-          vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, false ); // This inference seems to be missing in spec 
-        }
-#endif
       }
     }
@@ -1831,21 +1688,11 @@
     {  
       READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1" ); vpsVuiBspHrdP->setNumBspSchedCombinationsMinus1( h, uiCode );
-#if H_MV_HLS_8_HRD_Q0182_05
       for( Int i = 0; i <= vpsVuiBspHrdP->getNumBspSchedCombinationsMinus1( h ); i++ )
-#else
-      for( Int i = 0; i < vpsVuiBspHrdP->getNumBspSchedCombinationsMinus1( h ); i++ )
-#endif
       {
         for( Int j = 0; j < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); j++ )
         {  
-#if H_MV_HLS_8_HRD_Q0101_04
           READ_CODE( vpsVuiBspHrdP->getBspCombHrdIdxLen(), uiCode, "bsp_comb_hrd_idx" ); vpsVuiBspHrdP->setBspCombHrdIdx( h, i, j, uiCode );
-#else
-          READ_UVLC( uiCode, "bsp_comb_hrd_idx" ); vpsVuiBspHrdP->setBspCombHrdIdx( h, i, j, uiCode );
-#endif
           READ_UVLC( uiCode, "bsp_comb_sched_idx" ); vpsVuiBspHrdP->setBspCombSchedIdx( h, i, j, uiCode );
-#if H_MV_HLS_8_HRD_Q0101_04
           vpsVuiBspHrdP->checkBspCombHrdAndShedIdx( pcVPS, h, i, j ); 
-#endif
         }  
       }
@@ -1872,13 +1719,7 @@
   for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ )
   {  
-#if H_MV_HLS_8_MIS_Q0102_30
     Int currLsIdx = vps->olsIdxToLsIdx( i ); 
-#endif
     READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize->setSubLayerFlagInfoPresentFlag( i, uiCode == 1 );
-#if H_MV_HLS_8_MIS_Q0102_30
     for( Int j = 0; j  <=  vps->getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ )
-#else
-    for( Int j = 0; j  <=  vps->getMaxSubLayersInLayerSetMinus1( i ); j++ )
-#endif
     {  
       if( j > 0  &&  dpbSize->getSubLayerDpbInfoPresentFlag( i, j )  )  
@@ -1888,9 +1729,5 @@
       if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) )
       {  
-#if H_MV_HLS_8_MIS_Q0102_30
         for( Int k = 0; k < vps->getNumLayersInIdList( currLsIdx ); k++ )   
-#else
-        for( Int k = 0; k < vps->getNumSubDpbs( vps->olsIdxToLsIdx( i )); k++ )   
-#endif
         {
           READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1" ); dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode );
@@ -1903,9 +1740,5 @@
         if ( j > 0 )
         {
-#if H_MV_HLS_8_DBP_NODOC_42
           for( Int k = 0; k < vps->getNumLayersInIdList( vps->olsIdxToLsIdx( i ) ); k++ )   
-#else
-          for( Int k = 0; k < vps->getNumSubDpbs( vps->olsIdxToLsIdx( i ) ); k++ )   
-#endif
           {
             dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) );
@@ -1918,5 +1751,4 @@
   }  
 }
-#endif
 
 #if H_3D
@@ -1939,10 +1771,8 @@
 #if H_3D_IV_MERGE
         READ_FLAG( uiCode, "iv_mv_pred_flag[i]");          pcVPS->setIvMvPredFlag         ( i, uiCode == 1 ? true : false );
-#if QC_IV_PRED_CONSTRAINT_H0137
         if( !pcVPS->getNumDirectRefLayers(i) )
         {
           assert( !uiCode );         
         }
-#endif
 #if H_3D_SPIVMP
         READ_UVLC (uiCode, "log2_sub_PU_size_minus3[i]");     pcVPS->setSubPULog2Size(i, uiCode+3); 
@@ -1951,10 +1781,8 @@
 #if H_3D_ARP
         READ_FLAG( uiCode, "iv_res_pred_flag[i]"  );       pcVPS->setUseAdvRP  ( i, uiCode ); pcVPS->setARPStepNum( i, uiCode ? H_3D_ARP_WFNR : 1 );
-#if QC_IV_PRED_CONSTRAINT_H0137
         if( !pcVPS->getNumDirectRefLayers(i) )
         {
           assert( !uiCode );         
         }
-#endif
 #endif
 #if H_3D_NBDV_REF
@@ -1963,10 +1791,8 @@
 #if H_3D_VSP
         READ_FLAG( uiCode, "view_synthesis_pred_flag[i]"); pcVPS->setViewSynthesisPredFlag( i, uiCode == 1 ? true : false );
-#if QC_IV_PRED_CONSTRAINT_H0137
         if( !pcVPS->getNumDirectRefLayers(i) )
         {
           assert( !uiCode );         
         }
-#endif
 #endif
 #if H_3D_DBBP
@@ -1980,10 +1806,8 @@
         {
           READ_FLAG( uiCode, "iv_mv_pred_flag[i]");          pcVPS->setIvMvPredFlag         ( i, uiCode == 1 ? true : false );
-#if QC_IV_PRED_CONSTRAINT_H0137
           if( !pcVPS->getNumDirectRefLayers(i) )
           {
             assert( !uiCode );         
           }
-#endif
         }
 #endif
@@ -2037,6 +1861,6 @@
 }
 #endif
-
-#if H_MV_HLS_8_HRD_Q0102_08
+#endif
+#if H_MV
 Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx)
 #else
@@ -2081,10 +1905,6 @@
   sps->inferRepFormat  ( vps , rpcSlice->getLayerId() ); 
   sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) );   
-#if H_MV_HLS_8_HRD_Q0102_08
   sps->inferSpsMaxDecPicBufferingMinus1( vps, targetOlsIdx, rpcSlice->getLayerId(), false ); 
-#endif
-#if H_MV_HLS_8_RPS_Q0100_36
   vps->inferDbpSizeLayerSetZero( sps, false ); 
-#endif
 
   if ( sps->getVuiParametersPresentFlag() )
@@ -2141,5 +1961,5 @@
   }
   
-#if H0044_POC_LSB_NOT_PRESENT
+#if H_MV
     UInt slicePicOrderCntLsb = 0;
 #endif
@@ -2195,7 +2015,4 @@
 
 #if H_MV
-#if !H0044_POC_LSB_NOT_PRESENT
-    UInt slicePicOrderCntLsb = 0;
-#endif
     Int iPOClsb = slicePicOrderCntLsb;  // Needed later
     if ( (rpcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( rpcSlice->getLayerIdInVps())) || !rpcSlice->getIdrPicFlag() )
@@ -2203,7 +2020,5 @@
       READ_CODE(sps->getBitsForPOC(), slicePicOrderCntLsb, "slice_pic_order_cnt_lsb");        
     }    
-#if H_MV_HLS_8_POC_Q0142_32
     rpcSlice->setSlicePicOrderCntLsb( slicePicOrderCntLsb ); 
-#endif
 
     Bool picOrderCntMSBZeroFlag = false;     
@@ -2301,5 +2116,5 @@
       {        
         parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets());
-#if H_MV_HLS_8_RPS_Q0100_36
+#if H_MV
         if ( !rps->getInterRPSPrediction( ) )
         { // check sum of num_positive_pics and num_negative_pics
@@ -2414,5 +2229,5 @@
         rps->setNumberOfPictures(offset);        
       }  
-#if H_MV_HLS_8_RPS_Q0100_36
+#if H_MV
       if ( !rps->getInterRPSPrediction( ) )
       { // check sum of NumPositivePics, NumNegativePics, num_long_term_sps and num_long_term_pics 
@@ -2804,14 +2619,11 @@
       rpcSlice->setPocResetIdc( 0 );
     }
-#if H_MV_HLS_8_POC_Q0142_32
     rpcSlice->checkPocResetIdc(); 
-#endif
-
-#if H0044_POC_LSB_NOT_PRESENT
+
     if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && slicePicOrderCntLsb > 0 )
     {
       assert( rpcSlice->getPocResetIdc() != 2 );
     }
-#endif
+
     if( rpcSlice->getPocResetIdc() !=  0 )
     {
@@ -2828,16 +2640,6 @@
       READ_FLAG( uiCode, "full_poc_reset_flag" ); rpcSlice->setFullPocResetFlag( uiCode == 1 );
       READ_CODE( rpcSlice->getPocLsbValLen() , uiCode, "poc_lsb_val" ); rpcSlice->setPocLsbVal( uiCode );
-#if !H_MV_HLS_8_POC_Q0142_32
-#if H0044_POC_LSB_NOT_PRESENT
-      if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() )
-      {
-        assert( rpcSlice->getPocLsbVal() == 0 );
-      }
-#endif
-#endif
     }          
-#if H_MV_HLS_8_POC_Q0142_32
     rpcSlice->checkPocLsbVal(); 
-#endif
 
     // Derive the value of PocMs8bValRequiredFlag
@@ -2852,16 +2654,5 @@
     else
     {
-#if H_MV_HLS_8_POC_Q0146_15
       rpcSlice->setPocMsbValPresentFlag( rpcSlice->inferPocMsbValPresentFlag( ) ); 
-#else
-      if( rpcSlice->getPocMsbValRequiredFlag() )
-      {
-        rpcSlice->setPocMsbValPresentFlag( true );
-      }
-      else
-      {
-        rpcSlice->setPocMsbValPresentFlag( false );
-      }
-#endif
     }
 
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 964)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 976)
@@ -109,5 +109,5 @@
   Void  parseProfileTier    (ProfileTierLevel *ptl);
   Void  parseHrdParameters  (TComHRD *hrd, Bool cprms_present_flag, UInt tempLevelHigh);
-#if H_MV_HLS_8_HRD_Q0102_08
+#if H_MV
   Void  parseSliceHeader    ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx);
 #else
Index: trunk/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 964)
+++ trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 976)
@@ -432,17 +432,10 @@
     m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
     m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours 
-#if !ETRIKHU_CLEANUP_H0083
-      ,vspFlag
-#endif
       , inheritedVSPDisInfo
 #if H_3D_SPIVMP
-#if !ETRIKHU_CLEANUP_H0083_MISSING
-      , bSPIVMPFlag
-#endif
       , pcMvFieldSP, puhInterDirSP
 #endif
       , numValidMergeCand, uiMergeIndex );
 
-#if ETRIKHU_CLEANUP_H0083
     m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
 #if H_3D_SPIVMP
@@ -450,5 +443,4 @@
 #endif
       , numValidMergeCand );
-#endif
     pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
 #else
@@ -797,13 +789,8 @@
     }
     
-#if RWTH_DBBP_NO_SPU_H0057
     AOF( pcCU->getARPW(uiPartAddr) == 0 );
     AOF( pcCU->getICFlag(uiPartAddr) == false );
     AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false );
     AOF( pcCU->getVSPFlag(uiPartAddr) == 0 );
-#else
-    pDBBPTmpData->ahVSPFlag[uiSegment] = pcCU->getVSPFlag( uiPartAddr );
-    pDBBPTmpData->acDvInfo[uiSegment] = pcCU->getDvInfo( uiPartAddr );
-#endif
   }
   
@@ -814,10 +801,5 @@
   {
     pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth );
-    
-#if !RWTH_DBBP_NO_SPU_H0057
-    pcCU->setVSPFlagSubParts( pDBBPTmpData->ahVSPFlag[uiSegment], 0, 0, uiDepth );
-    pcCU->setDvInfoSubParts( pDBBPTmpData->acDvInfo[uiSegment], 0, 0, uiDepth );
-#endif
-    
+  
     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
     {
@@ -839,10 +821,4 @@
     
     pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth);
-    
-#if !RWTH_DBBP_NO_SPU_H0057
-    pcCU->setVSPFlagSubParts( pDBBPTmpData->ahVSPFlag[uiSegment], uiPartAddr, uiSegment, uiDepth );
-    pcCU->setDvInfoSubParts( pDBBPTmpData->acDvInfo[uiSegment], uiPartAddr, uiSegment, uiDepth );
-#endif
-    
     pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level
     
@@ -946,16 +922,5 @@
     for( UInt uiX = 0; uiX < uiWidth; uiX++ )
     {
-#if H_3D && !SEC_NO_RESI_DLT_H0105
-      if ( useDltFlag )
-      {
-        pReco    [ uiX ] = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) );
-      }
-      else
-      {
-        pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
-      }
-#else
       pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
-#endif
       pRecIPred[ uiX ] = pReco[ uiX ];
     }
@@ -1257,5 +1222,4 @@
   // get DC prediction for each segment
   Pel apDCPredValues[2];
-#if HS_DMM_SDC_PREDICTOR_UNIFY_H0108
   if ( getDimType( uiLumaPredMode ) == DMM1_IDX || getDimType( uiLumaPredMode ) == DMM4_IDX )
   {
@@ -1264,6 +1228,7 @@
   }
   else
-#endif
-  m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode);
+  {
+    m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode);
+  }
   
   // reconstruct residual based on mask + DC residuals
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 964)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 976)
@@ -140,9 +140,5 @@
 #if H_3D_DBBP
 
-#if MTK_DBBP_SIGNALING_H0094
   if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) )
-#else
-  if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && pcCU->getPartitionSize(uiAbsPartIdx) == RWTH_DBBP_PACK_MODE )
-#endif
   {
     decodeDBBPFlag(pcCU, uiAbsPartIdx, uiDepth);
@@ -150,7 +146,4 @@
     if( pcCU->getDBBPFlag(uiAbsPartIdx) )
     {
-#if !MTK_DBBP_SIGNALING_H0094
-      AOF( pcCU->getPartitionSize(uiAbsPartIdx) == RWTH_DBBP_PACK_MODE );
-#endif
       
       // get collocated depth block
@@ -169,10 +162,8 @@
       pcCU->setPartSizeSubParts(eVirtualPartSize, uiAbsPartIdx, uiDepth);
       
-#if RWTH_DBBP_NO_SPU_H0057
       // make sure that DBBP flag is set for both segments
       UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
       pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx, 0, uiDepth);
       pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx+uiPUOffset, 1, uiDepth);
-#endif
     }
   }
@@ -210,12 +201,4 @@
     return;
   }
-#if !MTK_SDC_FLAG_FIX_H0095
-#if H_3D_DIM_SDC
-  if( pcCU->getSDCFlag(uiAbsPartIdx) )
-  {
-    return;
-  }
-#endif
-#endif
   
   m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
@@ -309,17 +292,9 @@
           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
           pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
-#if !ETRIKHU_CLEANUP_H0083
-            ,vspFlag
-#endif
             , inheritedVSPDisInfo
 #if H_3D_SPIVMP
-#if !ETRIKHU_CLEANUP_H0083_MISSING
-            , bSPIVMPFlag
-#endif
             , pcMvFieldSP, puhInterDirSP
 #endif
             , numValidMergeCand );
-
-#if ETRIKHU_CLEANUP_H0083
           pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
 #if H_3D_SPIVMP
@@ -327,5 +302,4 @@
 #endif
             , numValidMergeCand );
-#endif
           pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
 
@@ -361,17 +335,9 @@
         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
         pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
-#if !ETRIKHU_CLEANUP_H0083
-          , vspFlag
-#endif
           , inheritedVSPDisInfo
 #if H_3D_SPIVMP
-#if !ETRIKHU_CLEANUP_H0083_MISSING
-            , bSPIVMPFlag
-#endif
           , pcMvFieldSP, puhInterDirSP
 #endif
           ,numValidMergeCand, uiMergeIndex );
-
-#if ETRIKHU_CLEANUP_H0083
         pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
 #if H_3D_SPIVMP
@@ -379,5 +345,4 @@
 #endif
           ,numValidMergeCand );
-#endif
         pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
         if(vspFlag[uiMergeIndex])
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 964)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 976)
@@ -77,5 +77,5 @@
 #endif
 
-#if H_MV_HLS_8_HRD_Q0102_08
+#if H_MV
   virtual Void parseSliceHeader          ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx )       = 0;
 #else
@@ -164,5 +164,5 @@
   Void    decodePPS                   ( TComPPS* pcPPS )    { m_pcEntropyDecoderIf->parsePPS(pcPPS);                    }
 #endif
-#if H_MV_HLS_8_HRD_Q0102_08
+#if H_MV
   Void    decodeSliceHeader           ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx)  { m_pcEntropyDecoderIf->parseSliceHeader(rpcSlice, parameterSetManager, targetOlsIdx );         }
 #else
Index: trunk/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 964)
+++ trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 976)
@@ -248,13 +248,4 @@
     calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), hash);
   }
-
-#if !H_MV_HLS_7_VPS_P0300_27
-#if SETTING_PIC_OUTPUT_MARK
-  rpcPic->setOutputMark(rpcPic->getSlice(0)->getPicOutputFlag() ? true : false);
-#else
-  rpcPic->setOutputMark(true);
-#endif
-  rpcPic->setReconMark(true);
-#endif
 }
 
Index: trunk/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 964)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 976)
@@ -87,7 +87,4 @@
 , m_cDdcDataSCModel           ( 1,             1,               NUM_DDC_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cAngleFlagSCModel         ( 1,             1,               NUM_ANGLE_FLAG_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
-#if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092
-, m_cDmm1DataSCModel          ( 1,             1,               NUM_DMM1_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
 #if H_3D_DIM_SDC
 , m_cSDCResidualFlagSCModel     ( 1,             1,             SDC_NUM_RESIDUAL_FLAG_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
@@ -171,7 +168,4 @@
   m_cDdcDataSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DDC_DATA );
   m_cAngleFlagSCModel.initBuffer         ( sliceType, qp, (UChar*)INIT_ANGLE_FLAG );
-#if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092
-  m_cDmm1DataSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_DMM1_DATA );
-#endif
 #if H_3D_DIM_SDC
   m_cSDCResidualFlagSCModel.initBuffer    ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
@@ -241,7 +235,4 @@
   m_cDdcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );
   m_cAngleFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG );
-#if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092
-  m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
-#endif
 #if H_3D_DIM_SDC
   m_cSDCResidualFlagSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
@@ -386,9 +377,5 @@
     uiCount++;
   }
-#if QC_SIMP_DELTADC_CODING_H0131
   while( uiSymbol && ( uiCount != 3 ) );
-#else
-  while( uiSymbol && ( uiCount != 13 ) );
-#endif
   ruiSymbol = uiCount - 1;
 
@@ -426,9 +413,5 @@
   for( Int i = 0; i < iNumBit; i++ )
   {
-#if MTK_DMM_SIMP_CODE_H0092
-      m_pcTDecBinIf->decodeBinEP( uiSymbol );
-#else
-    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm1DataSCModel.get(0, 0, 0) );
-#endif
+    m_pcTDecBinIf->decodeBinEP( uiSymbol );
     uiIdx += uiSymbol << i;
   }
@@ -1137,9 +1120,5 @@
   if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed
   {
-#if LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135
     m_pcTDecBinIf->decodeBin( uiSymbol, m_cAngleFlagSCModel.get( 0, 0, 0 ) );
-#else
-    m_pcTDecBinIf->decodeBin( uiSymbol, m_cAngleFlagSCModel.get( 0, 0, pcCU->getCtxAngleFlag( absPartIdx ) ) );
-#endif
   }
   else
@@ -2081,9 +2060,5 @@
     UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
     uiNumSegments = isDimMode( dir ) ? 2 : 1;
-#if MTK_DELTA_DC_FLAG_ONE_CONTEXT_H0084_H0100_H0113
     m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get( 0, 0, 0 ) );
-#else
-    m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get( 0, 0, uiNumSegments-1 ) );
-#endif
     if( pcCU->getSDCFlag( absPartIdx ) )
     {
@@ -2156,12 +2131,6 @@
 Void TDecSbac::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
-#if !MTK_DBBP_SIGNALING_H0094
-  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
-#endif
   AOF( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) );
   AOF( !pcCU->getSlice()->getIsDepth() );
-#if !MTK_DBBP_SIGNALING_H0094
-  AOF( ePartSize == RWTH_DBBP_PACK_MODE );
-#endif
   
   UInt uiSymbol = 0;
@@ -2172,8 +2141,6 @@
   {
     pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx, 0, uiDepth);
-#if MTK_DIS_SPBIP8X4_H0205
     UInt uiCurrPartNumQ = (pcCU->getPic()->getNumPartInCU() >> (2 * uiDepth)) >> 2;
     pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx + 2*uiCurrPartNumQ, 1, uiDepth);
-#endif
   }
 }
Index: trunk/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 964)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 976)
@@ -87,8 +87,8 @@
 #endif
 
-#if H_MV_HLS_8_HRD_Q0102_08
+#if H_MV
   Void  parseSliceHeader          ( TComSlice*& /*rpcSlice*/, ParameterSetManagerDecoder* /*parameterSetManager*/, Int targetOlsIdx ) {}
 #else
-  Void  parseSliceHeader          ( TComSlice*& /*rpcSlice*/, ParameterSetManagerDecoder* /*parameterSetManager*/) {}
+  Void  parseSliceHeader          ( TComSlice*& /*rpcSlice*/, ParameterSetManagerDecoder* /*parameterSetManager*/ ) {}
 #endif
   Void  parseTerminatingBit       ( UInt& ruiBit );
@@ -218,7 +218,4 @@
   ContextModel3DBuffer m_cDdcDataSCModel;
   ContextModel3DBuffer m_cAngleFlagSCModel;
-#if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092
-  ContextModel3DBuffer m_cDmm1DataSCModel;
-#endif
 #if H_3D_DIM_SDC  
   ContextModel3DBuffer m_cSDCResidualFlagSCModel;
Index: trunk/source/Lib/TLibDecoder/TDecSlice.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 964)
+++ trunk/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 976)
@@ -221,5 +221,5 @@
     }
   }
-#if  MTK_DLT_CODING_FIX_H0091
+#if  H_3D
   if( pcSlice->getPPS()->getDLT() != NULL )
   {
Index: trunk/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 964)
+++ trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 976)
@@ -371,8 +371,6 @@
   m_isNoOutputPriorPics = false;
 #endif
-#if H0056_EOS_CHECKS
+#if H_MV
   m_isLastNALWasEos = false;
-#endif
-#if H_MV
   m_layerId = 0;
   m_viewId = 0;
@@ -382,5 +380,5 @@
   m_pcCamParsCollector = 0;
 #endif
-#if H_MV_HLS_8_HRD_Q0102_08
+#if H_MV
   m_targetOptLayerSetIdx = -1; 
 #endif
@@ -511,5 +509,5 @@
     {
       rpcPic->setOutputMark(false);
-#if H_MV_HLS_7_VPS_P0300_27
+#if H_MV
       rpcPic->setPicOutputFlag(false); 
 #endif
@@ -521,5 +519,5 @@
     {
       rpcPic->setOutputMark(false);
-#if H_MV_HLS_7_VPS_P0300_27
+#if H_MV
       rpcPic->setPicOutputFlag(false); 
 #endif
@@ -568,7 +566,4 @@
   TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 );  
   TComSlice::markCurrPic( pcPic ); 
-#if !H_MV_HLS_8_DBP_NODOC_42
-  TComSlice::markIvRefPicsAsUnused   ( m_ivPicLists, targetDecLayerIdSet, m_parameterSetManagerDecoder.getActiveVPS(), m_layerId, poc ); 
-#endif
 #endif
   m_bFirstSliceInPicture  = true;
@@ -590,5 +585,5 @@
     {
       pcPicTmp->setOutputMark(false);
-#if H_MV_HLS_7_VPS_P0300_27
+#if H_MV
       pcPicTmp->setPicOutputFlag(false); 
 #endif
@@ -670,13 +665,7 @@
   }
 
-#if H_MV_HLS_8_HRD_Q0102_08
+#if H_MV
   sps->inferSpsMaxDecPicBufferingMinus1( vps, m_targetOptLayerSetIdx, getLayerId(), false ); 
-#endif
-
-#if H_MV_HLS_8_RPS_Q0100_36
   vps->inferDbpSizeLayerSetZero( sps, false ); 
-#endif
-
-#if H_MV_HLS_8_PMS_Q0195_21
   // When the value of vps_num_rep_formats_minus1 in the active VPS is equal to 0
   if ( vps->getVpsNumRepFormatsMinus1() == 0 )
@@ -685,11 +674,5 @@
     assert( sps->getUpdateRepFormatFlag() == false ); 
   }
-#endif
-
-#if H_MV_HLS_8_RPS_Q0100_36
   sps->checkRpsMaxNumPics( vps, getLayerId() ); 
-#endif
-
-#if H_MV_HLS_8_MIS_Q0177_22
   if( m_layerId > 0 )
   {
@@ -787,10 +770,5 @@
   m_apcSlicePilot->setRefPicSetInterLayer( & m_refPicSetInterLayer0, &m_refPicSetInterLayer1 ); 
   m_apcSlicePilot->setLayerId( nalu.m_layerId );
-#endif
-
-#if H_MV_HLS_8_HRD_Q0102_08
   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_targetOptLayerSetIdx );
-#else
-  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
 #endif
   // set POC for dependent slices in skipped pictures
@@ -1340,5 +1318,5 @@
     case NAL_UNIT_VPS:
       xDecodeVPS();
-#if H0056_EOS_CHECKS
+#if H_MV
       m_isLastNALWasEos = false;
 #endif
@@ -1355,5 +1333,5 @@
     case NAL_UNIT_PREFIX_SEI:
     case NAL_UNIT_SUFFIX_SEI:
-#if H0056_EOS_CHECKS
+#if H_MV
       if ( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_SEI )
       {
@@ -1380,5 +1358,5 @@
     case NAL_UNIT_CODED_SLICE_RASL_N:
     case NAL_UNIT_CODED_SLICE_RASL_R:
-#if H0056_EOS_CHECKS
+#if H_MV
       if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N ||
           nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N ||
@@ -1393,6 +1371,5 @@
         m_isLastNALWasEos = false;
       }
-#endif
-#if H_MV
+
       return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag );
 #else
@@ -1401,5 +1378,5 @@
       break;
     case NAL_UNIT_EOS:
-#if H0056_EOS_CHECKS
+#if H_MV
       assert( m_isLastNALWasEos == false );
       //Check layer id of the nalu. if it is not 0, give a warning message and just return without doing anything.
Index: trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 964)
+++ trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 976)
@@ -195,7 +195,5 @@
   Bool*                    m_layerInitilizedFlag; // initialization Layers
   static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets 
-#if  H_MV_HLS_8_HRD_Q0102_08
   Int                      m_targetOptLayerSetIdx; 
-#endif
 #else
   ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets 
@@ -234,5 +232,5 @@
   Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
 #endif
-#if H0056_EOS_CHECKS
+#if H_MV
   Bool                    m_isLastNALWasEos;
 #endif
@@ -271,7 +269,5 @@
   Void  deletePicBuffer();
 #if H_MV
-#if H_MV_HLS_7_VPS_P0300_27
   TComVPS* getActiveVPS() { return m_parameterSetManagerDecoder.getActiveVPS( ); }
-#endif
   TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS( m_layerId ); }
 #else
@@ -296,7 +292,5 @@
   Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
   Void                    setLayerInitilizedFlags( Bool* val )    { m_layerInitilizedFlag = val; }
-#if  H_MV_HLS_8_HRD_Q0102_08
   Void                    setTargetOptLayerSetIdx( Int targetOptLayerSetIdx ) { m_targetOptLayerSetIdx = targetOptLayerSetIdx; }    
-#endif
   TComVPS*                getPrefetchedVPS      ()               { return m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); }; //Assuming that currently only one VPS is present. 
   Int                     getCurrPoc            ()               { return m_apcSlicePilot->getPOC(); }
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 964)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 976)
@@ -273,13 +273,9 @@
   WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
 
-  #if MTK_DLT_CODING_FIX_H0091
+  #if H_3D
     if(( !pcPPS->getSPS()->getVPS()->getDepthId( pcPPS->getSPS()->getLayerId() ) )||
         pcPPS->getLayerId() != 1  )
     {
-#if H_MV_HLS_8_SPS_NODOC_48
       pcPPS->setPps3dExtensionFlag( false ); 
-#else
-      pcPPS->setPpsExtensionTypeFlag( PPS_EX_T_3D, false );
-#endif
     }
   #endif
@@ -290,5 +286,4 @@
   WRITE_FLAG( 1, "pps_extension_present_flag" );
 
-#if H_MV_HLS_8_SPS_NODOC_48
     WRITE_FLAG( pcPPS->getPpsRangeExtensionsFlag( ) ? 1 : 0 , "pps_range_extensions_flag" );
     WRITE_FLAG( pcPPS->getPpsMultilayerExtensionFlag( ) ? 1 : 0 , "pps_multilayer_extension_flag" );
@@ -307,7 +302,5 @@
     { 
       WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag( ) ? 1 : 0 , "poc_reset_info_present_flag" );
-#if H_MV_HLS_8_PPS_NODOC_NN
       WRITE_FLAG( 0, "pps_extension_reserved_zero_flag" );
-#endif
     }
 
@@ -318,28 +311,4 @@
     }
 #endif
-#else
-  for ( Int i = 0; i < PPS_EX_T_MAX_NUM; i++ )
-  {
-    WRITE_FLAG( pcPPS->getPpsExtensionTypeFlag( i ) ? 1 : 0 , "pps_extension_type_flag" );
-#if H_3D
-    assert( !pcPPS->getPpsExtensionTypeFlag( i ) || i == PPS_EX_T_MV || i == PPS_EX_T_3D || i == PPS_EX_T_ESC ); 
-#else
-    assert( !pcPPS->getPpsExtensionTypeFlag( i ) || i == PPS_EX_T_MV || i == PPS_EX_T_ESC ); 
-#endif
-  }
-
-  if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_MV ) )
-  {
-    WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag( ) ? 1 : 0 , "poc_reset_info_present_flag" );
-  }
-
-#if H_3D
-  if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_3D ) ) // This probably needs to be aligned with Rext and SHVC
-  {
-    codePPSExtension( pcPPS ); 
-  }
-#endif
-#endif
-
 #endif
 
@@ -861,14 +830,13 @@
   if ( pcSPS->getSpsExtensionPresentFlag() )
   {
-#if H_MV_HLS_8_SPS_NODOC_48
     WRITE_FLAG( pcSPS->getSpsRangeExtensionsFlag( ) ? 1 : 0 , "sps_range_extensions_flag" );
     WRITE_FLAG( pcSPS->getSpsMultilayerExtensionFlag( ) ? 1 : 0 , "sps_multilayer_extension_flag" );
 #if !H_3D
-    WRITE_CODE( pcSPS->getSpsExtension6bits( ), 6, "sps_extension_6bits" );
+    WRITE_CODE( pcSPS->getSpsExtension6bits( ), 6, "sps_extension_6bits" );  
 #else
     WRITE_FLAG( pcSPS->getSps3dExtensionFlag( ) ? 1 : 0 , "sps_3d_extension_flag" );
     WRITE_CODE( pcSPS->getSpsExtension5bits( ), 5, "sps_extension_5bits" );
 #endif
- }
+  }
 
   if ( pcSPS->getSpsRangeExtensionsFlag() )
@@ -889,29 +857,6 @@
 
 #endif
-#else
-    for (Int i = 0; i < PS_EX_T_MAX_NUM; i++)
-    {
-      WRITE_FLAG( pcSPS->getSpsExtensionTypeFlag( i ) ? 1 : 0 , "sps_extension_type_flag" );
-#if H_3D
-      assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV || i == PS_EX_T_3D ); 
-#else
-      assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV ); 
-#endif
-    }  
-
-    if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_MV ))
-    {
-      codeSPSExtension( pcSPS ); 
-    }
-
-#if H_3D
-    if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_3D ))
-    {
-      codeSPSExtension2( pcSPS, viewIndex, depthFlag ); 
-    }
-#endif
-  }
-#endif
-#endif
+#endif
+
 }
 
@@ -955,5 +900,5 @@
 {
   WRITE_CODE( pcVPS->getVPSId(),                    4,        "vps_video_parameter_set_id" );
-#if H_MV_HLS_8_SYN_Q0041_03
+#if H_MV
   WRITE_FLAG( pcVPS->getVpsBaseLayerInternalFlag( ) ? 1 : 0 , "vps_base_layer_internal_flag" );
   WRITE_FLAG( 1                                             , "vps_reserved_one_bit" );
@@ -1042,9 +987,5 @@
   }
 #if H_MV
-#if H_MV_HLS_8_RPS_Q0100_36
   WRITE_FLAG( pcVPS->getVpsExtensionFlag(),                     "vps_extension_flag" );
-#else
-  WRITE_FLAG( 1,                     "vps_extension_flag" );
-#endif
   m_pcBitIf->writeAlignOne();
   codeVPSExtension( pcVPS );                           
@@ -1069,10 +1010,5 @@
 #if H_MV
 Void TEncCavlc::codeVPSExtension( TComVPS *pcVPS ) 
-{
-  
-#if !H_MV_HLS_8_SYN_Q0041_03
-  WRITE_FLAG( pcVPS->getAvcBaseLayerFlag() ? 1 : 0,          "avc_base_layer_flag" );
-#endif
-
+{  
   WRITE_FLAG( pcVPS->getSplittingFlag() ? 1 : 0,             "splitting_flag" );
 
@@ -1187,5 +1123,4 @@
   }
 
-#if H_MV_HLS_8_SYN_39_19
   if ( pcVPS->getNumIndependentLayers() > 1 ) 
   {
@@ -1204,12 +1139,4 @@
     WRITE_CODE( pcVPS->getDefaultOutputLayerIdc( ), 2, "default_output_layer_idc" );
   }
-#else
-  WRITE_UVLC( pcVPS->getNumAddLayerSets( ), "num_add_layer_sets" );
-
-  if( pcVPS->getNumOutputLayerSets() > 1)
-  {
-    WRITE_CODE( pcVPS->getDefaultOutputLayerIdc( ), 2, "default_output_layer_idc" );
-  }  
-#endif
 
   assert( pcVPS->getOutputLayerFlag(0, 0) == pcVPS->inferOutputLayerFlag( 0, 0 )); 
@@ -1221,9 +1148,5 @@
   for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ )
   {
-#if H_MV_HLS_8_SYN_39_19
     if( i >= pcVPS->getNumLayerSets( ) )    
-#else
-    if( i > pcVPS->getVpsNumLayerSetsMinus1( ) )    
-#endif
     {      
       WRITE_UVLC( pcVPS->getLayerSetIdxForOlsMinus1( i ),      "layer_set_idx_for_ols_minus1[i]" );
@@ -1256,13 +1179,5 @@
   }
 
-#if !H_MV_HLS_8_PMS_Q0195_20
-  WRITE_FLAG( pcVPS->getRepFormatIdxPresentFlag( ) ? 1 : 0 , "rep_format_idx_present_flag" );
-  if ( pcVPS->getRepFormatIdxPresentFlag() )
-  {
-    WRITE_UVLC( pcVPS->getVpsNumRepFormatsMinus1( ), "vps_num_rep_formats_minus1" );
-  }
-#else
   WRITE_UVLC( pcVPS->getVpsNumRepFormatsMinus1( ), "vps_num_rep_formats_minus1" );
-#endif
 
   for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ )
@@ -1275,42 +1190,23 @@
   }
 
-#if H_MV_HLS_8_PMS_Q0195_20
   if ( pcVPS->getVpsNumRepFormatsMinus1() > 0 )
   {
     WRITE_FLAG( pcVPS->getRepFormatIdxPresentFlag( ) ? 1 : 0 , "rep_format_idx_present_flag" );
   }
-#endif
+
   if( pcVPS->getRepFormatIdxPresentFlag() ) 
   {
-#if H_MV_HLS_8_SYN_Q0041_03
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-#else
-    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-#endif
-    {
-#if !H_MV_HLS_8_PMS_Q0195_20
-      if( pcVPS->getVpsNumRepFormatsMinus1() > 0 )
-      {
-#endif
+    {
         WRITE_CODE( pcVPS->getVpsRepFormatIdx(i), pcVPS->getVpsRepFormatIdxLen(), "vps_rep_format_idx[i]" );
-#if !H_MV_HLS_8_PMS_Q0195_20
-      }
-#endif
-    }
-  }
-#if H_MV_HLS_8_PMS_Q0195_20
+    }
+  }
   else
   {
-#if H_MV_HLS_8_SYN_Q0041_03
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-#else
-    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-#endif
     {
       assert( pcVPS->getVpsRepFormatIdx( i ) ==  pcVPS->inferVpsRepFormatIdx( i ) );
     }
   }
-#endif
-
 
   WRITE_FLAG( pcVPS->getMaxOneActiveRefLayerFlag( ) ? 1 : 0, "max_one_active_ref_layer_flag" );
@@ -1337,13 +1233,7 @@
   }
 
-#if H_MV_HLS_8_SYN_Q0041_03
   for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ?  1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ )
   {
     for( Int j = pcVPS->getVpsBaseLayerInternalFlag() ?  0 : 1; j < i; j++ )
-#else
-  for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
-  {
-    for( Int j = 0; j < i; j++ )
-#endif
     {
       if (pcVPS->getDirectDependencyFlag( i, j) )
@@ -1366,5 +1256,5 @@
 
 
-WRITE_FLAG( pcVPS->getVpsVuiPresentFlag() ? 1 : 0 , "vps_vui_present_flag" );
+  WRITE_FLAG( pcVPS->getVpsVuiPresentFlag() ? 1 : 0 , "vps_vui_present_flag" );
   if( pcVPS->getVpsVuiPresentFlag() )
   {
@@ -1397,13 +1287,7 @@
   for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ )
   {  
-#if H_MV_HLS_8_MIS_Q0102_30
     Int currLsIdx = vps->olsIdxToLsIdx( i ); 
-#endif
     WRITE_FLAG( dpbSize->getSubLayerFlagInfoPresentFlag( i ) ? 1 : 0 , "sub_layer_flag_info_present_flag" );
-#if H_MV_HLS_8_MIS_Q0102_30
     for( Int j = 0; j  <=  vps->getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ )
-#else
-    for( Int j = 0; j  <=  vps->getMaxSubLayersInLayerSetMinus1( i ); j++ )
-#endif
     {  
       if( j > 0  &&  dpbSize->getSubLayerDpbInfoPresentFlag( i, j )  )  
@@ -1413,9 +1297,5 @@
       if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) )
       {  
-#if H_MV_HLS_8_MIS_Q0102_30
         for( Int k = 0; k < vps->getNumLayersInIdList( currLsIdx ); k++ )   
-#else
-        for( Int k = 0; k < vps->getNumSubDpbs( vps->olsIdxToLsIdx( i )); k++ )   
-#endif
         {
           WRITE_UVLC( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ), "max_vps_dec_pic_buffering_minus1" );
@@ -1428,9 +1308,5 @@
         if ( j > 0 )
         {
-#if H_MV_HLS_8_DBP_NODOC_42
           for( Int k = 0; k < vps->getNumLayersInIdList( vps->olsIdxToLsIdx( i ) ); k++ )   
-#else
-          for( Int k = 0; k < vps->getNumSubDpbs( vps->olsIdxToLsIdx( i ) ); k++ )   
-#endif
           {
             assert( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) == dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) );
@@ -1493,15 +1369,7 @@
   if( pcVPSVUI->getBitRatePresentVpsFlag( )  ||  pcVPSVUI->getPicRatePresentVpsFlag( ) )
   {
-#if H_MV_HLS_8_SYN_Q0041_03
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i  <=  pcVPS->getVpsNumLayerSetsMinus1(); i++ )
-#else
-    for( Int i = 0; i  <=  pcVPS->getVpsNumLayerSetsMinus1(); i++ )
-#endif
-    {
-#if H_MV_HLS_8_MIS_Q0102_30
+    {
       for( Int j = 0; j  <=  pcVPS->getMaxSubLayersInLayerSetMinus1( i ); j++ ) 
-#else          
-      for( Int j = 0; j  <=  pcVPS->getMaxTLayers(); j++ ) 
-#endif
       {
         if( pcVPSVUI->getBitRatePresentVpsFlag( ) )
@@ -1563,9 +1431,5 @@
   if( !pcVPSVUI->getTilesNotInUseFlag() ) 
   {      
-#if H_MV_HLS_8_SYN_Q0041_03
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
-#else
-    for( Int i = 0; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
-#endif
     {
       WRITE_FLAG( pcVPSVUI->getTilesInUseFlag( i ) ? 1 : 0 , "tiles_in_use_flag[i]" );
@@ -1575,9 +1439,5 @@
       }
     }  
-#if H_MV_HLS_8_SYN_Q0041_03
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i  <=  pcVPS->getMaxLayersMinus1(); i++ )  
-#else
-    for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )  
-#endif
     {
       for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ )
@@ -1610,20 +1470,16 @@
       for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ )
       {
-#if H_MV_HLS_8_SYN_Q0041_03
         if( pcVPS->getVpsBaseLayerInternalFlag() || pcVPS->getRefLayerId( pcVPS->getLayerIdInNuh( i ), j ) > 0 )
         {        
-#endif
-        WRITE_UVLC( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ), "min_spatial_segment_offset_plus1" );
-        if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 )
-        {
-          WRITE_FLAG( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ? 1 : 0 , "ctu_based_offset_enabled_flag" );
-          if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) )
+          WRITE_UVLC( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ), "min_spatial_segment_offset_plus1" );
+          if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 )
           {
-            WRITE_UVLC( pcVPSVUI->getMinHorizontalCtuOffsetPlus1( i, j ), "min_horizontal_ctu_offset_plus1" );
+            WRITE_FLAG( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ? 1 : 0 , "ctu_based_offset_enabled_flag" );
+            if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) )
+            {
+              WRITE_UVLC( pcVPSVUI->getMinHorizontalCtuOffsetPlus1( i, j ), "min_horizontal_ctu_offset_plus1" );
+            }
           }
         }
-#if H_MV_HLS_8_SYN_Q0041_03
-        }
-#endif
       }
     }
@@ -1673,20 +1529,7 @@
     for( Int i = 0; i < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); i++ )  
     {
-#if H_MV_HLS_8_HRD_Q0101_04
       for( Int j = 0; j < pcVPS->getNumLayersInIdList( h ); j++ )  
       {
         WRITE_FLAG( vpsVuiBspHrdP->getLayerInBspFlag( h, i, j ) ? 1 : 0 , "layer_in_bsp_flag" );
-#else
-      for( Int j = 0; j <= pcVPS->getMaxLayersMinus1(); j++ )  
-      {
-        if( pcVPS->getLayerIdIncludedFlag( h ,j ) )
-        {
-          WRITE_FLAG( vpsVuiBspHrdP->getLayerInBspFlag( h, i, j ) ? 1 : 0 , "layer_in_bsp_flag" );
-        }
-        else
-        {
-          vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, false ); // This inference seems to be missing in spec 
-        }
-#endif
       }
     }
@@ -1696,22 +1539,12 @@
     { 
       WRITE_UVLC( vpsVuiBspHrdP->getNumBspSchedCombinationsMinus1( h ), "num_bsp_sched_combinations_minus1" );
-#if H_MV_HLS_8_HRD_Q0182_05
       for( Int i = 0; i <= vpsVuiBspHrdP->getNumBspSchedCombinationsMinus1( h ); i++ )
-#else
-      for( Int i = 0; i < vpsVuiBspHrdP->getNumBspSchedCombinationsMinus1( h ); i++ )
-#endif
       {
         for( Int j = 0; j < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); j++ )
         {  
-#if H_MV_HLS_8_HRD_Q0101_04
           WRITE_CODE( vpsVuiBspHrdP->getBspCombHrdIdx( h, i, j ),  vpsVuiBspHrdP->getBspCombHrdIdxLen(), "bsp_comb_hrd_idx" ); 
-#else
-          WRITE_UVLC( vpsVuiBspHrdP->getBspCombHrdIdx( h, i, j ), "bsp_comb_hrd_idx" );
-#endif
           WRITE_UVLC( vpsVuiBspHrdP->getBspCombSchedIdx( h, i, j ), "bsp_comb_sched_idx" );
 
-#if H_MV_HLS_8_HRD_Q0101_04
           vpsVuiBspHrdP->checkBspCombHrdAndShedIdx( pcVPS, h, i, j ); 
-#endif
         }  
       }
@@ -1907,7 +1740,5 @@
       Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
       WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "slice_pic_order_cnt_lsb");
-#if H_MV_HLS_8_POC_Q0142_32
       pcSlice->setSlicePicOrderCntLsb( picOrderCntLSB ); 
-#endif
     }
 
@@ -2341,7 +2172,5 @@
     }
 
-#if H_MV_HLS_8_POC_Q0142_32
     pcSlice->checkPocResetIdc(); 
-#endif
 
     if( pcSlice->getPocResetIdc() !=  0 )
@@ -2355,7 +2184,5 @@
       WRITE_CODE( pcSlice->getPocLsbVal( ), pcSlice->getPocLsbValLen() , "poc_lsb_val" );
     }              
-#if H_MV_HLS_8_POC_Q0142_32
     pcSlice->checkPocLsbVal(); 
-#endif
 
     if( !pcSlice->getPocMsbValRequiredFlag() /* TODO &&  pcSlice->getVPS()->getVpsPocLsbAlignedFlag() */ )
@@ -2363,10 +2190,8 @@
       WRITE_FLAG( pcSlice->getPocMsbValPresentFlag( ) ? 1 : 0 , "poc_msb_val_present_flag" );
     }
-#if H_MV_HLS_8_POC_Q0146_15
     else
     {
       assert( pcSlice->getPocMsbValPresentFlag() ==  pcSlice->inferPocMsbValPresentFlag( ) ); 
     }
-#endif
     
     if( pcSlice->getPocMsbValPresentFlag() )
Index: trunk/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 964)
+++ trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 976)
@@ -403,7 +403,5 @@
 #if H_3D_IC
   Bool      m_bUseIC;
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
   Bool      m_bUseICLowLatencyEnc;
-#endif
 #endif
 #if H_3D_INTER_SDC
@@ -516,8 +514,6 @@
   Void       setUseIC                       ( Bool bVal )    { m_bUseIC = bVal; }
   Bool       getUseIC                       ()               { return m_bUseIC; }
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
   Void       setUseICLowLatencyEnc          ( Bool bVal )    { m_bUseICLowLatencyEnc = bVal; }
   Bool       getUseICLowLatencyEnc          ()               { return m_bUseICLowLatencyEnc; }
-#endif
 #endif
 #if H_3D_INTER_SDC
Index: trunk/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 964)
+++ trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 976)
@@ -1815,12 +1815,6 @@
     rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
-#if !ETRIKHU_CLEANUP_H0083
-      , vspFlag
-#endif
       , inheritedVSPDisInfo
 #if H_3D_SPIVMP
-#if !ETRIKHU_CLEANUP_H0083_MISSING
-      , bSPIVMPFlag
-#endif
       , pcMvFieldSP, puhInterDirSP
 #endif
@@ -1828,5 +1822,4 @@
       );
 
-#if ETRIKHU_CLEANUP_H0083
     rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag
 #if H_3D_SPIVMP
@@ -1835,5 +1828,4 @@
       , numValidMergeCand 
       );
-#endif
 
 #else
@@ -2400,11 +2392,6 @@
     pDBBPTmpData->auhMergeIndex[uiSegment] = rpcTempCU->getMergeIndex(0);
     
-#if RWTH_DBBP_NO_SPU_H0057
     AOF( rpcTempCU->getSPIVMPFlag(0) == false );
     AOF( rpcTempCU->getVSPFlag(0) == 0 );
-#else
-    pDBBPTmpData->ahVSPFlag[uiSegment] = rpcTempCU->getVSPFlag(0);
-    pDBBPTmpData->acDvInfo[uiSegment] = rpcTempCU->getDvInfo(0);
-#endif
     
     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
@@ -2437,10 +2424,5 @@
     rpcTempCU->setMergeFlagSubParts(pDBBPTmpData->abMergeFlag[uiSegment], uiPartAddr, uiSegment, uhDepth);
     rpcTempCU->setMergeIndexSubParts(pDBBPTmpData->auhMergeIndex[uiSegment], uiPartAddr, uiSegment, uhDepth);
-    
-#if !RWTH_DBBP_NO_SPU_H0057
-    rpcTempCU->setVSPFlagSubParts(pDBBPTmpData->ahVSPFlag[uiSegment], uiPartAddr, uiSegment, uhDepth);
-    rpcTempCU->setDvInfoSubParts(pDBBPTmpData->acDvInfo[uiSegment], uiPartAddr, uiSegment, uhDepth);
-#endif
-    
+        
     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
     {
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 964)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 976)
@@ -157,11 +157,12 @@
 
   if( !pcCU->getSlice()->getApplyIC() )
+  {
     return;
-
-  if( bRD )
-  {
-    uiAbsPartIdx = 0;
-  }
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
+  }
+
+  if( bRD )
+  {
+    uiAbsPartIdx = 0;
+  }
   else
   {
@@ -172,7 +173,8 @@
     }
   }
-#endif
   if( pcCU->isICFlagRequired( uiAbsPartIdx ) )
+  {
     m_pcEntropyCoderIf->codeICFlag( pcCU, uiAbsPartIdx );
+  }
 }
 #endif
@@ -255,10 +257,5 @@
   
 #if H_3D_DBBP
-
-#if MTK_DBBP_SIGNALING_H0094
   if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) )
-#else
-  if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && pcCU->getPartitionSize(uiAbsPartIdx) == RWTH_DBBP_PACK_MODE )
-#endif
   {
     encodeDBBPFlag(pcCU, uiAbsPartIdx, bRD);
@@ -266,7 +263,4 @@
     if( pcCU->getDBBPFlag(uiAbsPartIdx) )
     {
-#if !MTK_DBBP_SIGNALING_H0094
-      AOF( pcCU->getPartitionSize(uiAbsPartIdx) == RWTH_DBBP_PACK_MODE );
-#endif
       // restore virtual partition size for DBBP blocks
       pcCU->setPartSizeSubParts(eVirtualPartSize, uiAbsPartIdx, uiDepth);
@@ -290,12 +284,4 @@
     return;
   }
-#if !MTK_SDC_FLAG_FIX_H0095
-#if H_3D_DIM_SDC
-  if( pcCU->getSDCFlag(uiAbsPartIdx) )
-  {
-    return;
-  }
-#endif
-#endif
   
   if( bRD )
Index: trunk/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 964)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 976)
@@ -2325,7 +2325,4 @@
       std::vector<Int> temp; 
       TComSlice::markCurrPic( pcPic ); 
-#if !H_MV_HLS_8_DBP_NODOC_42
-      TComSlice::markIvRefPicsAsUnused   ( m_ivPicLists, temp, pcPic->getSlice(0)->getVPS(), m_layerId, pcPic->getPOC() ); 
-#endif
 #endif
       m_bFirst = false;
Index: trunk/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 964)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 976)
@@ -93,7 +93,4 @@
 , m_cDdcDataSCModel           ( 1,             1,               NUM_DDC_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cAngleFlagSCModel         ( 1,             1,               NUM_ANGLE_FLAG_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
-#if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092
-, m_cDmm1DataSCModel          ( 1,             1,               NUM_DMM1_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
 #if H_3D_DIM_SDC
 , m_cSDCResidualFlagSCModel   ( 1,             1,               SDC_NUM_RESIDUAL_FLAG_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
@@ -169,7 +166,4 @@
   m_cDdcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );
   m_cAngleFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG );
-#if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092
-  m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
-#endif
 #if H_3D_DIM_SDC
   m_cSDCResidualFlagSCModel.initBuffer   ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
@@ -255,7 +249,4 @@
       curCost += m_cDdcDataSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_DDC_DATA );
       curCost += m_cAngleFlagSCModel.calcCost         ( curSliceType, qp, (UChar*)INIT_ANGLE_FLAG );  
-#if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092
-      curCost += m_cDmm1DataSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_DMM1_DATA );
-#endif
     }
 #endif
@@ -319,7 +310,4 @@
   m_cDdcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );
   m_cAngleFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG );
-#if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092
-  m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
-#endif
 #if H_3D_DIM_SDC
   m_cSDCResidualFlagSCModel.initBuffer   ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
@@ -482,13 +470,7 @@
     m_pcBinIf->encodeBin( 1, rcSCModel );
     UInt uiCount = 0;
-#if QC_SIMP_DELTADC_CODING_H0131
     Bool bNoExGo = ( uiSymbol < 3 );
 
     while( --uiSymbol && ++uiCount < 3 )
-#else
-    Bool bNoExGo = (uiSymbol < 13);
-
-    while( --uiSymbol && ++uiCount < 13 )
-#endif
     {
       m_pcBinIf->encodeBin( 1, rcSCModel );
@@ -526,9 +508,5 @@
   for ( Int i = 0; i < iNumBit; i++ )
   {
-#if MTK_DMM_SIMP_CODE_H0092
-      m_pcBinIf->encodeBinEP( ( uiTabIdx >> i ) & 1 );
-#else
-    m_pcBinIf->encodeBin( ( uiTabIdx >> i ) & 1, m_cDmm1DataSCModel.get(0, 0, 0) );
-#endif
+    m_pcBinIf->encodeBinEP( ( uiTabIdx >> i ) & 1 );
   }
 }
@@ -1243,9 +1221,5 @@
   if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed
   {
-#if LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135
     m_pcBinIf->encodeBin( isDimMode( dir ) ? 0 : 1, m_cAngleFlagSCModel.get( 0, 0, 0 ) );
-#else
-    m_pcBinIf->encodeBin( isDimMode( dir ) ? 0 : 1, m_cAngleFlagSCModel.get( 0, 0, pcCU->getCtxAngleFlag( absPartIdx ) ) );
-#endif
   }
   if( isDimMode( dir ) )
@@ -2327,9 +2301,5 @@
       dimDeltaDC = isDimDeltaDC( dir );
     }
-#if MTK_DELTA_DC_FLAG_ONE_CONTEXT_H0084_H0100_H0113
     m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get( 0, 0, 0 ) );
-#else
-    m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get( 0, 0, uiNumSegments-1 ) );
-#endif
   }
   else //all-zero inter SDC is not allowed
@@ -2373,8 +2343,4 @@
 Void TEncSbac::codeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
-#if !MTK_DBBP_SIGNALING_H0094
-  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
-  AOF( ePartSize == RWTH_DBBP_PACK_MODE );
-#endif
   AOF( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) );
   AOF( !pcCU->getSlice()->getIsDepth() );
Index: trunk/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 964)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 976)
@@ -258,7 +258,4 @@
   ContextModel3DBuffer m_cDdcDataSCModel;
   ContextModel3DBuffer m_cAngleFlagSCModel;
-#if H_3D_DIM_DMM && !MTK_DMM_SIMP_CODE_H0092
-  ContextModel3DBuffer m_cDmm1DataSCModel;
-#endif
 #if H_3D_DIM_SDC  
   ContextModel3DBuffer m_cSDCResidualFlagSCModel;
Index: trunk/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 964)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 976)
@@ -1146,16 +1146,5 @@
         for( UInt uiX = 0; uiX < uiWidth; uiX++ )
         {
-#if H_3D_DIM && !SEC_NO_RESI_DLT_H0105
-          if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
-          {
-            pResi[ uiX ] = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pOrg[ uiX ] ) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] );
-          }
-          else
-          {
-            pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];
-          }
-#else
           pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];
-#endif
         }
         pOrg  += uiStride;
@@ -1221,16 +1210,5 @@
       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
       {
-#if H_3D_DIM && !SEC_NO_RESI_DLT_H0105
-        if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
-        {
-          pReco    [ uiX ] = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) );
-        }
-        else
-        {
-          pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
-        }
-#else
         pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
-#endif
         pRecQt   [ uiX ] = pReco[ uiX ];
         pRecIPred[ uiX ] = pReco[ uiX ];
@@ -1989,5 +1967,4 @@
   // get DC prediction for each segment
   Pel apDCPredValues[2];
-#if HS_DMM_SDC_PREDICTOR_UNIFY_H0108
   if ( getDimType( uiLumaPredMode ) == DMM1_IDX || getDimType( uiLumaPredMode ) == DMM4_IDX )
   {
@@ -1996,6 +1973,8 @@
   }
   else
-#endif
-  analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode );
+  {
+    analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode );
+  }
+
 
   // get original DC for each segment
@@ -3674,9 +3653,4 @@
       pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[0], 0, 0, pcCU->getDepth(0)); // interprets depth relative to LCU level
       
-#if !RWTH_DBBP_NO_SPU_H0057
-      pcCU->setVSPFlagSubParts(pDBBPTmpData->ahVSPFlag[0], 0, 0, pcCU->getDepth(0));
-      pcCU->setDvInfoSubParts(pDBBPTmpData->acDvInfo[0], 0, 0, pcCU->getDepth(0));
-#endif
-      
       for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
       {
@@ -3707,13 +3681,7 @@
       pcCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
 #if H_3D_VSP
-#if !ETRIKHU_CLEANUP_H0083
-                                        , vspFlag
-#endif
                                         , inheritedVSPDisInfo
 #endif
 #if H_3D_SPIVMP
-#if !ETRIKHU_CLEANUP_H0083_MISSING
-        , pbSPIVMPFlag
-#endif
         , pcMvFieldSP, puhInterDirSP
 #endif
@@ -3721,5 +3689,4 @@
         );
 
-#if ETRIKHU_CLEANUP_H0083
       pcCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours
 #if H_3D_VSP
@@ -3731,5 +3698,4 @@
                                         , numValidMergeCand
         );
-#endif
 #else
       pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
@@ -3745,13 +3711,7 @@
     pcCU->xGetInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours
 #if H_3D_VSP
-#if !ETRIKHU_CLEANUP_H0083
-                                      , vspFlag
-#endif
                                       , inheritedVSPDisInfo
 #endif
 #if H_3D_SPIVMP
-#if !ETRIKHU_CLEANUP_H0083_MISSING
-      , pbSPIVMPFlag 
-#endif
       , pcMvFieldSP, puhInterDirSP
 #endif
@@ -3759,5 +3719,4 @@
       );
 
-#if ETRIKHU_CLEANUP_H0083
     pcCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
 #if H_3D_VSP
@@ -3769,5 +3728,4 @@
                                       , numValidMergeCand
       );
-#endif
 #else
     pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand
Index: trunk/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 964)
+++ trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 976)
@@ -930,9 +930,5 @@
      )
   {
-#if MTK_LOW_LATENCY_IC_ENCODING_H0086
     pcSlice ->xSetApplyIC(pcEncTop->getUseICLowLatencyEnc());
-#else
-    pcSlice ->xSetApplyIC();
-#endif
     if ( pcSlice->getApplyIC() )
     {
Index: trunk/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 964)
+++ trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 976)
@@ -698,15 +698,7 @@
   m_cSPS.setSpsScalingListRefLayerId      ( 0              ); 
   m_cSPS.setSpsExtensionPresentFlag              ( true ); 
-#if H_MV_HLS_8_SPS_NODOC_48
   m_cSPS.setSpsMultilayerExtensionFlag    ( true ); 
-#else
-  m_cSPS.setSpsExtensionTypeFlag          ( PS_EX_T_MV ,true ); 
-#endif
 #if H_3D
-#if H_MV_HLS_8_SPS_NODOC_48
   m_cSPS.setSps3dExtensionFlag            ( true ); 
-#else
-  m_cSPS.setSpsExtensionTypeFlag          ( PS_EX_T_3D ,true ); 
-#endif
 #endif
 #endif
@@ -777,5 +769,5 @@
     m_cSPS.setNumReorderPics(m_numReorderPics[i], i);
   }
-#if H_MV_HLS_8_HRD_Q0102_08
+#if H_MV
   for ( Int ols = 0; ols < m_cVPS->getNumOutputLayerSets(); ols++)
   {
@@ -788,8 +780,5 @@
   }
 
-#if H_MV_HLS_8_RPS_Q0100_36
   m_cVPS->inferDbpSizeLayerSetZero( &m_cSPS, true ); 
-#endif
-
 #endif
   m_cSPS.setPCMBitDepthLuma (g_uiPCMBitDepthLuma);
@@ -853,14 +842,7 @@
   m_cPPS.setPPSId( getLayerIdInVps() );
   m_cPPS.setSPSId( getLayerIdInVps() );
-#if H_MV_HLS_8_SPS_NODOC_48
   m_cPPS.setPpsMultilayerExtensionFlag    ( true ); 
 #if H_3D
   m_cPPS.setPps3dExtensionFlag            ( true ); 
-#endif
-#else
-  m_cPPS.setPpsExtensionTypeFlag          ( PPS_EX_T_MV ,true ); 
-#if H_3D
-  m_cPPS.setPpsExtensionTypeFlag          ( PPS_EX_T_3D ,true ); 
-#endif
 #endif
 #endif
