Index: branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.cpp	(revision 479)
@@ -641,9 +641,5 @@
     m_tDecTop[ decIdx ] =  new TDecTop;
     m_tDecTop[ decIdx ]->create();
-#if H_3D_IV_MERGE
-    m_tDecTop[ decIdx ]->init(this );
-#else
     m_tDecTop[ decIdx ]->init( );
-#endif
     m_tDecTop[ decIdx ]->setLayerId( layerId );
     m_tDecTop[ decIdx ]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
@@ -682,23 +678,3 @@
 }
 #endif
-#if H_3D_IV_MERGE
-// GT: This function is not necessary anymore m_ivPicLists should be used instead
-TComPic* TAppDecTop::xGetPicFromView( Int viewIdx, Int poc, Bool isDepth )
-{
-  assert( ( viewIdx >= 0 ) );
-
-  TComList<TComPic*>* apcListPic = m_tDecTop[ (isDepth ? 1 : 0) + viewIdx * 2 ]->getListPic();
-
-  TComPic* pcPic = NULL;
-  for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
-  {
-    if( (*it)->getPOC() == poc )
-    {
-      pcPic = *it;
-      break;
-    }
-  }
-  return pcPic;
-}
-#endif
 //! \}
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.h	(revision 479)
@@ -49,7 +49,4 @@
 #include "TAppDecCfg.h"
 
-#if H_3D_IV_MERGE
-#include "TLibCommon/TComDepthMapGenerator.h"
-#endif
 //! \ingroup TAppDecoder
 //! \{
@@ -76,8 +73,4 @@
     // for output control
   Bool                            m_abDecFlag[ MAX_GOP ];         ///< decoded flag in one GOP
-#if H_3D_IV_MERGE
-  Int  m_fcoViewDepthId;
-  Char m_fcoOrder[MAX_VIEW_NUM*2];
-#endif
 #if H_MV
   Int                             m_pocLastDisplay      [ MAX_NUM_LAYERS ]; ///< last POC in display order
@@ -89,9 +82,4 @@
   FILE*                           m_pScaleOffsetFile;
   CamParsCollector                m_cCamParsCollector;
-#if H_3D_IV_MERGE
-  TComVPSAccess                   m_cVPSAccess;
-  TComSPSAccess                   m_cSPSAccess;
-  TComAUPicAccess                 m_cAUPicAccess;
-#endif
 #endif
 public:
@@ -103,13 +91,4 @@
   Void  decode            (); ///< main decoding function
 
-#if H_3D_IV_MERGE 
-  TDecTop* getTDecTop     ( Int viewIdx, Bool isDepth );
-  TComPic*              getPicFromView     ( Int viewIdx, Int poc, bool isDepth ) { return xGetPicFromView( viewIdx, poc, isDepth ); }
-  TComVPSAccess*    getVPSAccess  () { return &m_cVPSAccess;   }
-  TComSPSAccess*    getSPSAccess  () { return &m_cSPSAccess;   }
-  TComAUPicAccess*  getAUPicAccess() { return &m_cAUPicAccess; }
-  TDecTop*          getDecTop0    () { return m_tDecTop[0]; }
-#endif
-
 protected:
   Void  xCreateDecLib     (); ///< create internal classes
@@ -117,7 +96,4 @@
   Void  xInitDecLib       (); ///< initialize decoder class
 
-#if H_3D_IV_MERGE 
-  TComPic* xGetPicFromView( Int viewIdx, Int poc, Bool isDepth );
-#endif
 #if H_MV
   Void  xWriteOutput      ( TComList<TComPic*>* pcListPic, Int layerId, Int tId ); ///< write YUV to file
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 479)
@@ -718,6 +718,5 @@
 #endif //HHI_VSO
 #if H_3D_IV_MERGE
-  ("PredDepthMapGen",  m_uiPredDepthMapGeneration, (UInt)0, "generation of prediction depth maps for motion data prediction" )
-  ("MultiviewMvPred",  m_uiMultiviewMvPredMode,    (UInt)0, "usage of predicted depth maps" )
+  ("IvMvPred",                       m_ivMvPredFlag,           false           , "inter view motion prediction " )  
 #endif
 #endif //H_3D
@@ -1443,9 +1442,4 @@
   xConfirmPara( ((UInt) m_numberOfLayers >> 1 ) != m_cCameraData.getBaseViewNumbers().size(),   "Number of Views in BaseViewCameraNumbers must be equal to NumberOfViews" );
   xConfirmPara    ( m_iCodedCamParPrecision < 0 || m_iCodedCamParPrecision > 5,       "CodedCamParsPrecision must be in range of 0..5" );
-#if H_3D_IV_MERGE
-  xConfirmPara    ( m_uiPredDepthMapGeneration > 2,                                   "PredDepthMapGen must be less than or equal to 2" );
-  xConfirmPara    ( m_uiMultiviewMvPredMode > 7,                                      "MultiviewMvPred must be less than or equal to 7" );  
-  xConfirmPara    ( m_uiMultiviewMvPredMode > 0 && m_uiPredDepthMapGeneration == 0 ,  "MultiviewMvPred > 0 requires PredDepthMapGen > 0" );
-#endif
 #if H_3D_VSO
     if( m_bUseVSO )
@@ -2288,5 +2282,5 @@
 #endif
 #if H_3D_IV_MERGE
-  printf("MultiviewMvPred:%d", m_uiMultiviewMvPredMode);
+  printf("IvMvPred:%d", m_ivMvPredFlag );
 #endif
   printf("\n\n");  
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.h	(revision 479)
@@ -85,5 +85,8 @@
   Bool                   m_splittingFlag;                     ///< Splitting Flag
   Int                    m_scalabilityMask;                   ///< Mask indicating scalabilities, 1: texture; 3: texture + depth                                                                
-  std::vector<Int>       m_dimensionIdLen;                   ///< Length of scalability dimension s 
+  std::vector<Int>       m_dimensionIdLen;                    ///< Length of scalability dimension s 
+#if H_3D_IV_MERGE
+  Bool                   m_ivMvPredFlag;                      ///< Interview motion vector prediction 
+#endif
 #endif
   Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
@@ -381,8 +384,4 @@
   TAppComCamPara m_cCameraData;
   Int       m_iCodedCamParPrecision;                          ///< precision for coding of camera parameters
-#if H_3D_IV_MERGE
-  UInt      m_uiMultiviewMvPredMode;   
-  UInt      m_uiPredDepthMapGeneration;
-#endif
 #if H_3D_VSO
   Char*     m_pchVSOConfig;
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.cpp	(revision 479)
@@ -121,4 +121,7 @@
 #if H_3D
   vps.initViewIndex(); 
+#if H_3D_GEN
+  xSetVPSExtension2        ( vps ); 
+#endif
   m_ivPicLists.setVPS      ( &vps ); 
 #endif
@@ -166,8 +169,4 @@
     m_cTEncTop.setDWeight                      ( isDepth ? m_iDWeight             : 0     );
 #endif // H_3D_VSO
