Index: branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.cpp	(revision 456)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.cpp	(revision 476)
@@ -641,5 +641,9 @@
     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);
@@ -678,3 +682,23 @@
 }
 #endif
+#if H_3D_IV_MERGE
+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 456)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.h	(revision 476)
@@ -49,4 +49,7 @@
 #include "TAppDecCfg.h"
 
+#if H_3D_IV_MERGE
+#include "TLibCommon/TComDepthMapGenerator.h"
+#endif
 //! \ingroup TAppDecoder
 //! \{
@@ -73,4 +76,9 @@
     // 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
@@ -82,4 +90,9 @@
   FILE*                           m_pScaleOffsetFile;
   CamParsCollector                m_cCamParsCollector;
+#if H_3D_IV_MERGE
+  TComVPSAccess                   m_cVPSAccess;
+  TComSPSAccess                   m_cSPSAccess;
+  TComAUPicAccess                 m_cAUPicAccess;
+#endif
 #endif
 public:
@@ -90,10 +103,26 @@
   Void  destroy           (); ///< destroy internal members
   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 ); }
+#endif
+
+#if H_3D_IV_MERGE
+  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
   Void  xDestroyDecLib    (); ///< destroy internal classes
   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
@@ -104,4 +133,5 @@
   Void  xFlushOutput      ( TComList<TComPic*>* pcListPic ); ///< flush all remaining decoded pictures to file
 #endif
+
   Bool  isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet
 };
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 456)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 476)
@@ -717,4 +717,9 @@
 
 #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" )
+#endif
 #endif //H_3D
   ;
@@ -1439,4 +1444,9 @@
   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 )
@@ -2278,4 +2288,7 @@
   printf("WVSO:%d ", m_bUseWVSO );  
 #endif
+#if H_3D_IV_MERGE
+  printf("MultiviewMvPred:%d", m_uiMultiviewMvPredMode);
+#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 456)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.h	(revision 476)
@@ -381,4 +381,8 @@
   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 456)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.cpp	(revision 476)
@@ -128,8 +128,29 @@
     m_frameRcvd                 .push_back(0);
     m_acTEncTopList             .push_back(new TEncTop); 
+#if H_3D_IV_MERGE
+//    m_acTEncDepthTopList        .push_back(new TEncTop); 
+#endif
     m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv);
     m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv);
     m_picYuvRec                 .push_back(new TComList<TComPicYuv*>) ;
-
+#if H_3D_IV_MERGE
+    //m_acTEncDepthTopList[iViewIdx]->setFrameRate                    ( m_iFrameRate );
+    //m_acTEncDepthTopList[iViewIdx]->setFrameSkip                    ( m_FrameSkip );
+    //m_acTEncDepthTopList[iViewIdx]->setSourceWidth                  ( m_iSourceWidth );
+    //m_acTEncDepthTopList[iViewIdx]->setSourceHeight                 ( m_iSourceHeight );
+    //m_acTEncDepthTopList[iViewIdx]->setCroppingMode                 ( m_croppingMode );
+    //m_acTEncDepthTopList[iViewIdx]->setCropLeft                     ( m_cropLeft );
+    //m_acTEncDepthTopList[iViewIdx]->setCropRight                    ( m_cropRight );
+    //m_acTEncDepthTopList[iViewIdx]->setCropTop                      ( m_cropTop );
+    //m_acTEncDepthTopList[iViewIdx]->setCropBottom                   ( m_cropBottom );
+    //m_acTEncDepthTopList[iViewIdx]->setFrameToBeEncoded             ( m_iFrameToBeEncoded );
+    //m_acTEncDepthTopList[iViewIdx]->setViewId                       ( iViewIdx );
+    //m_acTEncDepthTopList[iViewIdx]->setIsDepth                      ( true );
+
+    //m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
+
+    //m_acTEncDepthTopList[iViewIdx]->setLayerId                      ( layerId );
+
+#endif
     m_ivPicLists.push_back( m_acTEncTopList[ layer ]->getListPic()  ); 
     TEncTop& m_cTEncTop = *m_acTEncTopList[ layer ];  // It is not a member, but this name helps avoiding code duplication !!!
