Index: branches/HTM-5.0-Qualcomm/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppDecoder/TAppDecTop.cpp	(revision 192)
+++ branches/HTM-5.0-Qualcomm/source/App/TAppDecoder/TAppDecTop.cpp	(revision 194)
@@ -82,5 +82,5 @@
 Void TAppDecTop::decode()
 {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   increaseNumberOfViews( 0, 0, 0 );
 #else
@@ -145,4 +145,9 @@
     {
       read(nalu, nalUnit);
+#if MVHEVC
+    viewDepthId = nalu.m_layerId;
+    Int depth = 0;
+    Int viewId = viewDepthId;
+#else
 #if VIDYO_VPS_INTEGRATION
       Int viewId = 0;
@@ -162,9 +167,9 @@
       viewDepthId = viewId * 2 + depth;   // coding order T0D0T1D1T2D2
 #endif
-      
+#endif     
       newPicture[viewDepthId] = false;
       if( viewDepthId >= m_tDecTop.size() )      
       {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
         increaseNumberOfViews( viewDepthId, viewId, depth );
 #else
@@ -195,4 +200,14 @@
       if( !(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) )
       {
+#if MVHEVC
+        if(viewDepthId && m_tDecTop[viewDepthId]->m_bFirstNal== false)
+        {
+          m_tDecTop[viewDepthId]->m_bFirstNal = true;
+          ParameterSetManagerDecoder* pDecV0 = m_tDecTop[0]->xGetParaSetDec();
+          m_tDecTop[viewDepthId]->xCopyVPS(pDecV0->getPrefetchedVPS(0));
+          m_tDecTop[viewDepthId]->xCopySPS(pDecV0->getPrefetchedSPS(0));
+          m_tDecTop[viewDepthId]->xCopyPPS(pDecV0->getPrefetchedPPS(0));
+        }
+#endif
         newPicture[viewDepthId] = m_tDecTop[viewDepthId]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[viewDepthId]);
         if (newPicture[viewDepthId])
@@ -218,5 +233,10 @@
     if( pcListPic[viewDepthId] )
     {
+#if QC_REM_IDV
+      Int iviewId = m_tDecTop[viewDepthId]->getViewId();
+      if( newPicture[viewDepthId] && (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR || ((nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR && iviewId) && m_tDecTop[viewDepthId]->getNalUnitTypeBaseView() == NAL_UNIT_CODED_SLICE_IDR)) )
+#else
       if( newPicture[viewDepthId] && (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDV && m_tDecTop[viewDepthId]->getNalUnitTypeBaseView() == NAL_UNIT_CODED_SLICE_IDR)) )
+#endif
       {
         xFlushOutput( pcListPic[viewDepthId], viewDepthId );
@@ -275,4 +295,13 @@
         m_tDecTop[viewDepthIdx]->destroy() ;
       }
+#if MVHEVC
+      if(viewDepthIdx)
+      {
+         //Call clear function to remove the record, which has been freed during viewDepthIdx = 0 case.
+        m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearSPS();
+        m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearVPS();
+        m_tDecTop[viewDepthIdx]->xGetParaSetDec()->clearPPS();
+      }
+#endif
       delete m_tDecTop[viewDepthIdx] ; 
       m_tDecTop[viewDepthIdx] = NULL ;
@@ -416,5 +445,5 @@
   m_pocLastDisplay[viewDepthId] = -MAX_INT;
 }
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
 Void  TAppDecTop::increaseNumberOfViews  ( UInt layerId, UInt viewId, UInt isDepth )
 #else
@@ -422,5 +451,5 @@
 #endif
 {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Int newNumberOfViewDepth = layerId + 1;
 #endif
@@ -429,5 +458,5 @@
     m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
   }
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION&!MVHEVC
   Int viewId = (newNumberOfViewDepth-1)>>1;   // coding order T0D0T1D1T2D2
   Bool isDepth = ((newNumberOfViewDepth % 2) == 0);  // coding order T0D0T1D1T2D2
@@ -442,5 +471,5 @@
       m_tVideoIOYuvReconFile.push_back(new TVideoIOYuv);
       Char buffer[4];
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
       sprintf(buffer,"_%i", viewId );
 #else
@@ -448,5 +477,5 @@
 #endif
       Char* nextFilename = NULL;
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
       if( isDepth)
 #else
@@ -463,5 +492,5 @@
         xAppendToFileNameEnd( m_pchReconFile, buffer, nextFilename);
       }
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION&!MVHEVC
       if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
 #endif
@@ -480,5 +509,5 @@
   {
     m_tDecTop.push_back(new TDecTop);
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION&!MVHEVC
     if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
     {
@@ -490,5 +519,5 @@
       m_tDecTop.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
       m_tDecTop.back()->setCamParsCollector( &m_cCamParsCollector );
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION&!MVHEVC
     }
 #endif
Index: branches/HTM-5.0-Qualcomm/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppDecoder/TAppDecTop.h	(revision 192)
+++ branches/HTM-5.0-Qualcomm/source/App/TAppDecoder/TAppDecTop.h	(revision 194)
@@ -74,5 +74,5 @@
   CamParsCollector                m_cCamParsCollector;
 #if DEPTH_MAP_GENERATION
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   TComVPSAccess                   m_cVPSAccess;
 #endif
@@ -88,5 +88,5 @@
   Void  destroy           (); ///< destroy internal members
   Void  decode            (); ///< main decoding function
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Void  increaseNumberOfViews  (UInt layerId, UInt viewId, UInt isDepth);
 #else
Index: branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 192)
+++ branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 194)
@@ -329,4 +329,7 @@
   /* Camera Paremetes */
   ("CameraParameterFile,cpf", m_pchCameraParameterFile,    (Char *) 0, "Camera Parameter File Name")