-#if H_3D_IV_MERGE
-    m_cTEncTop.setMultiviewMvPredMode          ( m_uiMultiviewMvPredMode     );
-    m_cTEncTop.setPredDepthMapGeneration       ( m_uiPredDepthMapGeneration );
-#endif
 #endif // H_3D
 
@@ -211,22 +210,5 @@
     m_cTEncTop.setNumReorderPics             ( m_numReorderPics[i], i );
     m_cTEncTop.setMaxDecPicBuffering         ( m_maxDecPicBuffering[i], i );
-#if H_3D_IV_MERGE
-        m_acTEncDepthTopList[iViewIdx]->setNumReorderPics             ( m_numReorderPics[iViewIdx][i], i );
-        m_acTEncDepthTopList[iViewIdx]->setMaxDecPicBuffering         ( m_maxDecPicBuffering[iViewIdx][i], i );
-#endif
-  }
-#if H_3D_IV_MERGE
-      m_acTEncDepthTopList[iViewIdx]->setQP                           ( m_aiQP[1] );
-
-      m_acTEncDepthTopList[iViewIdx]->setTemporalLayerQPOffset        ( m_aiTLayerQPOffset );
-      m_acTEncDepthTopList[iViewIdx]->setPad                          ( m_aiPad );
-
-      m_acTEncDepthTopList[iViewIdx]->setMaxTempLayer                 ( m_maxTempLayer[iViewIdx] );
-
-      m_acTEncDepthTopList[iViewIdx]->setDisInter4x4                  ( m_bDisInter4x4);
-
-      m_acTEncDepthTopList[iViewIdx]->setUseNSQT( m_enableNSQT );
-      m_acTEncDepthTopList[iViewIdx]->setUseAMP( m_enableAMP );
-#endif
+  }
 #endif
   for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
@@ -625,9 +607,5 @@
   for(Int layer=0; layer<m_numberOfLayers; layer++)
   {
-#if H_3D_IV_MERGE
-    m_acTEncTopList[layer]->init(this );
-#else
     m_acTEncTopList[layer]->init( );
-#endif
   }
 #else
@@ -1057,26 +1035,20 @@
 }
 #endif
+#if H_3D_GEN
+Void TAppEncTop::xSetVPSExtension2( TComVPS& vps )
+{
+  for ( Int layer = 0; layer < vps.getMaxLayers(); layer++ )
+  {
+    if ( layer != 0 ) 
+    {    
+      if( ( vps.getDepthId( layer ) == 0 ) )
+      {
 #if H_3D_IV_MERGE
- // GT: This function is not necessary anymore m_ivPicLists should be used instead
-TComPic* TAppEncTop::xGetPicFromView( Int viewIdx, Int poc, Bool isDepth )
-{
-  assert( ( viewIdx >= 0 ) && ( viewIdx < m_iNumberOfViews ) );
-
-  TComList<TComPic*>* apcListPic =  m_acTEncTopList[(isDepth ? 1 : 0) + viewIdx * 2]->getListPic() ;
-
-  
-
-  TComPic* pcPic = NULL;
-  for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++)
-  {
-    if( (*it)->getPOC() == poc )
-    {
-      pcPic = *it ;
-      break ;
-    }
-  }
-
-  return pcPic;
-};
+        vps.setIvMvPredFlag( layer, m_ivMvPredFlag ); 
+#endif
+      }
+    }
+  }
+}
 #endif
 //! \}
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.h	(revision 479)
@@ -48,7 +48,4 @@
 #if H_3D
 #include "../../Lib/TLibRenderer/TRenTop.h"
-#if H_3D_IV_MERGE
-#include "TLibCommon/TComDepthMapGenerator.h"
-#endif
 #endif
 
@@ -92,9 +89,4 @@
   TRenModel                   m_cRendererModel;   
 #endif
-#if H_3D_IV_MERGE
-  TComVPSAccess               m_cVPSAccess;
-  TComSPSAccess               m_cSPSAccess;
-  TComAUPicAccess             m_cAUPicAccess;
-#endif
 protected:
   // initialization
@@ -122,7 +114,5 @@
   void rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& stats);
   void printRateSummary();
-#if H_3D_IV_MERGE
-  TComPic* xGetPicFromView( Int viewIdx, Int iPoc, Bool isDepth );
-#endif
+
 #if H_MV
   Void xSetLayerIds               ( TComVPS& vps );  
@@ -131,4 +121,7 @@
   Int  xGetMax( std::vector<Int>& vec);
 #endif
+#if H_3D_GEN
+  Void xSetVPSExtension2( TComVPS& vps );
+#endif
 public:
   TAppEncTop();
@@ -136,16 +129,8 @@
   
   Void        encode      ();                               ///< main encoding function
-#if H_3D_IV_MERGE
-  TComPic*              getPicFromView     ( Int viewIdx, Int poc, Bool isDepth ) { return xGetPicFromView( viewIdx, poc, isDepth ); }
-#endif
 #if H_MV
   TEncTop*    getTEncTop( UInt layer ) { return  m_acTEncTopList[layer]; }  ///< return pointer to encoder class for specific layer
 #else
   TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
-#endif
-#if H_3D_IV_MERGE
-  TComVPSAccess*    getVPSAccess  () { return &m_cVPSAccess;   }
-  TComSPSAccess*    getSPSAccess  () { return &m_cSPSAccess;   }
-  TComAUPicAccess*  getAUPicAccess() { return &m_cAUPicAccess; }
 #endif
 };// END CLASS DEFINITION TAppEncTop
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/CommonDef.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/CommonDef.h	(revision 479)
@@ -178,37 +178,4 @@
 }
 
-#if H_3D_IV_MERGE
-#define ROFVS( exp )          \
-{                             \
-  if( !( exp ) )              \
-{                           \
-  return;                   \
-}                           \
-}
-
-#define ROTVS( exp )          \
-{                             \
-  if( ( exp ) )               \
-{                           \
-  return;                   \
-}                           \
-}
-
-#define ROTRS( exp, retVal )  \
-{                             \
-  if( ( exp ) )               \
-{                           \
-  return retVal;            \
-}                           \
-}
-
-#define ROFRS( exp, retVal )  \
-{                             \
-  if( !( exp ) )              \
-{                           \
-  return retVal;            \
-}                           \
-}
-#endif
 template <typename T>
 __inline T gSign(const T& t)
@@ -360,25 +327,4 @@
 #define STD_CAM_PARAMETERS_PRECISION 5        ///< quarter luma sample accuarcy for derived disparities (as default)
 
