Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 455)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 476)
@@ -759,4 +759,39 @@
     }
 #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
   }
 }
@@ -1414,5 +1449,9 @@
     {
       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);
+#else
       rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
+#endif
     }
 
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecCu.cpp	(revision 455)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecCu.cpp	(revision 476)
@@ -320,6 +320,12 @@
     m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
     m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
+    m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
+#if H_3D_IV_MERGE
+    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
+    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
+#else
     TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
     UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
+#endif
     Int numValidMergeCand = 0;
     for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 455)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 476)
@@ -156,6 +156,11 @@
   UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
 
+#if H_3D_IV_MERGE
+  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
+  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
+#else
   TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
+#endif
 
   for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
@@ -168,4 +173,7 @@
   pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
   pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
+#if H_3D_IV_MERGE
+  pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx);
+#endif
   for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
   {
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecGop.cpp	(revision 455)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecGop.cpp	(revision 476)
@@ -84,4 +84,7 @@
                    TComLoopFilter*         pcLoopFilter,
                    TComSampleAdaptiveOffset* pcSAO
+#if H_3D_IV_MERGE
+                    ,TComDepthMapGenerator*  pcDepthMapGenerator
+#endif
                    )
 {
@@ -93,4 +96,7 @@
   m_pcLoopFilter          = pcLoopFilter;
   m_pcSAO  = pcSAO;
+#if H_3D_IV_MERGE
+  m_pcDepthMapGenerator   = pcDepthMapGenerator;
+#endif
 }
 
@@ -152,4 +158,12 @@
     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 455)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecGop.h	(revision 476)
@@ -51,4 +51,8 @@
 #include "TLibCommon/TComSampleAdaptiveOffset.h"
 
+#if H_3D_IV_MERGE
+#include "TLibCommon/TComDepthMapGenerator.h"
+#endif
+
 #include "TDecEntropy.h"
 #include "TDecSlice.h"
@@ -79,4 +83,8 @@
   TComLoopFilter*       m_pcLoopFilter;
   
+#if H_3D_IV_MERGE
+  TComDepthMapGenerator*  m_pcDepthMapGenerator;
+#endif
+
   TComSampleAdaptiveOffset*     m_pcSAO;
   Double                m_dDecTime;
@@ -98,4 +106,7 @@
                  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 455)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.cpp	(revision 476)
@@ -37,4 +37,7 @@
 
 #include "NALread.h"
+#if H_3D_IV_MERGE
+#include "../../App/TAppDecoder/TAppDecTop.h"
+#endif
 #include "TDecTop.h"
 
@@ -389,5 +392,9 @@
 }
 
+#if H_3D_IV_MERGE
+Void TDecTop::init(TAppDecTop* pcTAppDecTop)
+#else
 Void TDecTop::init()
+#endif
 {
   // initialize ROM
@@ -395,7 +402,16 @@
   initROM();
 #endif
-  m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO);
+  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_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
 }
 
@@ -754,4 +770,13 @@
 
     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
@@ -893,4 +918,10 @@
 #endif
 
+#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 );
 #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 455)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.h	(revision 476)
@@ -45,4 +45,7 @@
 #include "TLibCommon/TComTrQuant.h"
 #include "TLibCommon/SEI.h"
+#if H_3D_IV_MERGE
+#include "TLibCommon/TComDepthMapGenerator.h"
+#endif
 
 #include "TDecGop.h"
@@ -222,4 +225,8 @@
   Bool                    m_isDepth;
   CamParsCollector*       m_pcCamParsCollector;
+#if H_3D_IV_MERGE
+  TComDepthMapGenerator   m_cDepthMapGenerator;
+  TAppDecTop*             m_tAppDecTop;
+#endif
 #endif
 #endif
@@ -234,5 +241,9 @@
   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 );
@@ -265,4 +276,7 @@
   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
