Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 479)
@@ -581,29 +581,4 @@
   WRITE_FLAG( 0, "sps_extension_flag" );
 #endif
-#if H_3D_IV_MERGE
-  if( pcSPS->getViewIndex() || pcSPS->isDepth() )
-  {
-    WRITE_FLAG( 0, "base_view_flag" ); 
-    if( pcSPS->isDepth() )
-    {
-      WRITE_FLAG( 1, "depth_flag" ); 
-      WRITE_UVLC( pcSPS->getViewIndex(), "view_idx" );
-    }
-    else
-    {
-      WRITE_FLAG( 0, "depth_flag" ); 
-      WRITE_UVLC( pcSPS->getViewIndex() - 1, "view_idx_minus1" );
-      WRITE_UVLC( pcSPS->getPredDepthMapGeneration(), "Pdm_generation" );
-      if( pcSPS->getPredDepthMapGeneration() )
-      {
-        WRITE_UVLC( pcSPS->getMultiviewMvPredMode(), "multi_view_mv_pred_mode" );
-      }
-    }
-  }
-  else
-  {
-    WRITE_FLAG( 1, "base_view_flag" );   
-  }
-#endif
 }
 
@@ -766,5 +741,21 @@
     }
   }
+#if H_3D_GEN
+  WRITE_FLAG( 1,                                             "vps_extension2_flag" );
+  for( Int layer = 0; layer <= pcVPS->getMaxLayers() - 1; layer++ )
+  {
+    if (layer != 0)
+    {
+      if ( !( pcVPS->getDepthId( layer ) == 1 ) )
+      {
+#if H_3D_IV_MERGE
+        WRITE_FLAG( pcVPS->getIvMvPredFlag(layer) ? 1 : 0 , "ivMvPredFlag[i]");
+#endif
+      }          
+    }        
+  }
+#else
   WRITE_FLAG( 0,                                             "vps_extension2_flag" );
+#endif
 #else
   WRITE_FLAG( 0,                     "vps_extension_flag" );
@@ -1104,5 +1095,6 @@
     {
 #if H_3D_IV_MERGE
-      WRITE_UVLC(((pcSlice->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE) == PDM_USE_FOR_MERGE? MRG_MAX_NUM_CANDS_MEM: MRG_MAX_NUM_CANDS) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
+      Bool ivMvPredFlag = pcSlice->getVPS()->getIvMvPredFlag( pcSlice->getLayerIdInVps() ) ;
+      WRITE_UVLC( ( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
 #else
       WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncCfg.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncCfg.h	(revision 479)
@@ -375,8 +375,4 @@
   TAppComCamPara* m_cameraParameters; 
   
-#if H_3D_IV_MERGE
-  UInt      m_uiPredDepthMapGeneration;
-  UInt      m_uiMultiviewMvPredMode;
-#endif
 #if H_3D_VSO
   //====== View Synthesis Optimization ======
@@ -930,10 +926,4 @@
   Void      setDispCoeff                    ( Double  d )   { m_dDispCoeff  = d; }
 #endif // H_3D_VSO
-#if H_3D_IV_MERGE
-  Void      setMultiviewMvPredMode              (UInt ui)   { m_uiMultiviewMvPredMode = ui;}
-  Void      setPredDepthMapGeneration       ( UInt  u )      { m_uiPredDepthMapGeneration   = u; }  
-
-  UInt      getMultiviewMvPredMode          ()              { return m_uiMultiviewMvPredMode;}
-#endif
 #endif // H_3D
 };
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 479)
@@ -49,7 +49,5 @@
 #include <time.h>
 #include <math.h>
-#if H_3D_IV_MERGE
-#include "../../App/TAppEncoder/TAppEncTop.h"
-#endif
+
 using namespace std;
 //! \ingroup TLibEncoder
@@ -109,7 +107,4 @@
   m_viewIndex  =   0; 
   m_isDepth = false;
-#if H_3D_IV_MERGE
-  m_pcDepthMapGenerator = NULL;
-#endif
 #endif
 #endif
@@ -160,7 +155,4 @@
   m_viewIndex            = pcTEncTop->getViewIndex();
   m_isDepth              = pcTEncTop->getIsDepth();
-#if H_3D_IV_MERGE
-  m_pcDepthMapGenerator  = pcTEncTop->getDepthMapGenerator();
-#endif
 #endif
 #endif
@@ -502,5 +494,9 @@
     pcPic->setCurrSliceIdx(0);
 
+#if H_3D_GEN
+    m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS() );     
+#else
     m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() );
+#endif
     pcSlice->setLastIDR(m_iLastIDR);
     pcSlice->setSliceIdx(0);
@@ -510,5 +506,7 @@
     pcSlice->setLayerId     ( getLayerId() );
     pcSlice->setViewId      ( getViewId()  );    