-#if H_3D_IV_MERGE
- // GT: To be checked if all of this is still necessary. 
-#define PDM_USE_FOR_IVIEW                 1
-#define PDM_USE_FOR_INTER                 2
-#define PDM_USE_FOR_MERGE                 4
-
-#define MAX_VIEW_NUM                      10
-#define PDM_SUBSAMPLING_EXP               2         // subsampling factor is 2^PDM_SUBSAMPLING_EXP
-#define PDM_SUB_SAMP_EXP_X(Pdm)           ((Pdm)==1?PDM_SUBSAMPLING_EXP:0)
-#define PDM_SUB_SAMP_EXP_Y(Pdm)           ((Pdm)==1?PDM_SUBSAMPLING_EXP:0)
-
-#define PDM_INTERNAL_CALC_BIT_DEPTH       31        // bit depth for internal calculations (32 - 1 for signed values)
-#define PDM_BITDEPTH_VIRT_DEPTH           15        // bit depth for virtual depth storage (16 - 1 for signed values)
-#define PDM_LOG2_MAX_ABS_NORMAL_DISPARITY 8         // maximum absolute normal disparity = 256 (for setting accuracy)
-#define PDM_VIRT_DEPTH_PRECISION          4         // must be greater than or equal to 2 (since MVs are given in quarter-pel units)
-
-#define PDM_INTER_CALC_SHIFT              ( PDM_INTERNAL_CALC_BIT_DEPTH - PDM_BITDEPTH_VIRT_DEPTH )         // avoids overflow
-#define PDM_LOG4_SCALE_DENOMINATOR        ( PDM_LOG2_MAX_ABS_NORMAL_DISPARITY + PDM_VIRT_DEPTH_PRECISION )  // accuracy of scaling factor
-#define PDM_OFFSET_SHIFT                  ( PDM_LOG2_MAX_ABS_NORMAL_DISPARITY )                             // accuracy of offset
-
-#endif
 #endif // end of H_3D
 //! \}
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.cpp	(revision 479)
@@ -40,7 +40,4 @@
 #include "TComPic.h"
 
-#if H_3D_IV_MERGE
-#include "TComDepthMapGenerator.h"
-#endif
 //! \ingroup TLibCommon
 //! \{
@@ -2458,5 +2455,5 @@
   deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
 #if H_3D_IV_MERGE
-  Bool bNoPdmMerge   = ( m_pcSlice->getSPS()->getViewIndex() == 0 || ( m_pcSlice->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) != PDM_USE_FOR_MERGE );
+  Bool ivMvPredFlag   = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() );
 
   //===== add merge with predicted depth maps =====
@@ -2556,8 +2553,8 @@
 
   Int iPdmDir[2] = {0, 0};
-  getUnifiedMvPredCan(uiPUIdx, REF_PIC_LIST_0, 0, aiPdmRefIdx, acPdmMv, &cDisInfo, iPdmDir, true);
+  getInterViewMergeCands(uiPUIdx, aiPdmRefIdx, acPdmMv, &cDisInfo, iPdmDir );
   Int iPdmInterDir;
 
-  if( iPdmDir[0] && !bNoPdmMerge )
+  if( iPdmDir[0] && ivMvPredFlag )
   {
     abCandIsInter        [ iCount ] = true;
@@ -2755,5 +2752,5 @@
 
 #if H_3D_IV_MERGE 
-  if(!bNoPdmMerge && iPdmDir[1] )
+  if(ivMvPredFlag && iPdmDir[1] )
   {
     assert(iCount < getSlice()->getMaxNumMergeCand());
@@ -4500,10 +4497,123 @@
 #endif 
 #if H_3D_IV_MERGE
-Bool TComDataCU::getUnifiedMvPredCan(UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* iPdm, Bool bMerge )
-{
-  TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator();
-  ROFRS( pcDepthMapGenerator, false );
-  if (pcDepthMapGenerator->getPdmCandidate(this, uiPartIdx, eRefPicList, iRefIdx, paiPdmRefIdx, pacPdmMv, pDInfo, iPdm, bMerge))
-    return true;
+Bool
+TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc )
+{
+  TComSlice*    pcSlice         = getSlice ();  
+
+  Bool valid     = false;
+  Int iViewIndex = 0;
+
+  for( UInt uiBIndex = 0; uiBIndex < pcSlice->getViewIndex( ) && !valid; uiBIndex++ )
+  {
+    UInt        uiBaseIndex = uiBIndex;    
+    TComPic*    pcBasePic   = pcSlice->getIvPic( false, uiBaseIndex );
+    for( Int iRefListId = 0; iRefListId < 2 && !valid; iRefListId++ )
+    {
+      RefPicList  eRefPicListTest = RefPicList( iRefListId );
+      Int         iNumRefPics = pcSlice->getNumRefIdx( eRefPicListTest ) ;
+      for( Int iRefIndex = 0; iRefIndex < iNumRefPics; iRefIndex++ )
+      { 
+        if(pcBasePic->getPOC() == pcSlice->getRefPic( eRefPicListTest, iRefIndex )->getPOC() 
+          && pcBasePic->getViewIndex() == pcSlice->getRefPic( eRefPicListTest, iRefIndex )->getViewIndex())
+        {
+          valid = true;
+          iViewIndex = uiBaseIndex;
+          break;
+        }
+      }
+    }
+  }
+
+  if (!valid)
+    return false;
+
+  //--- get base CU/PU and check prediction mode ---
+  TComPic*    pcBasePic   = pcSlice->getIvPic( false, iViewIndex );
+  TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
+
+  UInt          uiPartAddr;
+  Int           iWidth;
+  Int           iHeight;
+  getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight );
+
+  Int  iCurrPosX, iCurrPosY;
+  pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
+
+  iCurrPosX  += ( ( iWidth  - 1 ) >> 1 );
+  iCurrPosY  += ( ( iHeight - 1 ) >> 1 );
+
+  Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (pDInfo->m_acNBDV.getHor() + 2 ) >> 2 ) );
+  Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (pDInfo->m_acNBDV.getVer() + 2 ) >> 2 )); 
+
+  Int         iBaseCUAddr;
+  Int         iBaseAbsPartIdx;
+  pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
+
+  TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
+
+  Bool abPdmAvailable[4] = {false, false, false, false};
+  if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == 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 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());
+
+                //                  cMv.m_bDvMcp = true;
+                //                  cMv.m_iDvMcpDispX = pDInfo->m_acMvCand[0].getHor();                  
+
+                clipMv( cMv );
+                paiPdmRefIdx  [ uiCurrRefListId ] = iPdmRefIdx;
+                pacPdmMv      [ uiCurrRefListId ] = cMv;
+                stopLoop = true;
+                break;
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  availableMcDc[0] = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 );
+
+  for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ )
+  {
+    RefPicList  eRefPicListDMV       = RefPicList( iRefListId );
+    Int         iNumRefPics       = pcSlice->getNumRefIdx( eRefPicListDMV );
+    for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ )
+    {
+      if( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC())
+      {
+        abPdmAvailable[ iRefListId+2 ] = true;
+        paiPdmRefIdx  [ iRefListId+2 ] = iPdmRefIdx;
+
+        TComMv cMv = pDInfo->m_acNBDV; 
+        cMv.setVer(0);
+        clipMv( cMv );
+        pacPdmMv      [ iRefListId + 2] = cMv;
+        break;
+      }
+    }
+  }
+  availableMcDc[1] = ( abPdmAvailable[2] ? 1 : 0 ) + ( abPdmAvailable[3] ? 2 : 0 );
   return false;
 }
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.h	(revision 479)
@@ -435,5 +435,5 @@
 #endif
 #if H_3D_IV_MERGE