@@ -143,4 +164,10 @@
     m_cTEncTop.setIsDepth                      ( isDepth );
     //====== Camera Parameters =========
+#if H_3D_IV_MERGE
+      //m_acTEncDepthTopList[iViewIdx]->setCamParPrecision              ( 0 );
+      //m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader          ( false );
+      //m_acTEncDepthTopList[iViewIdx]->setCodedScale                   ( 0 );
+      //m_acTEncDepthTopList[iViewIdx]->setCodedOffset                  ( 0 );
+#endif
     m_cTEncTop.setCameraParameters             ( &m_cCameraData );     
     m_cTEncTop.setCamParPrecision              ( isDepth ? false : m_cCameraData.getCamParsCodedPrecision  () );
@@ -166,4 +193,8 @@
     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
 
@@ -189,4 +220,11 @@
   
   //====== Coding Structure ========
+#if H_3D_IV_MERGE
+      //m_acTEncDepthTopList[iViewIdx]->setIntraPeriod                  ( m_iIntraPeriod );
+      //m_acTEncDepthTopList[iViewIdx]->setDecodingRefreshType          ( m_iDecodingRefreshType );
+      //m_acTEncDepthTopList[iViewIdx]->setGOPSize                      ( m_iGOPSize );
+      //m_acTEncDepthTopList[iViewIdx]->setGopList                      ( m_GOPListsMvc[iViewIdx] );
+      //m_acTEncDepthTopList[iViewIdx]->setExtraRPSs                    ( m_extraRPSs[iViewIdx] );
+#endif
   m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod );
   m_cTEncTop.setDecodingRefreshType          ( m_iDecodingRefreshType );
@@ -207,9 +245,29 @@
     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 )
   {
     m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
+#if H_3D_IV_MERGE
+//        m_acTEncDepthTopList[iViewIdx]->setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] );
+#endif
   }
 #if H_MV
@@ -231,4 +289,11 @@
   
   //====== Loop/Deblock Filter ========
+#if H_3D_IV_MERGE
+      //m_acTEncDepthTopList[iViewIdx]->setLoopFilterDisable            ( m_abLoopFilterDisable[1]   );
+      //m_acTEncDepthTopList[iViewIdx]->setLoopFilterOffsetInAPS        ( m_loopFilterOffsetInAPS );
+      //m_acTEncDepthTopList[iViewIdx]->setLoopFilterBetaOffset         ( m_loopFilterBetaOffsetDiv2  );
+      //m_acTEncDepthTopList[iViewIdx]->setLoopFilterTcOffset           ( m_loopFilterTcOffsetDiv2    );
+      //m_acTEncDepthTopList[iViewIdx]->setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent);
+#endif
 #if H_MV
   m_cTEncTop.setLoopFilterDisable            ( m_bLoopFilterDisable[layer]);
@@ -604,5 +669,9 @@
   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
@@ -1032,3 +1101,25 @@
 }
 #endif
+#if H_3D_IV_MERGE
+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;
+};
+#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 456)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.h	(revision 476)
@@ -48,4 +48,7 @@
 #if H_3D
 #include "../../Lib/TLibRenderer/TRenTop.h"
+#if H_3D_IV_MERGE
+#include "TLibCommon/TComDepthMapGenerator.h"
+#endif
 #endif
 
@@ -89,4 +92,10 @@
   TRenModel                   m_cRendererModel;   
 #endif
+
+#if H_3D_IV_MERGE
+  TComVPSAccess               m_cVPSAccess;
+  TComSPSAccess               m_cSPSAccess;
+  TComAUPicAccess             m_cAUPicAccess;
+#endif
 protected:
   // initialization
@@ -114,5 +123,7 @@
   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 );  
@@ -126,8 +137,17 @@
   
   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