+#if !H_3D_GEN
     pcSlice->setVPS         ( m_pcEncTop->getVPS() );
+#endif
 #if H_3D
     pcPic  ->setViewIndex   ( getViewIndex() ); 
@@ -516,7 +514,7 @@
     pcSlice->setViewIndex   ( getViewIndex()  );
     pcSlice->setIsDepth( getIsDepth() );    
-    pcSlice->setCamparaSlice( pcPic->getCodedScale(), pcPic->getCodedOffset() );
-#endif
-#endif
+    pcSlice->setCamparaSlice( pcPic->getCodedScale(), pcPic->getCodedOffset() );    
+#endif
+#endif 
     //set default slice level flag to the same as SPS level flag
     pcSlice->setLFCrossSliceBoundaryFlag(  pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()  );
@@ -682,9 +680,9 @@
 #endif
 
-#if H_3D_IV_MERGE 
-    TAppEncTop* tAppEncTop = m_pcEncTop->getEncTop();
-    TComPic * const pcTexturePic = m_pcEncTop->getIsDepth() ? tAppEncTop->getPicFromView( getViewIndex(), pcSlice->getPOC(), false ) : NULL;
-    assert( !m_pcEncTop->getIsDepth() || pcTexturePic != NULL );
-    pcSlice->setTexturePic( pcTexturePic );
+#if H_3D
+    pcSlice->setIvPicLists( m_ivPicLists );         
+#if H_3D_IV_MERGE    
+    assert( !m_pcEncTop->getIsDepth() || ( pcSlice->getTexturePic() != 0 ) );
+#endif    
 #endif
     //  Slice info. refinement
@@ -1042,7 +1040,4 @@
     m_storedStartCUAddrForEncodingSliceSegment.push_back(nextCUAddr);
     startCUAddrSliceSegmentIdx++;
-#if H_3D_IV_MERGE
-    m_pcDepthMapGenerator->initViewComponent( pcPic );
-#endif
 #if H_3D_NBDV
       if(pcSlice->getViewIndex() && !pcSlice->getIsDepth()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncGOP.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncGOP.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncGOP.h	(revision 479)
@@ -59,7 +59,4 @@
 #include <vector>
 
-#if H_3D_IV_MERGE
-#include "TLibCommon/TComDepthMapGenerator.h"
-#endif
 //! \ingroup TLibEncoder
 //! \{
@@ -110,7 +107,4 @@
   Int                     m_viewIndex; 
   Bool                    m_isDepth;
-#if H_3D_IV_MERGE
-  TComDepthMapGenerator*  m_pcDepthMapGenerator;
-#endif
 #endif
 #endif
@@ -172,7 +166,5 @@
   
   TComList<TComPic*>*   getListPic()      { return m_pcListPic; }
-#if H_3D_IV_MERGE
-  TEncTop* getEncTop() { return m_pcEncTop; }
-#endif
+
 #if !H_MV
   Void  printOutSummary      ( UInt uiNumAllPicCoded );
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 479)
@@ -176,5 +176,9 @@
  \param pPPS          PPS associated with the slice
  */
+#if H_3D_GEN
+Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS )
+#else
 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS )
+#endif
 {
   Double dQP;
@@ -182,4 +186,7 @@
   
   rpcSlice = pcPic->getSlice(0);
+#if H_3D_GEN
+  rpcSlice->setVPS( pVPS );
+#endif
   rpcSlice->setSPS( pSPS );
   rpcSlice->setPPS( pPPS );
@@ -530,5 +537,5 @@
   rpcSlice->setSliceSegmentArgument ( m_pcCfg->getSliceSegmentArgument() );
 #if H_3D_IV_MERGE
-  rpcSlice->setMaxNumMergeCand        ( m_pcCfg->getMaxNumMergeCand()   + ((rpcSlice->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE) ? 1:0)      );
+  rpcSlice->setMaxNumMergeCand      ( m_pcCfg->getMaxNumMergeCand()   + ( rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ? 1 : 0 ) );
 #else
   rpcSlice->setMaxNumMergeCand        ( m_pcCfg->getMaxNumMergeCand()        );
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncSlice.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncSlice.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncSlice.h	(revision 479)
@@ -116,6 +116,11 @@
   
   /// preparation of slice encoding (reference marking, QP and lambda)
+#if H_3D_GEN
+  Void    initEncSlice        ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 
+                                Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS ); 
+#else
   Void    initEncSlice        ( TComPic*  pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd,
                                 Int iGOPid,   TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS );
+#endif
 #if RATE_CONTROL_LAMBDA_DOMAIN
   Void    resetQP             ( TComPic* pic, Int sliceQP, Double lambda );
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncTop.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncTop.cpp	(revision 479)
@@ -120,7 +120,4 @@
   m_cLoopFilter.        create( g_uiMaxCUDepth );
 