-  Bool          getUnifiedMvPredCan       ( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* iPdm, Bool bMerge );
+  Bool          getInterViewMergeCands          ( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc );   
 #endif
   // -------------------------------------------------------------------------------------------------------------------
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDepthMapGenerator.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 478)
+++ 	(revision )
@@ -1,299 +1,0 @@
-/* The copyright in this software is being made available under the BSD
- * License, included below. This software may be subject to other third party
- * and contributor rights, including patent rights, and no such rights are
- * granted under this license.
- *
- * Copyright (c) 2010-2011, ISO/IEC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *  * Neither the name of the ISO/IEC nor the names of its contributors may
- *    be used to endorse or promote products derived from this software without
- *    specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-
-/** \file     TComDepthMapGenerator.cpp
-    \brief    depth map generator class
-*/
-
-
-
-#include "CommonDef.h"
-#include "TComDepthMapGenerator.h"
-
-#if H_3D_IV_MERGE
-
-TComDepthMapGenerator::TComDepthMapGenerator()
-{
-  m_bCreated            = false;
-  m_bInit               = false;
-  m_bDecoder            = false;
-  m_pcPrediction        = 0;
-  m_pcSPSAccess         = 0;
-  m_pcAUPicAccess       = 0;
-
-  m_uiSubSampExpX       = 0;
-  m_uiSubSampExpY       = 0;
-}
-
-TComDepthMapGenerator::~TComDepthMapGenerator()
-{
-  destroy ();
-  uninit  ();
-}
-
-Void
-TComDepthMapGenerator::create( Bool bDecoder, UInt uiPicWidth, UInt uiPicHeight, UInt uiMaxCUDepth, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiOrgBitDepth, UInt uiSubSampExpX, UInt uiSubSampExpY )
-{
-  destroy();
-  m_bDecoder            = bDecoder;
-
-  m_uiSubSampExpX       = uiSubSampExpX;
-  m_uiSubSampExpY       = uiSubSampExpY;
-  m_bCreated    = true;
-}
-
-Void
-TComDepthMapGenerator::destroy()
-{
-  if( m_bCreated )
-  {
-    m_bCreated    = false;
-
-    m_uiSubSampExpX       = 0;
-    m_uiSubSampExpY       = 0;
-    m_bDecoder            = false;
-  }
-}
-
-
-Void
-TComDepthMapGenerator::init( TComPrediction* pcPrediction, TComVPSAccess* pcVPSAccess, TComSPSAccess* pcSPSAccess, TComAUPicAccess* pcAUPicAccess )
-{
-  AOF( pcPrediction  );
-  AOF( pcSPSAccess   );
-  AOF( pcAUPicAccess );
-  uninit();
-  m_pcPrediction  = pcPrediction;
-  m_pcVPSAccess   = pcVPSAccess;
-  m_pcSPSAccess   = pcSPSAccess;
-  m_pcAUPicAccess = pcAUPicAccess;
-  m_bInit         = true;
-}
-
-Void
-TComDepthMapGenerator::uninit()
-{
-  if( m_bInit )
-  {
-    m_bInit         = false;
-    m_pcPrediction  = 0;
-    m_pcSPSAccess   = 0;
-    m_pcAUPicAccess = 0;
-  }
-}
-
-Void  
-TComDepthMapGenerator::initViewComponent( TComPic* pcPic )
-{
-  AOF  ( m_bCreated && m_bInit );
-  AOF  ( pcPic );
-  AOT  ( pcPic->getSPS()->getViewIndex() && !pcPic->getSPS()->isDepth() && pcPic->getPOC() && pcPic->getSPS()->getPredDepthMapGeneration() != m_pcSPSAccess->getPdm() );
-  m_bPDMAvailable = false;
-  m_uiCurrViewIndex  = pcPic->getSPS()->getViewIndex();
-
-  // update SPS list and AU pic list and set depth map generator in SPS
-  m_pcVPSAccess  ->addVPS( pcPic->getVPS() );
-  m_pcSPSAccess  ->addSPS( pcPic->getSPS() );
-  m_pcAUPicAccess->addPic( pcPic );
-  pcPic->getSPS()->setDepthMapGenerator( this );
-
-  // check whether we have depth data or don't use pred depth prediction
-  ROFVS( pcPic->getSPS()->getViewIndex() );
-  ROTVS( pcPic->getSPS()->isDepth  () );
-  ROFVS( m_pcSPSAccess->getPdm     () ); 
-}
-
-Bool
-TComDepthMapGenerator::getPdmCandidate(TComDataCU* pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* iPdm, Bool bMerge )
-{
-  AOF  ( m_bCreated && m_bInit );
-  TComSlice*    pcSlice     = pcCU->getSlice ();
-  TComSPS*      pcSPS       = pcSlice->getSPS();
-  AOF  ( pcSPS->getViewIndex() == m_uiCurrViewIndex );
-
-  TComPic*      pcRefPic    = pcSlice->getRefPic( eRefPicList, iRefIdx );
-  UInt          uiRefViewId = pcRefPic->getSPS()->getViewIndex();
-  Bool          bInterview  = ( uiRefViewId < m_uiCurrViewIndex );
-  Bool          bPdmIView   = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_IVIEW ) == PDM_USE_FOR_IVIEW );
-  Bool          bPdmInter   = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_INTER ) == PDM_USE_FOR_INTER );
-  Bool          bPdmMerge   = ( ( pcSPS->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE );
-  if(!bMerge)
-  {
-    ROTRS( ( bInterview && !bMerge ) && !bPdmIView, false );
-    ROTRS( (!bInterview && !bMerge ) && !bPdmInter, false );
-    ROTRS(                  bMerge   && !bPdmMerge, false );
-  }
-  else
-    ROTRS( !bPdmMerge, 0 );
-
-
-  Bool abPdmAvailable[4] = {false, false, false, false};
-
-  Int iValid = 0;
-  Int iViewIndex = 0;
-  for( UInt uiBIndex = 0; uiBIndex < m_uiCurrViewIndex && iValid==0; uiBIndex++ )
-  {
-
-    UInt        uiBaseIndex    = uiBIndex;
-    TComPic*    pcBasePic   = m_pcAUPicAccess->getPic( uiBaseIndex );
-    for( Int iRefListId = 0; iRefListId < 2 && iValid==0; iRefListId++ )
-    {
-      RefPicList  eRefPicListTest = RefPicList( iRefListId );
-      Int         iNumRefPics = pcSlice->getNumRefIdx( eRefPicListTest ) ;
-      for( Int iRefIndex = 0; iRefIndex < iNumRefPics; iRefIndex++ )
-      { 
-        if(pcBasePic->getPOC() == pcSlice->getRefPic( eRefPicListTest, iRefIndex )->getPOC() 
-          && pcBasePic->getViewIndex() == pcSlice->getRefPic( eRefPicListTest, iRefIndex )->getViewIndex())
-        {
-          iValid=1;
-          iViewIndex = uiBaseIndex;
-          break;
-        }
-      }
-    }
-  }
-  if (iValid == 0)
-    return false;
-
-  //--- get base CU/PU and check prediction mode ---
-  TComPic*    pcBasePic   = m_pcAUPicAccess->getPic( iViewIndex );
-  TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
-  if(bMerge || !bInterview)
-  {
-    Int  iCurrPosX, iCurrPosY;
-    UInt          uiPartAddr;
-    Int           iWidth;
-    Int           iHeight;
-
-    pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight );
-    pcBaseRec->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
-    iCurrPosX  += ( ( iWidth  - 1 ) >> 1 );
-    iCurrPosY  += ( ( iHeight - 1 ) >> 1 );
-
-    Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (pDInfo->m_acNBDV.getHor() + 2 ) >> 2 ) );
-    Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (pDInfo->m_acNBDV.getVer() + 2 ) >> 2 )); 
-    Int         iBaseCUAddr;
-    Int         iBaseAbsPartIdx;
-    pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
-
-    TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
-    if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
-    {
-      for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
-      {
-        RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
-        if(!bMerge && eCurrRefPicList != eRefPicList)
-          continue;
-        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 = (bMerge?0: iRefIdx); iPdmRefIdx < (bMerge? pcSlice->getNumRefIdx( eCurrRefPicList ): (iRefIdx+1)); iPdmRefIdx++)
-              {
-                if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
-                {
-                  abPdmAvailable[ uiCurrRefListId ] = true;
-                  TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
-
-                  //if( bMerge )
-                  //{
-                    //cMv.m_bDvMcp = true;
-                    //cMv.m_iDvMcpDispX = pDInfo->m_acMvCand[0].getHor();
-                  //}
-
-                  pcCU->clipMv( cMv );
-                  if(bMerge)
-                  {
-                    paiPdmRefIdx  [ uiCurrRefListId ] = iPdmRefIdx;
-                    pacPdmMv      [ uiCurrRefListId ] = cMv;
-                    bLoop_stop = true;
-                    break;
-                  }else
-                  {
-                    pacPdmMv  [0] = cMv;
-                    return true;
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-    if( bMerge )
-      iPdm[0] = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 );
-  }
-  if(bMerge || bInterview)
-  {
-    for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ )
-    {
-      RefPicList  eRefPicListDMV       = RefPicList( iRefListId );
-      Int         iNumRefPics       = pcSlice->getNumRefIdx( eRefPicListDMV );
-      for( Int iPdmRefIdx = (bMerge ? 0: iRefIdx); iPdmRefIdx < (bMerge ? iNumRefPics: (iRefIdx+1) ); iPdmRefIdx++ )
-      {
-        if( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC())
-        {
-          abPdmAvailable[ iRefListId+2 ] = true;
-          paiPdmRefIdx  [ iRefListId+2 ] = iPdmRefIdx;
-
-          TComMv cMv = pDInfo->m_acNBDV; 
-          cMv.setVer(0);
-
-          pcCU->clipMv( cMv );
-          pacPdmMv      [ iRefListId + 2] = cMv;
-          if(bMerge)
-            break;
-          else
-          {
-            pacPdmMv [0] = cMv;
-            return true;
-          }
-        }
-      }
-    }
-    iPdm[1] = ( abPdmAvailable[2] ? 1 : 0 ) + ( abPdmAvailable[3] ? 2 : 0 );
-  }
-  return false;
-}
-#endif
-
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDepthMapGenerator.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 478)
+++ 	(revision )
@@ -1,163 +1,0 @@
-/* The copyright in this software is being made available under the BSD
- * License, included below. This software may be subject to other third party
- * and contributor rights, including patent rights, and no such rights are
- * granted under this license.
- *
- * Copyright (c) 2010-2011, ISO/IEC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *  * Neither the name of the ISO/IEC nor the names of its contributors may
- *    be used to endorse or promote products derived from this software without
- *    specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-
-/** \file     TComDepthMapGenerator.h
-    \brief    depth map generator class (header)
-*/
-
-
-#ifndef __TCOM_DEPTH_MAP_GENERATOR__
-#define __TCOM_DEPTH_MAP_GENERATOR__
-
-
-#include "CommonDef.h"
-#include "TComPic.h"
-#include "TComPrediction.h"
-#include "TComSlice.h"
-
-#if H_3D_IV_MERGE
-
-class TComVPSAccess // would be better to have a real VPS buffer
-{
-public:
-  TComVPSAccess ()  { clear(); }
-  ~TComVPSAccess()  {}
-
-  Void      clear   ()                                { ::memset( m_aacVPS, 0x00, sizeof( m_aacVPS ) ); m_uiActiceVPSId = 0;}
-  Void      addVPS  ( TComVPS* pcVPS )                { m_aacVPS[ pcVPS->getVPSId() ] = pcVPS; }
-  TComVPS*  getVPS  ( UInt uiVPSId )                  { return m_aacVPS[ uiVPSId ]; }
-  TComVPS*  getActiveVPS  ( )                         { return m_aacVPS[ m_uiActiceVPSId ]; }
-  Void      setActiveVPSId  ( UInt activeVPSId )      { m_uiActiceVPSId = activeVPSId; }
-private:
-  TComVPS*  m_aacVPS[ MAX_NUM_VPS ];
-  UInt      m_uiActiceVPSId;
-};
-
-
-class TComSPSAccess // would be better to have a real SPS buffer
-{
-public:
-  TComSPSAccess ()  { clear(); }
-  ~TComSPSAccess()  {}
-
-  Void      clear   ()                            { ::memset( m_aacActiveSPS, 0x00, sizeof( m_aacActiveSPS ) ); }
-  Void      addSPS  ( TComSPS* pcSPS    )         { m_aacActiveSPS[ pcSPS->isDepth() ? 1 : 0 ][ pcSPS->getViewIndex() ] = pcSPS; }
-  TComSPS*  getSPS  ( UInt     uiViewId, 
-                      Bool     bIsDepth = false ) { return m_aacActiveSPS[ bIsDepth ? 1 : 0 ][ uiViewId ]; }
-
-  UInt      getPdm  ()                            { if( m_aacActiveSPS[0][1] ) { return m_aacActiveSPS[0][1]->getPredDepthMapGeneration(); } return 0; }
-
-private:
-  TComSPS*  m_aacActiveSPS[ 2 ][ MAX_VIEW_NUM ];
-};
-
-
-
-class TComAUPicAccess // would be better to have a real decoded picture buffer
-{
-public:
-  TComAUPicAccess () : m_iLastPoc( 0 ), m_uiMaxViewId( 0 ) { clear(); }
-  ~TComAUPicAccess()                   {}
-
-  Void      clear   ()                            { ::memset( m_aacCurrAUPics, 0x00, sizeof( m_aacCurrAUPics ) ); }
-  Void      addPic    ( TComPic* pcPic    )         { if( m_iLastPoc != pcPic->getPOC() ) 
-                                                      { 
-                                                        clear(); 
-                                                        m_iLastPoc = pcPic->getPOC(); 
-                                                      } 
-                                                      m_aacCurrAUPics[ pcPic->getSPS()->isDepth() ? 1 : 0 ][ pcPic->getSPS()->getViewIndex() ] = pcPic; 
-                                                      if( pcPic->getSPS()->getViewIndex() > m_uiMaxViewId )
-                                                      {
-                                                        m_uiMaxViewId = pcPic->getSPS()->getViewIndex();
-                                                      }
-                                                    }
-  TComPic*  getPic  ( UInt     uiViewId,
-                      Bool     bIsDepth = false ) { return m_aacCurrAUPics[ bIsDepth ? 1 : 0 ][ uiViewId ]; }
-  UInt      getMaxVId ()                            { return m_uiMaxViewId; }
-
-private:
-  Int       m_iLastPoc;
-  UInt      m_uiMaxViewId;
-  TComPic*  m_aacCurrAUPics[ 2 ][ MAX_VIEW_NUM ];
-};
-
-
-
-class TComDepthMapGenerator
-{
-public:
-  TComDepthMapGenerator ();
-  ~TComDepthMapGenerator();
-
-  Void  create                ( Bool bDecoder, UInt uiPicWidth, UInt uiPicHeight, UInt uiMaxCUDepth, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiOrgBitDepth, UInt uiSubSampExpX, UInt uiSubSampExpY );
-  Void  destroy               ();
-
-  Void  init( TComPrediction* pcPrediction, TComVPSAccess* pcVPSAccess, TComSPSAccess* pcSPSAccess, TComAUPicAccess* pcAUPicAccess );
-  Void  uninit                ();
-
-  Void  initViewComponent     ( TComPic*      pcPic );
-
-  UInt  getSubSampExpX        ()                      { return m_uiSubSampExpX; }
-  UInt  getSubSampExpY        ()                      { return m_uiSubSampExpY; }
-  
-
-  Bool  getPdmCandidate       ( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* iPdm, Bool bMerge );
-
-  
-private:
-  // general parameters
-  Bool              m_bCreated;
-  Bool              m_bInit;
-  Bool              m_bDecoder;
-  TComPrediction*   m_pcPrediction;
-  TComVPSAccess*    m_pcVPSAccess;
-  TComSPSAccess*    m_pcSPSAccess;
-  TComAUPicAccess*  m_pcAUPicAccess;
-  UInt              m_uiSubSampExpX;
-  UInt              m_uiSubSampExpY;
-
-  // conversion parameters
-  UInt              m_uiCurrViewIndex;
-  Bool              m_bPDMAvailable;
-};
-
-
-
-#endif
-#endif // __TCOM_DEPTH_MAP_GENERATOR__
-
-
-
-
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComPic.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComPic.h	(revision 479)
@@ -141,9 +141,4 @@
   Int           getPOC()              { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getPOC();  }
   TComDataCU*&  getCU( UInt uiCUAddr )  { return  m_apcPicSym->getCU( uiCUAddr ); }