+#if MVHEVC
+  ("BaseViewCameraNumbers" ,  m_aiVId,     std::vector<Int>(1, MAX_VIEW_NUM), "Numbers of base views")
+#endif
   ("BaseViewCameraNumbers" ,  m_pchBaseViewCameraNumbers,  (Char *) 0, "Numbers of base views")
 
@@ -786,4 +789,5 @@
 }
 #else
+#if !MVHEVC
   m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
     m_uiInputBitDepth,
@@ -797,10 +801,12 @@
     LOG2_DISP_PREC_LUT );
 #endif
+#endif
 
 
   // check validity of input parameters
   xCheckParameter();
+#if !MVHEVC
   m_cCameraData.check( false, true );
-  
+#endif
   // print-out parameters
   xPrintParameter();
Index: branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncCfg.h	(revision 192)
+++ branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncCfg.h	(revision 194)
@@ -109,4 +109,7 @@
   std::vector<Double>  m_adQP;                                ///< QP value of key-picture (floating point) [0] video, [1] depth
   std::vector<Int>     m_aiQP;                                ///< QP value of key-picture (integer) [0] video, [1] depth
+#if MVHEVC
+  std::vector<Int>     m_aiVId;                                ///< view id
+#endif
   Int       m_aiTLayerQPOffset[MAX_TLAYER];                   ///< QP offset corresponding to temporal layer depth
   char*     m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
@@ -285,6 +288,7 @@
   Char*     m_pchCameraParameterFile;                         ///< camera parameter file
   Char*     m_pchBaseViewCameraNumbers;
+#if !MVHEVC
   TAppComCamPara m_cCameraData;
-
+#endif
   Int       m_iCodedCamParPrecision;                          ///< precision for coding of camera parameters
 