-#if H_3D_IV_MERGE
-  m_cDepthMapGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_bitDepthY, PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) );
-#endif
 #if RATE_CONTROL_LAMBDA_DOMAIN
   if ( m_RCEnableRateControl )
@@ -228,7 +225,4 @@
   m_cLoopFilter.        destroy();
   m_cRateCtrl.          destroy();
-#if H_3D_IV_MERGE
-  m_cDepthMapGenerator. destroy();
-#endif
   // SBAC RD
   if( m_bUseSBACRD )
@@ -290,9 +284,5 @@
 }
 
-#if H_3D_IV_MERGE
-Void TEncTop::init( TAppEncTop* pcTAppEncTop)
-#else
 Void TEncTop::init()
-#endif
 {
   // initialize SPS
@@ -316,8 +306,4 @@
   m_cCuEncoder.   init( this );
   
-#if H_3D_IV_MERGE
-  m_pcTAppEncTop = pcTAppEncTop;
-  m_cDepthMapGenerator.init( (TComPrediction*)this->getPredSearch(), m_pcTAppEncTop->getVPSAccess(), m_pcTAppEncTop->getSPSAccess(), m_pcTAppEncTop->getAUPicAccess() );
-#endif
   // initialize transform & quantization class
   m_pcCavlcCoder = getCavlcCoder();
@@ -672,22 +658,5 @@
   {
     m_cSPS.initCamParaSPS           ( m_viewIndex, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset );
-#if H_3D_IV_MERGE
-    if( m_viewIndex )
-    {
-      m_cSPS.setPredDepthMapGeneration( m_viewIndex, false, m_uiPredDepthMapGeneration, m_uiMultiviewMvPredMode);
-    }
-    else
-    {
-      m_cSPS.setPredDepthMapGeneration( m_viewIndex, false );
-    }
-#endif
-  }
-#if H_3D_IV_MERGE
-  else
-  {
-    m_cSPS.initCamParaSPSDepth           ( m_viewIndex);
-    m_cSPS.setPredDepthMapGeneration( m_viewIndex, true );
-  }
-#endif
+  }
 #endif
 }
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncTop.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncTop.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncTop.h	(revision 479)
@@ -57,7 +57,4 @@
 #include "TEncPreanalyzer.h"
 #include "TEncRateCtrl.h"
-#if H_3D_IV_MERGE
-#include "TLibCommon/TComDepthMapGenerator.h"
-#endif
 //! \ingroup TLibEncoder
 //! \{
@@ -67,7 +64,4 @@
 // ====================================================================================================================
 
-#if H_3D_IV_MERGE
-class TAppEncTop;
-#endif
 /// encoder class
 class TEncTop : public TEncCfg
@@ -102,7 +96,4 @@
   TEncSlice               m_cSliceEncoder;                ///< slice encoder
   TEncCu                  m_cCuEncoder;                   ///< CU encoder
-#if H_3D_IV_MERGE
-  TComDepthMapGenerator   m_cDepthMapGenerator;           ///< depth map generator
-#endif
   // SPS
   TComSPS                 m_cSPS;                         ///< SPS
@@ -128,7 +119,4 @@
   TEncBinCABAC*           m_pcRDGoOnBinCodersCABAC;        ///< going on bin coder CABAC for RD stage per substream
 
-#if H_3D_IV_MERGE  
-  TAppEncTop*             m_pcTAppEncTop;
-#endif
   // quality control
   TEncPreanalyzer         m_cPreanalyzer;                 ///< image characteristics analyzer for TM5-step3-like adaptive QP
@@ -157,9 +145,5 @@
   Void      create          ();
   Void      destroy         ();
-#if H_3D_IV_MERGE
-  Void      init            ( TAppEncTop* pcTAppEncTop );
-#else
   Void      init            ();
-#endif
 #if H_MV  
   TComPicLists* getIvPicLists() { return m_ivPicLists; }
@@ -201,7 +185,4 @@
   TEncSbac*               getRDGoOnSbacCoders   () { return  m_pcRDGoOnSbacCoders;   }
   TEncRateCtrl*           getRateCtrl           () { return &m_cRateCtrl;             }
-#if H_3D_IV_MERGE
-  TAppEncTop*             getEncTop             () { return m_pcTAppEncTop; }
-#endif
   TComSPS*                getSPS                () { return  &m_cSPS;                 }
   TComPPS*                getPPS                () { return  &m_cPPS;                 }
@@ -224,7 +205,4 @@
   Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
 #endif
-#if H_3D_IV_MERGE
-  TComDepthMapGenerator*  getDepthMapGenerator  () { return  &m_cDepthMapGenerator;   }
-#endif
   // -------------------------------------------------------------------------------------------------------------------
   // encoder function