-#if H_3D_IV_MERGE
-  TComSlice*    getCurrSlice()        { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx);  }
-  TComSPS*      getSPS()              { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getSPS();  }
-  TComVPS*      getVPS()              { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getVPS();  }
-#endif
   
   TComPicYuv*   getPicYuvOrg()        { return  m_apcPicYuv[0]; }
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.cpp	(revision 479)
@@ -68,7 +68,4 @@
 , m_iSliceQpDeltaCb               ( 0 )
 , m_iSliceQpDeltaCr               ( 0 )
-#if H_3D_IV_MERGE
-, m_pcTexturePic                  ( NULL )
-#endif
 , m_iDepth                        ( 0 )
 , m_bRefenced                     ( false )
@@ -174,7 +171,4 @@
   
   m_colRefIdx = 0;
-#if H_3D_IV_MERGE
-  m_pcTexturePic = NULL;
-#endif
   initEqualRef();
 #if !L0034_COMBINED_LIST_CLEANUP
@@ -1497,4 +1491,10 @@
     }
   }
+#if H_3D_IV_MERGE
+  for( Int i = 0; i < MAX_NUM_LAYERS; i++ )
+  {
+    m_ivMvPredFlag[ i ] = false;
+  }
+#endif
 #endif
 }
@@ -1857,17 +1857,4 @@
   }
 }