Index: branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncTop.cpp	(revision 192)
+++ branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncTop.cpp	(revision 194)
@@ -67,9 +67,15 @@
 Void TAppEncTop::xInitLibCfg()
 {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
+#if !MVHEVC
   UInt layerId = 0;
+#endif
   // TODO: fix the assumption here that the temporal structures are all equal across all layers???
   m_cVPS.setMaxTLayers( m_maxTempLayer[0] );
+#if MVHEVC
+  m_cVPS.setMaxLayers( m_iNumberOfViews );
+#else
   m_cVPS.setMaxLayers( m_iNumberOfViews * (m_bUsingDepthMaps ? 2:1) );
+#endif
   for(Int i = 0; i < MAX_TLAYER; i++)
   {
@@ -101,4 +107,8 @@
     m_acTEncTopList[iViewIdx]->setViewId                       ( iViewIdx );
     m_acTEncTopList[iViewIdx]->setIsDepth                      ( false );
+#if MVHEVC
+    m_acTEncTopList[iViewIdx]->setLayerId                      ( iViewIdx );
+    m_cVPS.setViewId                                           ( m_aiVId[ iViewIdx ], iViewIdx );
+#else
     m_acTEncTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
 #if VIDYO_VPS_INTEGRATION
@@ -117,4 +127,5 @@
     m_acTEncTopList[iViewIdx]->setCodedScale                   ( m_cCameraData.getCodedScale             () );
     m_acTEncTopList[iViewIdx]->setCodedOffset                  ( m_cCameraData.getCodedOffset            () );
+#endif   
 
   //====== Coding Structure ========
@@ -406,5 +417,9 @@
       m_acTEncDepthTopList[iViewIdx]->setViewId                       ( iViewIdx );
       m_acTEncDepthTopList[iViewIdx]->setIsDepth                      ( true );
+#if MVHEVC
+      m_acTEncDepthTopList[iViewIdx]->setLayerId                      ( iViewIdx );
+#else
       m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
+#endif
 #if VIDYO_VPS_INTEGRATION
       layerId = iViewIdx * 2 + 1;
@@ -821,4 +836,14 @@
   {
     m_acTEncTopList[iViewIdx]->init( this );
+#if MVHEVC
+  //set setNumDirectRefLayer
+  Int iNumDirectRef = m_acTEncTopList[iViewIdx]->getSPS()->getNumberOfUsableInterViewRefs();
+  m_acTEncTopList[iViewIdx]->getEncTop()->getVPS()->setNumDirectRefLayer(iNumDirectRef, iViewIdx);
+  for(Int iNumIvRef = 0; iNumIvRef < iNumDirectRef; iNumIvRef ++)
+  {
+    Int iLayerId = m_acTEncTopList[iViewIdx]->getSPS()->getUsableInterViewRef(iNumIvRef);
+    m_acTEncTopList[iViewIdx]->getEncTop()->getVPS()->setDirectRefLayerId( iLayerId + iViewIdx, iViewIdx, iNumIvRef);
+  }
+#endif
   }
   for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
@@ -862,5 +887,7 @@
   TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
   TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
+#if !MVHEVC
   TComPicYuv*       pcPdmDepthOrg    = new TComPicYuv;
+#endif
   TComPicYuv*       pcPicYuvRec = NULL;
   TComPicYuv*       pcDepthPicYuvRec = NULL;
@@ -963,4 +990,5 @@
     {
       Int  iNumEncoded = 0;
+#if !MVHEVC
       UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
       if ( iNextPoc < m_iFrameToBeEncoded )
@@ -968,4 +996,5 @@
       m_cCameraData.update( iNextPoc );
       }
+#endif
       for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
       {
@@ -1022,6 +1051,11 @@
   delete pcDepthPicYuvOrg;
   pcDepthPicYuvOrg = NULL;
-  
+
+#if !MVHEVC
+#if BUG_FIX_HTM
+  if ( pcPdmDepthOrg != NULL && m_uiMultiviewMvRegMode )
+#else
   if ( pcPdmDepthOrg != NULL )
+#endif
   {
     pcPdmDepthOrg->destroy();
@@ -1029,5 +1063,5 @@
     pcPdmDepthOrg = NULL; 
   };
-
+#endif
   
   for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
@@ -1233,5 +1267,7 @@
     case NAL_UNIT_CODED_SLICE:
 #if H0566_TLA
+#if !QC_REM_IDV
     case NAL_UNIT_CODED_SLICE_IDV:
+#endif
     case NAL_UNIT_CODED_SLICE_TLA:
     case NAL_UNIT_CODED_SLICE_CRA:
Index: branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncTop.h	(revision 192)
+++ branches/HTM-5.0-Qualcomm/source/App/TAppEncoder/TAppEncTop.h	(revision 194)
@@ -87,5 +87,5 @@
 #endif
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   TComVPS                     m_cVPS;
 #endif
@@ -139,4 +139,7 @@
 #endif
   
+#if MVHEVC
+  TComVPS*          getVPS()  { return &m_cVPS; }
+#endif
 #if VIDYO_VPS_INTEGRATION
   TComVPS*          getVPS()  { return &m_cVPS; }
Index: branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/RendererMain.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/RendererMain.cpp	(revision 192)
+++ branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/RendererMain.cpp	(revision 194)
@@ -43,4 +43,5 @@
 int main(int argc, char* argv[])
   {
+#if !MVHEVC
   TAppRendererTop  cTAppRendererTop;
 
@@ -78,4 +79,5 @@
 
   return 0;
+#endif
 }
 
Index: branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererCfg.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererCfg.cpp	(revision 192)
+++ branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererCfg.cpp	(revision 194)
@@ -59,5 +59,5 @@
 // Constructor / destructor / initialization / destroy
 // ====================================================================================================================
-
+#if !MVHEVC
 TAppRendererCfg::TAppRendererCfg()
 {
@@ -516,2 +516,3 @@
   g_uiIBDI_MAX     = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1);
 }
+#endif
Index: branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererCfg.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererCfg.h	(revision 192)
+++ branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererCfg.h	(revision 194)
@@ -50,5 +50,5 @@
 #include <string>
 #include <vector>
-
+#if !MVHEVC
 // ====================================================================================================================
 // Class definition
@@ -134,5 +134,5 @@
 
 
-
+#endif
 #endif // __TAppRENDERERCFG__
 
Index: branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererTop.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererTop.cpp	(revision 192)
+++ branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererTop.cpp	(revision 194)
@@ -45,5 +45,5 @@
 // Constructor / destructor / initialization / destroy
 // ====================================================================================================================
-
+#if !MVHEVC
 TAppRendererTop::TAppRendererTop()
 {
@@ -1034,2 +1034,3 @@
 
 }
+#endif
Index: branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererTop.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererTop.h	(revision 192)
+++ branches/HTM-5.0-Qualcomm/source/App/TAppRenderer/TAppRendererTop.h	(revision 194)
@@ -50,5 +50,5 @@
 #include "../../Lib/TLibRenderer/TRenModel.h"
 
-
+#if !MVHEVC
 // ====================================================================================================================
 // Class definition
@@ -87,4 +87,5 @@
 };// END CLASS DEFINITION TAppRendererTop
 
-#endif // __TAppRendererTOP__
+#endif
 
+#endif