-#if H_3D_IV_MERGE
-Void
-TComSPS::setPredDepthMapGeneration( UInt uiViewIndex, Bool bIsDepth, UInt uiPdmGenMode, UInt uiPdmMvPredMode)
-{ 
-  AOF( m_uiViewIndex == uiViewIndex );
-  AOF( m_bDepth   == bIsDepth );
-  AOT( ( uiViewIndex == 0 || bIsDepth ) && uiPdmGenMode );
-  AOT( uiPdmMvPredMode && uiPdmGenMode == 0 );
-
-  m_uiPredDepthMapGeneration = uiPdmGenMode;
-  m_uiMultiviewMvPredMode    = uiPdmMvPredMode;
-}
-#endif
 const Int TComSPS::m_winUnitX[]={1,2,2,1};
 const Int TComSPS::m_winUnitY[]={1,2,1,1};
@@ -1936,8 +1923,4 @@
   ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) );
 
-#if H_3D_IV_MERGE  
-  m_uiViewIndex           = uiViewIndex;
-  m_bDepth                = false;
-#endif
   if( !m_bCamParInSliceHeader )
   {
@@ -1951,18 +1934,4 @@
   }
 }
-#if H_3D_IV_MERGE
-Void
-TComSPS::initCamParaSPSDepth( UInt uiViewIndex)
-{  
-  m_uiCamParPrecision     = 0;
-  m_bCamParInSliceHeader  = false;
-
-  ::memset( m_aaiCodedScale,  0x00, sizeof( m_aaiCodedScale  ) );
-  ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) );
-
-  m_uiViewIndex           = uiViewIndex;
-  m_bDepth                = true;
-}
-#endif
 #endif
 
@@ -2298,4 +2267,16 @@
   }
 }
+#if H_3D_GEN
+Void TComSlice::setIvPicLists( TComPicLists* m_ivPicLists )
+{
+  for (Int i = 0; i < MAX_NUM_LAYERS; i++ )
+  {     
+    for ( Int depthId = 0; depthId < 2; depthId++ )
+    {
+      m_ivPicsCurrPoc[ depthId ][ i ] = ( i <= m_viewIndex ) ? m_ivPicLists->getPic( i, ( depthId == 1) , getPOC() ) : NULL;
+    }        
+  }  
+}
+#endif
 #endif
 /** get scaling matrix from RefMatrixID
@@ -2606,3 +2587,4 @@
 }
 #endif
+
 //! \}
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.h	(revision 479)
@@ -54,7 +54,4 @@
 class TComPicLists; 
 #endif
-#if H_3D_IV_MERGE
-class TComDepthMapGenerator;
-#endif
 // ====================================================================================================================
 // Constants
@@ -540,4 +537,7 @@
   Int         m_refLayerId               [ MAX_NUM_LAYERS ][MAX_NUM_LAYERS];  
 
+#if H_3D_IV_MERGE
+  Bool        m_ivMvPredFlag             [ MAX_NUM_LAYERS ]; 
+#endif
 #endif
 public:
@@ -673,4 +673,8 @@
   Bool    checkVPSExtensionSyntax(); 
   Int     scalTypeToScalIdx   ( ScalabilityType scalType );
+#if H_3D_IV_MERGE
+  Void    setIvMvPredFlag     ( Int layerIdInVps, Bool val )  { m_ivMvPredFlag[ layerIdInVps ] = val; }
+  Bool    getIvMvPredFlag     ( Int layerIdInVps )            { return m_ivMvPredFlag[ layerIdInVps ]; }; 
+#endif
 #endif
 };
@@ -984,12 +988,4 @@
   Int         m_aaiCodedScale [2][MAX_NUM_LAYERS];
   Int         m_aaiCodedOffset[2][MAX_NUM_LAYERS];
-#if H_3D_IV_MERGE
-  UInt        m_uiMultiviewMvPredMode;
-  UInt        m_uiPredDepthMapGeneration;
-
-  UInt        m_uiViewIndex;
-  Bool        m_bDepth;
-  TComDepthMapGenerator* m_pcDepthMapGenerator;
-#endif
 #endif
 public:
@@ -1135,15 +1131,4 @@
   Int* getInvCodedScale      ()  { return m_aaiCodedScale [1]; }
   Int* getInvCodedOffset     ()  { return m_aaiCodedOffset[1]; }
-#if H_3D_IV_MERGE
-  Void  initCamParaSPSDepth      ( UInt uiViewIndex);
-  UInt  getMultiviewMvPredMode   ()          { return m_uiMultiviewMvPredMode;    }
-  UInt  getPredDepthMapGeneration()          { return m_uiPredDepthMapGeneration; }
-
-  UInt  getViewIndex             ()  { return m_uiViewIndex; }
-  Bool  isDepth               ()  { return m_bDepth; }
-  Void  setDepthMapGenerator( TComDepthMapGenerator* pcDepthMapGenerator )  { m_pcDepthMapGenerator = pcDepthMapGenerator; }
-  TComDepthMapGenerator*  getDepthMapGenerator()                                              { return m_pcDepthMapGenerator; }
-  Void setPredDepthMapGeneration( UInt uiViewIndex, Bool bIsDepth, UInt uiPdmGenMode = 0, UInt uiPdmMvPredMode = 0);
-#endif
 #endif
 };
@@ -1436,7 +1421,4 @@
 #endif
   Bool        m_bIsUsedAsLongTerm[2][MAX_NUM_REF+1];
-#if H_3D_IV_MERGE
-  TComPic*    m_pcTexturePic;
-#endif
   Int         m_iDepth;
   
@@ -1510,5 +1492,8 @@
   Bool       m_isDepth;
   Int        m_aaiCodedScale [2][MAX_NUM_LAYERS];
-  Int        m_aaiCodedOffset[2][MAX_NUM_LAYERS];
+  Int        m_aaiCodedOffset[2][MAX_NUM_LAYERS];  
+#if H_3D_GEN
+  TComPic*   m_ivPicsCurrPoc [2][MAX_NUM_LAYERS];  
+#endif
 #endif
 #endif
@@ -1569,6 +1554,9 @@
   TComPic*  getRefPic           ( RefPicList e, Int iRefIdx)    { return  m_apcRefPicList[e][iRefIdx];  }
   Int       getRefPOC           ( RefPicList e, Int iRefIdx)    { return  m_aiRefPOCList[e][iRefIdx];   }
+#if H_3D_GEN
+  TComPic*  getIvPic            ( Bool depthFlag, Int viewIndex){ return  m_ivPicsCurrPoc[ depthFlag ? 1 : 0 ][ viewIndex ]; }
+#endif
 #if H_3D_IV_MERGE
-  TComPic*  getTexturePic       () const                        { return  m_pcTexturePic; }
+  TComPic*  getTexturePic       ()                              { return  m_ivPicsCurrPoc[0][ m_viewIndex ]; }
 #endif
   Int       getDepth            ()                              { return  m_iDepth;                     }
@@ -1622,7 +1610,4 @@
   Void      setRefPic           ( TComPic* p, RefPicList e, Int iRefIdx ) { m_apcRefPicList[e][iRefIdx] = p; }
   Void      setRefPOC           ( Int i, RefPicList e, Int iRefIdx ) { m_aiRefPOCList[e][iRefIdx] = i; }
-#if H_3D_IV_MERGE
-  Void      setTexturePic       ( TComPic *pcTexturePic )       { m_pcTexturePic = pcTexturePic; }
-#endif
   Void      setNumRefIdx        ( RefPicList e, Int i )         { m_aiNumRefIdx[e]    = i;      }
   Void      setPic              ( TComPic* p )                  { m_pcPic             = p;      }
@@ -1789,4 +1774,8 @@
 #endif
 #endif
+#if H_3D_GEN
+  Void    setIvPicLists( TComPicLists* m_ivPicLists );
+#endif
+
 protected:
   TComPic*  xGetRefPic  (TComList<TComPic*>& rcListPic,
@@ -1794,5 +1783,5 @@
 TComPic*  xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb);
 #if H_MV
-  TComPic*  xGetInterLayerRefPic( std::vector<TComPic*>& rcListIlPic, Int layerId );
+  TComPic*  xGetInterLayerRefPic( std::vector<TComPic*>& rcListIlPic, Int layerId );  
 #endif
 };// END CLASS DEFINITION TComSlice
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TypeDef.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TypeDef.h	(revision 479)
@@ -97,5 +97,5 @@
                                               // QC_AMVP_MRG_UNIFY_IVCAN_C0051     
                                               // TEXTURE MERGING CANDIDATE     , JCT3V-C0137
-
+#define H_3D_GEN                          1   // Some general changes can be removed after merge 
 #endif 
 
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 479)
@@ -759,38 +759,4 @@
     }
 #endif // !H_MV
-#if H_3D_IV_MERGE
-    READ_FLAG( uiCode, "base_view_flag" );
-    if( uiCode )
-    { // baseview SPS -> set standard values
-      pcSPS->initCamParaSPS         ( 0 );
-      pcSPS->setPredDepthMapGeneration( 0, false );
-    }
-    else
-    {
-      READ_FLAG( uiCode, "depth_flag" ); 
-      if( uiCode )
-      {
-        READ_UVLC( uiCode, "view_idx" ); 
-        pcSPS->initCamParaSPSDepth    ( uiCode );
-        pcSPS->setPredDepthMapGeneration( uiCode, true );
-      }
-      else
-      {
-        UInt  uiViewIndex;
-        READ_UVLC( uiViewIndex, "view_idx" );  uiViewIndex++; 
-        UInt uiPredDepthMapGeneration = 0;
-        UInt uiMultiviewMvPredMode = 0;
-
-        READ_UVLC( uiPredDepthMapGeneration, "Pdm_generation" );
-        if( uiPredDepthMapGeneration )
-        {
-          READ_UVLC( uiMultiviewMvPredMode, "multi_view_mv_pred_mode" );
-        }
-
-        pcSPS->setPredDepthMapGeneration( uiViewIndex, false, uiPredDepthMapGeneration, uiMultiviewMvPredMode);
-
-      }
-    }
-#endif
   }
 }
@@ -987,8 +953,23 @@
     if (uiCode)
     {
+#if H_3D
+#if H_3D_IV_MERGE
+      for( Int layer = 0; layer <= pcVPS->getMaxLayers() - 1; layer++ )
+      {
+        if (layer != 0)
+        {
+          if ( !( pcVPS->getDepthId( layer ) == 1 ) )
+          {
+            READ_FLAG( uiCode, "ivMvPredFlag[i]"); pcVPS->setIvMvPredFlag( layer, uiCode == 1 ? true : false );
+          }          
+        }        
+      }
+#endif
+#else
       while ( xMoreRbspData() )
       {
         READ_FLAG( uiCode, "vps_extension2_data_flag");
       }
+#endif
     }
 
@@ -1449,5 +1430,6 @@
       READ_UVLC( uiCode, "five_minus_max_num_merge_cand");
 #if H_3D_IV_MERGE
-      rpcSlice->setMaxNumMergeCand(((rpcSlice->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE) == PDM_USE_FOR_MERGE ? MRG_MAX_NUM_CANDS_MEM: MRG_MAX_NUM_CANDS) - uiCode);
+      Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ;
+      rpcSlice->setMaxNumMergeCand(( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode);
 #else
       rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecGop.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecGop.cpp	(revision 479)
@@ -84,7 +84,4 @@
                    TComLoopFilter*         pcLoopFilter,
                    TComSampleAdaptiveOffset* pcSAO
-#if H_3D_IV_MERGE
-                    ,TComDepthMapGenerator*  pcDepthMapGenerator
-#endif
                    )
 {
@@ -96,7 +93,4 @@
   m_pcLoopFilter          = pcLoopFilter;
   m_pcSAO  = pcSAO;
-#if H_3D_IV_MERGE
-  m_pcDepthMapGenerator   = pcDepthMapGenerator;
-#endif
 }
 
@@ -158,10 +152,4 @@
     m_LFCrossSliceBoundaryFlag.push_back( pcSlice->getLFCrossSliceBoundaryFlag());
   }
-#if H_3D_IV_MERGE
-  if( uiStartCUAddr == 0 )
-  {
-    m_pcDepthMapGenerator->initViewComponent( rpcPic );
-  }
-#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/TLibDecoder/TDecGop.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecGop.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecGop.h	(revision 479)
@@ -51,7 +51,4 @@
 #include "TLibCommon/TComSampleAdaptiveOffset.h"
 
-#if H_3D_IV_MERGE
-#include "TLibCommon/TComDepthMapGenerator.h"
-#endif
 #include "TDecEntropy.h"
 #include "TDecSlice.h"
@@ -82,7 +79,4 @@
   TComLoopFilter*       m_pcLoopFilter;
   
-#if H_3D_IV_MERGE
-  TComDepthMapGenerator*  m_pcDepthMapGenerator;
-#endif
   TComSampleAdaptiveOffset*     m_pcSAO;
   Double                m_dDecTime;
@@ -104,7 +98,4 @@
                  TComLoopFilter*         pcLoopFilter,
                  TComSampleAdaptiveOffset* pcSAO
-#if H_3D_IV_MERGE
-                 ,TComDepthMapGenerator* pcDepthMapGenerator
-#endif
                  );
   Void  create  ();
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.cpp	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.cpp	(revision 479)
@@ -37,7 +37,4 @@
 
 #include "NALread.h"
-#if H_3D_IV_MERGE
-#include "../../App/TAppDecoder/TAppDecTop.h"
-#endif
 #include "TDecTop.h"
 
@@ -392,9 +389,5 @@
 }
 
-#if H_3D_IV_MERGE
-Void TDecTop::init(TAppDecTop* pcTAppDecTop)
-#else
 Void TDecTop::init()
-#endif
 {
   // initialize ROM
@@ -402,15 +395,7 @@
   initROM();
 #endif
-  m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO
-#if H_3D_IV_MERGE
-    , &m_cDepthMapGenerator
-#endif
-    );
+  m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO );
   m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder );
   m_cEntropyDecoder.init(&m_cPrediction);
-#if H_3D_IV_MERGE
-  m_tAppDecTop = pcTAppDecTop;
-  m_cDepthMapGenerator.init( &m_cPrediction, m_tAppDecTop->getVPSAccess(), m_tAppDecTop->getSPSAccess(), m_tAppDecTop->getAUPicAccess() );
-#endif
 }
 
@@ -769,13 +754,4 @@
 
     m_cSliceDecoder.create();
-#if H_3D_IV_MERGE
-    UInt uiPdm = ( m_apcSlicePilot->getSPS()->getViewIndex() ? m_apcSlicePilot->getSPS()->getPredDepthMapGeneration() : m_tAppDecTop->getSPSAccess()->getPdm() );
-    m_cDepthMapGenerator.create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_bitDepthY, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
-    TComDepthMapGenerator* pcDMG0 = m_tAppDecTop->getDecTop0()->getDepthMapGenerator();
-    if( m_apcSlicePilot->getSPS()->getViewIndex() == 1 && ( pcDMG0->getSubSampExpX() != PDM_SUB_SAMP_EXP_X(uiPdm) || pcDMG0->getSubSampExpY() != PDM_SUB_SAMP_EXP_Y(uiPdm) ) )
-    {
-      pcDMG0->create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_bitDepthY, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) );
-    }
-#endif
   }
   else
@@ -918,8 +894,9 @@
 
 #endif
-#if H_3D_IV_MERGE
-    TComPic * const pcTexturePic = m_isDepth ? m_tAppDecTop->getPicFromView(  m_viewIndex, pcSlice->getPOC(), false ) : NULL;
-    assert( !m_isDepth || pcTexturePic != NULL );
-    pcSlice->setTexturePic( pcTexturePic );
+#if H_3D_GEN
+    pcSlice->setIvPicLists( m_ivPicLists );         
+#if H_3D_IV_MERGE    
+    assert( !getIsDepth() || ( pcSlice->getTexturePic() != 0 ) );
+#endif    
 #endif
     // For generalized B
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.h	(revision 478)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.h	(revision 479)
@@ -45,7 +45,4 @@
 #include "TLibCommon/TComTrQuant.h"
 #include "TLibCommon/SEI.h"
-#if H_3D_IV_MERGE
-#include "TLibCommon/TComDepthMapGenerator.h"
-#endif
 
 #include "TDecGop.h"
@@ -225,8 +222,4 @@
   Bool                    m_isDepth;
   CamParsCollector*       m_pcCamParsCollector;
-#if H_3D_IV_MERGE
-  TComDepthMapGenerator   m_cDepthMapGenerator;
-  TAppDecTop*             m_tAppDecTop;
-#endif
 #endif
 #endif
@@ -241,9 +234,5 @@
   void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
 
-#if H_3D_IV_MERGE
-  Void  init(TAppDecTop* pcTAppDecTop);
-#else
   Void  init();
-#endif
 #if H_MV  
   Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
@@ -276,7 +265,4 @@
   Bool                    getIsDepth            ()               { return m_isDepth;    }
   Void                    setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
-#if H_3D_IV_MERGE
-  TComDepthMapGenerator*  getDepthMapGenerator  () { return &m_cDepthMapGenerator; }
-#endif
 #endif
 #endif
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
