Index: branches/HTM-5.0-Qualcomm/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/App/TAppDecoder/TAppDecTop.cpp	(revision 193)
+++ 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 193)
+++ 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 193)
+++ 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 193)
+++ 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 193)
+++ 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 193)
+++ 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 193)
+++ 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 193)
+++ 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 193)
+++ 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 193)
+++ 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 193)
+++ 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
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/CommonDef.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/CommonDef.h	(revision 194)
@@ -185,4 +185,7 @@
 // VPS constants
 // ====================================================================================================================
+#if MVHEVC
+#define MAX_LAYER_NUM                     MAX_VIEW_NUM
+#endif
 #if VIDYO_VPS_INTEGRATION
 #define MAX_LAYER_NUM                     MAX_VIEW_NUM
@@ -480,5 +483,9 @@
   NAL_UNIT_CODED_SLICE,
 #if H0566_TLA
+#if QC_REM_IDV
+  NAL_UNIT_RESERVED,
+#else
   NAL_UNIT_CODED_SLICE_IDV,
+#endif
   NAL_UNIT_CODED_SLICE_TLA,
   NAL_UNIT_CODED_SLICE_CRA,
@@ -508,5 +515,5 @@
   NAL_UNIT_RESERVED_23,
   NAL_UNIT_UNSPECIFIED_24,
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   NAL_UNIT_VPS,
 #else
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/NAL.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/NAL.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/NAL.h	(revision 194)
@@ -51,5 +51,5 @@
   NalRefIdc   m_nalRefIDC;   ///< nal_ref_idc
 #endif
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   unsigned    m_layerId;
   unsigned    m_temporalId;  ///< temporal_id
@@ -69,5 +69,5 @@
     NalUnitType nalUnitType,
     Bool        nalRefFlag,
-#if !VIDYO_VPS_INTEGRATION    
+#if !VIDYO_VPS_INTEGRATION & !MVHEVC    
     Int         viewId,
     Bool        isDepth,
@@ -78,5 +78,5 @@
     :m_nalUnitType (nalUnitType)
     ,m_nalRefFlag  (nalRefFlag)
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION & !MVHEVC
     ,m_viewId      (viewId)
     ,m_isDepth     (isDepth)
@@ -139,5 +139,7 @@
     return m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR
 #if H0566_TLA
+#if !QC_REM_IDV    
         || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDV
+#endif
         || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA
         || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp	(revision 194)
@@ -4307,4 +4307,5 @@
   {
     // col [2]
+#if !TMVP_INDEX_MODIFY
     Int iRefIdxSkip[2] = {-1, -1};
     for (Int i=0; i<2; i++)
@@ -4326,4 +4327,5 @@
       iRefIdxSkip[i] = (iRefIdxTmp != -1) ? iRefIdxTmp : 0;
     }
+#endif
     //>> MTK colocated-RightBottom
     UInt uiPartIdxRB;
@@ -4337,6 +4339,9 @@
 
     TComMv cColMv;
+#if TMVP_INDEX_MODIFY
+    Int iRefIdx = 0;
+#else
     Int iRefIdx;
-
+#endif
     if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
     {
@@ -4371,6 +4376,9 @@
       }
     }
+#if !TMVP_INDEX_MODIFY
     iRefIdx = iRefIdxSkip[0];
-
+#else
+    iRefIdx = 0;
+#endif
     Bool bExistMV = false;
     UInt uiPartIdxCenter;
@@ -4390,5 +4398,9 @@
       if ( getSlice()->isInterB() )
       {       
+#if !TMVP_INDEX_MODIFY
         iRefIdx = iRefIdxSkip[1];
+#else
+        iRefIdx = 0;
+#endif
         bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
         if( bExistMV == false )
@@ -6400,4 +6412,10 @@
   if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 )
   {
+#if IV_AS_LT
+    Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm();
+    Bool bIsNeibRefLongTerm = m_pcSlice->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx))->getIsLongTerm();
+    iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) );
+    if ( (bIsCurrRefLongTerm == bIsNeibRefLongTerm) && (iNeibRefPOC == iCurrRefPOC) )
+#else
     if( pcTmpCU->getSlice()->getRefViewId( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) != m_pcSlice->getRefViewId( eRefPicList, iRefIdx ) )
     {
@@ -6406,4 +6424,5 @@
     iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) );
     if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List//
+#endif
     {
       TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
@@ -6542,10 +6561,19 @@
   Int iNeibRefPOC;
 
+#if IV_AS_LT
+  Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm();
+  Bool bIsNeibRefLongTerm = false;
+#endif
   if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 )
   {
     iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) );
+#if IV_AS_LT
+    bIsNeibRefLongTerm = m_pcSlice->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx))->getIsLongTerm() ;
+    if ( (bIsCurrRefLongTerm == bIsNeibRefLongTerm) && (iNeibRefPOC == iCurrRefPOC) )
+#else
     if( pcTmpCU->getSlice()->getRefViewId( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) != m_pcSlice->getRefViewId( eRefPicList, iRefIdx ) )
       return false;
     if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List//
+#endif
     {
       TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
@@ -6565,10 +6593,14 @@
     TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     TComMv rcMv;
-
+#if IV_AS_LT
+    bIsNeibRefLongTerm = m_pcSlice->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx))->getIsLongTerm(); 
+    if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm )
+    {
+#else
     if( pcTmpCU->getSlice()->getRefViewId( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ) != m_pcSlice->getRefViewId( eRefPicList, iRefIdx ) )
     {
       return false;
     }
-
+#endif
     Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC );
     if ( iScale == 4096 )
@@ -6585,4 +6617,7 @@
     pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
     return true;
+#if IV_AS_LT
+    }
+#endif
   }
   //---------------------- V2(END) --------------------//
@@ -6592,10 +6627,14 @@
     TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
     TComMv rcMv;
-
+#if IV_AS_LT
+    bIsNeibRefLongTerm = m_pcSlice->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx))->getIsLongTerm(); ;
+    if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm )
+    {
+#else
     if( pcTmpCU->getSlice()->getRefViewId( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) != m_pcSlice->getRefViewId( eRefPicList, iRefIdx ) )
     {
       return false;
     }
-
+#endif
     Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC );
     if ( iScale == 4096 )
@@ -6612,4 +6651,7 @@
     pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
     return true;
+#if IV_AS_LT
+  }
+#endif
   }
   //---------------------- V3(END) --------------------//
@@ -6722,5 +6764,9 @@
   Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale;
 #if SONY_COLPIC_AVAILABILITY
+#if IV_AS_LT
+  Int iColViewOrderIdx, iCurrViewOrderIdx, iCurrRefViewOrderIdx;
+#else
   Int iColViewOrderIdx, iColRefViewOrderIdx, iCurrViewOrderIdx, iCurrRefViewOrderIdx;
+#endif
 #endif
   TComMv cColMv;
@@ -6753,5 +6799,5 @@
   }
 
-#if !SONY_COLPIC_AVAILABILITY
+#if !SONY_COLPIC_AVAILABILITY&!IV_AS_LT
   if( m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewId() != m_pcSlice->getViewId() )
     return false;
@@ -6781,4 +6827,5 @@
   iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);
 
+#if !IV_AS_LT
 #if SONY_COLPIC_AVAILABILITY
   iColRefViewOrderIdx = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewOrderIdx();
@@ -6789,8 +6836,34 @@
   }
 #endif
-
+#else
+  Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm();
+  Bool bIsColRefLongTerm = pColCU->getSlice()->getWasLongTerm(eColRefPicList, iColRefIdx); 
+  if(bIsCurrRefLongTerm != bIsColRefLongTerm) 
+  {
+    assert( ((iColPOC == iColRefPOC)&&(iCurrPOC != iCurrRefPOC))||((iColPOC != iColRefPOC)&&(iCurrPOC == iCurrRefPOC)));
+    return false;
+  }
+#endif
   cColMv = pColCU->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr);
 
   iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC();
+#if IV_AS_LT
+  {
+    assert( ((iColPOC != iColRefPOC)&&(iCurrPOC != iCurrRefPOC))||((iColPOC == iColRefPOC)&&(iCurrPOC == iCurrRefPOC)));
+    if(!bIsCurrRefLongTerm)  //short-term
+    {
+      iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC);
+      if ( iScale == 4096 )
+      {
+        rcMv = cColMv;
+      }
+      else
+      {
+        rcMv = cColMv.scaleMv( iScale );
+      }
+    }else
+      rcMv = cColMv; //inter-view
+  }
+#else
 #if SONY_COLPIC_AVAILABILITY
   iScale = 0;
@@ -6814,5 +6887,5 @@
     rcMv = cColMv.scaleMv( iScale );
   }
-
+#endif
   return true;
 }
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComDepthMapGenerator.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 194)
@@ -239,5 +239,5 @@
   Bool              m_bDecoder;
   TComPrediction*   m_pcPrediction;
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   TComVPSAccess*    m_pcVPSAccess;
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPic.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPic.cpp	(revision 194)
@@ -519,5 +519,10 @@
       UInt uiTempLayer = currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice()->getTLayer(); 
       Int iTempDiff = (iTempPoc > iPOCCurr) ? (iTempPoc - iPOCCurr): (iPOCCurr - iTempPoc);
+#if QC_REM_IDV
+      TComSlice* refSlice = currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice();
+      bRAP = (refSlice->getSPS()->getViewId() && (refSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || refSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA))? 1: 0;      
+#else
       bRAP = (currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV? 1:0);
+#endif
       if( bRAP)
       {
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPic.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPic.h	(revision 194)
@@ -140,5 +140,5 @@
   TComSlice*    getSlice(Int i)       { return  m_apcPicSym->getSlice(i);  }
   TComSlice*    getCurrSlice()        { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx);  }
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   TComVPS*      getVPS()              { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getVPS();  }
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp	(revision 194)
@@ -924,6 +924,8 @@
 }
 #endif
+#if !MVHEVC
   Int     ixFrac      = iHor & 0x3;
   Int     iyFrac      = iVer & 0x3;
+#endif
   Int     iRefOffset  = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride;
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPrediction.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComPrediction.h	(revision 194)
@@ -105,6 +105,6 @@
 #else
   Void xPredInterLumaBlk  ( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi );
+  Void xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi );
 #endif
-  Void xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi );
   Void xWeightedAverage         ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst );
   
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp	(revision 194)
@@ -44,5 +44,9 @@
 
 TComSlice::TComSlice()
+#if MVHEVC
+: m_iPPSId                        ( 0  )
+#else
 : m_iPPSId                        ( -1 )
+#endif
 , m_iPOC                          ( 0 )
 , m_iLastIDR                      ( 0 )
@@ -142,4 +146,11 @@
   resetWpScalingLC(m_weightPredTableLC);
   initWpAcDcParam();
+#if IV_AS_LT
+  for(Int iNumCount = 0; iNumCount < MAX_NUM_REF+1; iNumCount++)
+  {
+     m_bWasLongTerm[0][iNumCount] = false;
+     m_bWasLongTerm[1][iNumCount] = false;
+  }
+#endif
 }
 
@@ -472,5 +483,9 @@
   {
     pcRefPic = xGetInterViewRefPic( rapcInterViewRefPics, getViewId() + m_pcSPS->getUsableInterViewRef(i) );
+#if IV_AS_LT
+    pcRefPic->setIsLongTerm( 1 );
+#else
     pcRefPic->setIsLongTerm( 0 );
+#endif
     pcRefPic->getPicYuvRec()->extendPicBorder();
     RefPicSetIvCurr[NumPocIvCurr] = pcRefPic;
@@ -513,4 +528,7 @@
   {
     m_apcRefPicList[0][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? refPicListTemp0[ m_RefPicListModification.getRefPicSetIdxL0(cIdx) ] : refPicListTemp0[cIdx];
+#if IV_AS_LT
+    setWasLongTerm(m_apcRefPicList[0][cIdx]->getIsLongTerm(), REF_PIC_LIST_0, cIdx);
+#endif
   }
   if( m_eSliceType == P_SLICE )
@@ -524,4 +542,7 @@
     {
       m_apcRefPicList[1][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? refPicListTemp1[ m_RefPicListModification.getRefPicSetIdxL1(cIdx) ] : refPicListTemp1[cIdx];
+#if IV_AS_LT
+      setWasLongTerm(m_apcRefPicList[1][cIdx]->getIsLongTerm(), REF_PIC_LIST_1, cIdx);
+#endif
     }
   }
@@ -876,5 +897,9 @@
     for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++)
     {
+#if IV_AS_LT
+       if( rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i))
+#else
       if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i))
+#endif
       {
         isReference = 1;
@@ -886,5 +911,9 @@
     for(;i<pReferencePictureSet->getNumberOfPictures();i++)
     {
+#if IV_AS_LT
+     if( (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()))
+#else
       if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()))
+#endif
       {
         isReference = 1;
@@ -1390,4 +1419,42 @@
 // Video parameter set (VPS)
 // ------------------------------------------------------------------------------------------------
+#if MVHEVC
+TComVPS::TComVPS()
+: m_VPSId                     (  0)
+, m_uiMaxTLayers              (  1)
+, m_uiMaxLayers               (  1)
+, m_bTemporalIdNestingFlag    (false)
+, m_uiNumHRDParameter         (  0)
+, m_numAddiLayerOperationPoints (2)
+, m_numAddiProLevelSets       (  1)
+{
+  for( Int i = 0; i < MAX_LAYER_NUM; i++)
+  {
+  m_numOpLayerIdMinus1[i] = 0;
+  if(i)
+      m_numDirectRefLayer[i] = 1;
+  else
+    m_numDirectRefLayer[i] = 0;
+  for( Int j = 0; j < MAX_LAYER_NUM; j++)
+  {
+    m_numDirectRefID[i][j] = 0;
+    m_numOpLayerId[i][j]   = 0;
+  }
+    m_uiViewId[i] = 0;
+    m_iViewOrderIdx[i] = 0;
+  }
+  
+  for( Int i = 0; i < MAX_TLAYER; i++)
+  {
+    m_numReorderPics[i] = 0;
+    m_uiMaxDecPicBuffering[i] = 0; 
+    m_uiMaxLatencyIncrease[i] = 0;
+  }
+}
+
+TComVPS::~TComVPS()
+{
+}
+#else
 #if VIDYO_VPS_INTEGRATION
 TComVPS::TComVPS()
@@ -1422,5 +1489,5 @@
 
 #endif
-
+#endif
 
 // ------------------------------------------------------------------------------------------------
@@ -1429,5 +1496,5 @@
 
 TComSPS::TComSPS()
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
 : m_VPSId                     (  0)
 , m_SPSId                     (  0)
@@ -1481,5 +1548,9 @@
 , m_bLCMod                    (false)
 #if H0412_REF_PIC_LIST_RESTRICTION
+#if MVHEVC
+, m_restrictedRefPicListsFlag   (  0)
+#else
 , m_restrictedRefPicListsFlag   (  1)
+#endif
 , m_listsModificationPresentFlag(  0)
 #endif
@@ -1734,8 +1805,9 @@
 TComSPS::initMultiviewSPS( UInt uiViewId, Int iViewOrderIdx, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset )
 {
+#if !MVHEVC
   AOT( uiViewId == 0 && iViewOrderIdx != 0 );
   AOT( uiViewId != 0 && iViewOrderIdx == 0 );
   AOT( uiViewId != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) );
-
+#endif
   m_uiViewId              = uiViewId;
   m_iViewOrderIdx         = iViewOrderIdx;
@@ -1745,4 +1817,5 @@
   ::memset( m_aaiCodedScale,  0x00, sizeof( m_aaiCodedScale  ) );
   ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) );
+#if !MVHEVC
   if( !m_bCamParInSliceHeader )
   {
@@ -1755,4 +1828,5 @@
     }
   }
+#endif
 }
 
@@ -2374,5 +2448,5 @@
 , m_ppsMap(MAX_NUM_PPS)
 , m_apsMap(MAX_NUM_APS)
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
 , m_vpsMap(MAX_NUM_VPS)
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComSlice.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TComSlice.h	(revision 194)
@@ -144,5 +144,5 @@
 #endif
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
 /// VPS class
 
@@ -156,10 +156,23 @@
 
   UInt        m_uiExtensionType;
-  
+#if !MVHEVC  
   Bool        m_bDependentFlag[MAX_LAYER_NUM];
+#else
+  UInt        m_uiNumHRDParameter;
+  UInt        m_numAddiLayerOperationPoints;
+  UInt        m_numAddiProLevelSets;
+  UInt        m_numDirectRefLayer[MAX_LAYER_NUM];
+  UInt        m_numDirectRefID[MAX_LAYER_NUM][MAX_LAYER_NUM];
+  UInt        m_numOpLayerIdMinus1[MAX_LAYER_NUM];
+  UInt        m_numOpLayerId[MAX_LAYER_NUM][MAX_LAYER_NUM];
+#endif
   UInt        m_uiViewId[MAX_LAYER_NUM];
+#if !MVHEVC  
   Bool        m_bDepthFlag[MAX_LAYER_NUM];
+#endif
   Int         m_iViewOrderIdx[MAX_LAYER_NUM];
+#if !MVHEVC  
   UInt        m_uiDependentLayer[MAX_LAYER_NUM];
+#endif
 
   UInt        m_numReorderPics[MAX_TLAYER];
@@ -182,5 +195,5 @@
   Bool    getTemporalNestingFlag   ()         { return m_uiMaxLayers;   }
   Void    setTemporalNestingFlag   (UInt t)   { m_bTemporalIdNestingFlag = t; }
-  
+#if !MVHEVC
   Void    setExtensionType(UInt v)                     { m_uiExtensionType = v;    }
   UInt    getExtensionType()                             { return m_uiExtensionType; }
@@ -188,17 +201,17 @@
   Void    setDependentFlag(Bool d, UInt layer)              { m_bDependentFlag[layer] = d;    }
   Bool    getDependentFlag(UInt layer)                      { return m_bDependentFlag[layer]; }
-
+#endif
   Void    setViewId(UInt v, UInt layer)                     { m_uiViewId[layer] = v;    }
   UInt    getViewId(UInt layer)                             { return m_uiViewId[layer]; }
-  
+#if !MVHEVC 
   Void    setDepthFlag(Bool d, UInt layer)                  { m_bDepthFlag[layer] = d;    }
   Bool    getDepthFlag(UInt layer)                          { return m_bDepthFlag[layer]; }
-
+#endif
   Void    setViewOrderIdx(Int v, UInt layer)                { m_iViewOrderIdx[layer] = v;    }
   Int     getViewOrderIdx(UInt layer)                       { return m_iViewOrderIdx[layer]; }
-  
+#if !MVHEVC   
   Void    setDependentLayer(UInt v, UInt layer)                     { m_uiDependentLayer[layer] = v;    }
   UInt    getDependentLayer(UInt layer)                             { return m_uiDependentLayer[layer]; }
-  
+#endif
   Void    setNumReorderPics(UInt v, UInt tLayer)                { m_numReorderPics[tLayer] = v;    }
   UInt    getNumReorderPics(UInt tLayer)                        { return m_numReorderPics[tLayer]; }
@@ -209,5 +222,23 @@
   Void    setMaxLatencyIncrease(UInt v, UInt tLayer)                { m_uiMaxLatencyIncrease[tLayer] = v;    }
   UInt    getMaxLatencyIncrease(UInt tLayer)                        { return m_uiMaxLatencyIncrease[tLayer]; }
-  
+#if MVHEVC
+  Void    setNumHRDParameters(UInt n)                                { m_uiNumHRDParameter = n;    }
+  UInt    getNumHRDParameters()                                      { return m_uiNumHRDParameter; }
+  Void    setNumDirectRefLayer(UInt n, UInt layer)                   { m_numDirectRefLayer[layer] = n;        };
+  UInt    getNumDirectRefLayer(UInt layer)                           { return m_numDirectRefLayer[layer];     };
+  Void    setDirectRefLayerId (UInt n, UInt layer, UInt refId)       { m_numDirectRefID[layer][refId] = n;   assert(refId < MAX_NUM_REF ); };
+  UInt    getDirectRefLayerId (        UInt layer, UInt refId)       { return m_numDirectRefID[layer][refId]; };
+  UInt    getNumAddiLayerOperationPoints(      )               { return m_numAddiLayerOperationPoints;  };
+  Void    setNumAddiLayerOperationPoints(UInt n)                {  m_numAddiLayerOperationPoints = n;  };
+  Void    setNumAddiProLevelSets        (UInt n)                     {  m_numAddiProLevelSets = n;}
+  UInt    getNumAddiProLevelSets        (      )                     { return m_numAddiProLevelSets;}
+
+  Void    setNumOpLayerIdMinus1         (UInt n, UInt layer)                     {  m_numOpLayerIdMinus1[layer] = n;}
+  UInt    getNumOpLayerIdMinus1         (UInt layer      )                       { return m_numOpLayerIdMinus1[layer];}
+
+  Void    setNumOpLayerId               (UInt n, UInt layer, UInt OpId)                     {  m_numOpLayerId[layer][OpId] = n;}
+  UInt    getNumOpLayerId               (UInt layer, UInt OpId        )                     { return m_numOpLayerId[layer][OpId];}
+
+#endif 
 };
 
@@ -218,5 +249,5 @@
 {
 private:
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Int          m_VPSId;
 #endif
@@ -391,5 +422,5 @@
   TComSPS();
   virtual ~TComSPS();
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Int  getVPSId       ()         { return m_VPSId;          }
   Void setVPSId       (Int i)    { m_VPSId = i;             }
@@ -1221,6 +1252,9 @@
   
   // access channel
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   TComVPS*    m_pcVPS;
+#endif
+#if IV_AS_LT
+  Bool                  m_bWasLongTerm[2][MAX_NUM_REF+1]; //was long-term picture
 #endif
   TComSPS*    m_pcSPS;
@@ -1297,5 +1331,5 @@
   Int        m_aaiCodedOffset[2][MAX_VIEW_NUM];
 
-#if SONY_COLPIC_AVAILABILITY
+#if SONY_COLPIC_AVAILABILITY|MVHEVC
   Int         m_iViewOrderIdx;
 #endif
@@ -1311,8 +1345,13 @@
   Void      initTiles();
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Void      setVPS          ( TComVPS* pcVPS ) { m_pcVPS = pcVPS; }
   TComVPS*  getVPS          () { return m_pcVPS; }
 #endif
+#if IV_AS_LT
+  Void          setWasLongTerm( Bool lt,  RefPicList e, Int iRefIdx ) { m_bWasLongTerm[e][iRefIdx] = lt; }
+  Bool          getWasLongTerm( RefPicList e, Int iRefIdx           ) { return m_bWasLongTerm[e][iRefIdx] ; }
+#endif
+
   Void      setSPS          ( TComSPS* pcSPS ) { m_pcSPS = pcSPS; }
   TComSPS*  getSPS          () { return m_pcSPS; }
@@ -1587,4 +1626,8 @@
   Void setViewId( Int viewId )       { m_viewId = viewId;   }
   Int  getViewId()                   { return m_viewId;     }
+#if MVHEVC
+  Void    setViewOrderIdx(Int v, UInt layer)                { m_iViewOrderIdx = v;    }
+  Int     getViewOrderIdx()                                 { return m_iViewOrderIdx; }
+#endif
   Void setIsDepth( Bool isDepth )    { m_isDepth = isDepth; }
   Bool getIsDepth()                  { return m_isDepth;    }
@@ -1655,4 +1698,10 @@
   }
 
+#if MVHEVC
+  Void clearPSList()
+  {
+    m_paramsetMap.clear();
+  }
+#endif
 private:
   std::map<Int,T *> m_paramsetMap;
@@ -1665,5 +1714,5 @@
   ParameterSetManager();
   virtual ~ParameterSetManager();
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   //! store video parameter set and take ownership of it 
   Void storeVPS(TComVPS *vps) { m_vpsMap.storePS( vps->getVPSId(), vps); };
@@ -1671,4 +1720,9 @@
   TComVPS* getVPS(Int vpsId)  { return m_vpsMap.getPS(vpsId); };
   TComVPS* getFirstVPS()      { return m_vpsMap.getFirstPS(); };
+#if MVHEVC
+  Void     clearVPS()         { m_vpsMap.clearPSList(); };
+  Void     clearSPS()         { m_spsMap.clearPSList(); };
+  Void     clearPPS()         { m_ppsMap.clearPSList(); };
+#endif
 #endif
   //! store sequence parameter set and take ownership of it 
@@ -1693,5 +1747,5 @@
   ParameterSetMap<TComPPS> m_ppsMap; 
   ParameterSetMap<TComAPS> m_apsMap; 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   ParameterSetMap<TComVPS> m_vpsMap; 
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TypeDef.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibCommon/TypeDef.h	(revision 194)
@@ -41,5 +41,10 @@
 //! \ingroup TLibCommon
 //! \{
-
+#define MVHEVC                            0
+#define            IV_AS_LT               1   //inter-view reference pictures are treated as long-term pictures         
+#define            TMVP_INDEX_MODIFY      1   //the reference index for temporal merging candidate is set to 0, as defined in HEVC
+#define            QC_REM_IDV             1   //nal unit type NAL_UNIT_CODED_SLICE_IDV is removed.
+#define            BUG_FIX_HTM            1
+#if !MVHEVC
 ///// ***** FIXES *********
 // A
@@ -177,5 +182,5 @@
 
 #define HHI_MPI_MERGE_POS                 0
-
+#endif
 ///// ***** HM 6.1 *********
 #define SKIPFRAME_BUGFIX                  1 ///< bug fix to enable skipFrame at decoder
@@ -477,8 +482,12 @@
 // VPS INTEGRATION
 // ====================================================================================================================
-
+#if !MVHEVC
 #if VIDYO_VPS_INTEGRATION
 #define MAX_NUM_VPS 10
 #endif
+#else
+#define MAX_NUM_VPS 1
+#endif
+
 
 // ====================================================================================================================
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/NALread.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/NALread.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/NALread.cpp	(revision 194)
@@ -132,4 +132,9 @@
 #endif
 
+#if MVHEVC
+  //nalu.m_layerId    = bs.read(6);
+  nalu.m_layerId    = bs.read(5);
+  nalu.m_temporalId = bs.read(3) - 1;
+#else
 #if H0388
   nalu.m_temporalId = bs.read(3);
@@ -145,5 +150,9 @@
   if ( nalu.m_temporalId )
   {
+#if QC_REM_IDV
+    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR);
+#else
     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDV );
+#endif
   }
 #endif
@@ -154,5 +163,7 @@
   case NAL_UNIT_CODED_SLICE_IDR:
 #if H0566_TLA
+#if !QC_REM_IDV
   case NAL_UNIT_CODED_SLICE_IDV:
+#endif
   case NAL_UNIT_CODED_SLICE_CRA:
   case NAL_UNIT_CODED_SLICE_TLA:
@@ -175,5 +186,9 @@
       if (nalu.m_temporalId == 0)
       {
+#if QC_REM_IDV
+        assert(nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR);
+#else
         assert(nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDV );
+#endif
       }
       else
@@ -190,4 +205,5 @@
   }
 #endif
+#endif
 }
 //! \}
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 194)
@@ -1338,5 +1338,83 @@
   }
 }
-
+#if MVHEVC
+Void TDecCavlc::parseVPS(TComVPS* pcVPS)
+{
+  UInt  uiCode;
+  READ_CODE( 4, uiCode,  "video_parameter_set_id"   );       pcVPS->setVPSId( uiCode );
+  READ_FLAG( uiCode,     "temporal_id_nesting_flag" );       pcVPS->setTemporalNestingFlag( uiCode ? true:false );
+  READ_CODE( 2, uiCode,  "vps_reserved_zero_2bits" );         assert( !uiCode );
+  READ_CODE( 6, uiCode,  "vps_max_layers_minus1" );               pcVPS->setMaxLayers( uiCode + 1 );
+  READ_CODE( 3, uiCode,  "vps_max_sub_layers_minus1" );      pcVPS->setMaxTLayers( uiCode + 1 );
+  READ_CODE( 12, uiCode, "vps_extension_offset"      );      assert( !uiCode );
+  for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++)
+  {
+    READ_UVLC( uiCode,  "max_dec_pic_buffering[i]" );     pcVPS->setMaxDecPicBuffering( uiCode, i );
+    READ_UVLC( uiCode,  "num_reorder_pics[i]" );          pcVPS->setNumReorderPics( uiCode, i );
+    READ_UVLC( uiCode,  "max_latency_increase[i]" );      pcVPS->setMaxLatencyIncrease( uiCode, i );
+  }
+  READ_UVLC( uiCode,                 "vps_num_hrd_parameters"   ); pcVPS->setNumHRDParameters(uiCode);
+  assert(pcVPS->getNumHRDParameters()==0);
+  for ( UInt i = 0; i < pcVPS->getNumHRDParameters(); i ++)
+  {
+   //   if( i > 0 )  
+    //{
+    //  READ_UVLC (0, "op_num_layer_id_values_minus1[ opIdx ]");
+    //  for( i = 0; i <= op_num_layer_id_values_minus1[ opIdx ]; i++ )  
+    //    READ_UVLC(0, 6, "op_layer_id[ opIdx ][ i ]");
+    //}  
+    //hrd_parameters( i  = =  0, vps_max_sub_layers_minus1 );  
+  }
+ 
+  READ_CODE( 1, uiCode, "bit_equal_to_one" );             assert( uiCode );
+  //vps_extension_byte_alignment_reserved_one_bit
+  xReadVPSAlignOne();
+  READ_CODE( 8, uiCode, "num_additional_layer_operation_points" );     pcVPS->setNumAddiLayerOperationPoints( uiCode );
+  READ_CODE( 8, uiCode, "num_additional_profile_level_sets"     );     pcVPS->setNumAddiProLevelSets( uiCode);
+
+
+  for(UInt i=0; i <= pcVPS->getMaxLayers()-1; i++)
+  {
+    READ_CODE( 4,  uiCode,             "num_types_zero_4bits[i]" );   assert( !uiCode );
+    READ_CODE( 4,  uiCode,             "type_zero_4bits[i]"      );   assert( !uiCode );
+    READ_CODE( 8,  uiCode,             "view_id[i]" );                pcVPS->setViewId(uiCode, i);
+    // WRITE_SVLC( pcVPS->getViewOrderIdx(i),                  "view_order_idx[i]" );
+    if(i)
+    {
+      READ_CODE( 6, uiCode,  "num_direct_ref_layers[ i ]" );    pcVPS->setNumDirectRefLayer(uiCode, i);
+      for (UInt j = 0; j< pcVPS->getNumDirectRefLayer(i); j++)
+      {
+        READ_CODE( 6, uiCode, "ref_layer_id[i][j]" );         pcVPS->setDirectRefLayerId (uiCode, i, j);
+      }
+    }
+  }
+  for( UInt i=1; i<=pcVPS->getNumAddiProLevelSets(); i++)
+  {
+    //profile_tier_level
+  }
+  for( UInt i=1; i<= pcVPS->getNumAddiLayerOperationPoints(); i++)
+  {   
+    if(pcVPS->getMaxLayers() == 3)
+    {
+      pcVPS->setNumOpLayerIdMinus1((i < pcVPS->getNumAddiLayerOperationPoints() ? 1: 2), (i-1)); 
+    }
+    else if( i==1 )
+    {
+      assert(pcVPS->getNumAddiLayerOperationPoints()==1);
+      pcVPS->setNumOpLayerIdMinus1(pcVPS->getMaxLayers()-1, (i-1)); 
+    }
+    READ_UVLC( uiCode,           "op_num_layer_id_values_minus1[ opIdx ]" ); pcVPS->setNumOpLayerIdMinus1(uiCode, i-1);
+    for(UInt j = 0; j <= pcVPS->getNumOpLayerIdMinus1(i-1); j++ )
+    {
+      READ_UVLC( uiCode,           "op_layer_id[ opIdx ][ i ]" ); pcVPS->setNumOpLayerId(uiCode, i-1, j);
+    }
+    if (pcVPS->getNumAddiProLevelSets())
+    {
+      //profile_level_idx[ i ]
+    }
+  }
+  return;
+}
+#else
 #if VIDYO_VPS_INTEGRATION
 Void TDecCavlc::parseVPS(TComVPS* pcVPS)
@@ -1389,5 +1467,5 @@
 
 #endif
-
+#endif
 #if HHI_MPI
 Void TDecCavlc::parseSPS(TComSPS* pcSPS, Bool bIsDepth)
@@ -1401,6 +1479,7 @@
   
   UInt  uiCode;
+#if !MVHEVC
   Int   iCode;
-
+#endif
   READ_CODE( 8,  uiCode, "profile_idc" );                        pcSPS->setProfileIdc( uiCode );
   READ_CODE( 8,  uiCode, "reserved_zero_8bits" );
@@ -1645,4 +1724,5 @@
 #endif
   READ_FLAG( uiCode, "sps_extension_flag");
+#if !MVHEVC
   if(uiCode)
   {
@@ -1803,4 +1883,5 @@
     }
   }
+#endif
 }
 
@@ -1907,5 +1988,13 @@
     }
 #endif
+#if QC_REM_IDV
+#if !MVHEVC
+  if(rpcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR && rpcSlice->getSPS()->getViewId() == 0) 
+#else
+  if(rpcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR && rpcSlice->getViewId() == 0) 
+#endif
+#else
     if(rpcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR) 
+#endif
     { 
       READ_UVLC( uiCode, "idr_pic_id" );  //ignored
@@ -1941,6 +2030,13 @@
       }
       rpcSlice->setPOC( iPOCmsb+iPOClsb );
-
+#if QC_REM_IDV
+#if !MVHEVC
+      if( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR &&  rpcSlice->getSPS()->getViewId() && rpcSlice->getPOC() == 0 )
+#else
+      if( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR &&  rpcSlice->getViewId() && rpcSlice->getPOC() == 0 )
+#endif
+#else
       if( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && rpcSlice->getPOC() == 0 )
+#endif
       {
         TComReferencePictureSet* rps = rpcSlice->getLocalRPS();
@@ -2082,5 +2178,9 @@
     {
 #if H0412_REF_PIC_LIST_RESTRICTION
+#if MVHEVC
+    if( !rpcSlice->getViewId() || !rpcSlice->getSPS()->getListsModificationPresentFlag() )
+#else
       if( !rpcSlice->getSPS()->getListsModificationPresentFlag() )
+#endif
       {
         refPicListModification->setRefPicListModificationFlagL0( 0 );
@@ -2153,5 +2253,9 @@
     {
 #if H0412_REF_PIC_LIST_RESTRICTION
+#if MVHEVC
+    if( !rpcSlice->getViewId() || !rpcSlice->getSPS()->getListsModificationPresentFlag() )
+#else
       if( !rpcSlice->getSPS()->getListsModificationPresentFlag() )
+#endif
       {
         refPicListModification->setRefPicListModificationFlagL1( 0 );
@@ -2237,5 +2341,9 @@
       
 #if H0412_REF_PIC_LIST_RESTRICTION
-      if(rpcSlice->getSPS()->getListsModificationPresentFlag() )
+#if MVHEVC
+    if( rpcSlice->getViewId() && rpcSlice->getSPS()->getListsModificationPresentFlag() )
+#else
+    if(rpcSlice->getSPS()->getListsModificationPresentFlag() )
+#endif
       {
 #endif
@@ -2944,4 +3052,29 @@
 }
 
+#if MVHEVC
+/** Parse VPS alignment one bits.
+ * \returns Void
+ */
+Void TDecCavlc::xReadVPSAlignOne( )
+{
+  UInt uiNumberOfBits = m_pcBitstream->getNumBitsUntilByteAligned();
+
+  if(uiNumberOfBits)
+  {
+    UInt uiBits;
+    UInt uiSymbol;
+
+    for(uiBits = 0; uiBits < uiNumberOfBits; uiBits++)
+    {
+      xReadFlag( uiSymbol );
+
+      if(!uiSymbol)
+      {
+        printf("\nWarning! vps_extension_byte_alignment_reserved_one_bit include a non-zero value.\n");
+      }
+    }
+  }
+}
+#endif
 /** Parse PCM alignment zero bits.
  * \returns Void
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 194)
@@ -75,5 +75,7 @@
   Void  xReadFlagTr           (              UInt& rValue, const Char *pSymbolName);
 #endif
-  
+#if MVHEVC
+  Void  xReadVPSAlignOne      ();
+#endif
   Void  xReadPCMAlignZero     ();
 
@@ -113,5 +115,5 @@
   Void  parseQtRootCbf      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf );
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Void  parseVPS            ( TComVPS* pcVPS );
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.h	(revision 194)
@@ -71,5 +71,5 @@
 #endif
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   virtual Void  parseVPS                  ( TComVPS* pcVPS )                       = 0;
 #endif
@@ -175,5 +175,5 @@
   Void    resetEntropy                ( TComSlice* p)           { m_pcEntropyDecoderIf->resetEntropy(p);                    }
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Void    decodeVPS                   ( TComVPS* pcVPS ) { m_pcEntropyDecoderIf->parseVPS(pcVPS); }
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecSbac.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecSbac.h	(revision 194)
@@ -87,5 +87,5 @@
   Void  setBitstream              ( TComInputBitstream* p  ) { m_pcBitstream = p; m_pcTDecBinIf->init( p ); }
   
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Void  parseVPS                  ( TComVPS* pcVPS )  {}
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecSlice.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 194)
@@ -446,5 +446,5 @@
 , m_ppsBuffer(16)
 , m_apsBuffer(64)
-#if VIDYO_VPS_INTEGRATION 
+#if VIDYO_VPS_INTEGRATION|MVHEVC 
 , m_vpsBuffer(16)
 #endif
@@ -458,5 +458,5 @@
 }
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
 TComVPS* ParameterSetManagerDecoder::getPrefetchedVPS  (Int vpsId)
 {
@@ -513,5 +513,5 @@
   m_ppsMap.mergePSList(m_ppsBuffer);
   m_spsMap.mergePSList(m_spsBuffer);
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   m_vpsMap.mergePSList(m_vpsBuffer);
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecSlice.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecSlice.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecSlice.h	(revision 194)
@@ -96,5 +96,5 @@
   Void     storePrefetchedAPS(TComAPS *aps)  { m_apsBuffer.storePS( aps->getAPSID(), aps); };
   TComAPS* getPrefetchedAPS  (Int apsId);
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Void     storePrefetchedVPS(TComVPS *vps)  { m_vpsBuffer.storePS( vps->getVPSId(), vps); };
   TComVPS* getPrefetchedVPS  (Int vpsId);
@@ -106,5 +106,5 @@
   ParameterSetMap<TComPPS> m_ppsBuffer; 
   ParameterSetMap<TComAPS> m_apsBuffer; 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC 
   ParameterSetMap<TComVPS> m_vpsBuffer;
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecTop.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecTop.cpp	(revision 194)
@@ -50,4 +50,7 @@
   m_aaiCodedScale          = new Int* [ MAX_VIEW_NUM ];
   m_aiViewOrderIndex       = new Int  [ MAX_VIEW_NUM ];
+#if MVHEVC
+  m_aiViewId               = new Int  [ MAX_VIEW_NUM ];
+#endif
   m_aiViewReceived         = new Int  [ MAX_VIEW_NUM ];
   for( UInt uiId = 0; uiId < MAX_VIEW_NUM; uiId++ )
@@ -266,4 +269,7 @@
   m_bFirstSliceInSequence   = true;
   m_pcCamParsCollector = 0;
+#if MVHEVC
+  m_bFirstNal                  = false;
+#endif
 }
 
@@ -578,5 +584,9 @@
   TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId());
   assert (vps != 0);
+#if !QC_REM_IDV
   if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA )
+#else
+  if( (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) && !sps->getViewId() )
+#endif
     // VPS can only be activated on IDR or CRA...
     getTAppDecTop()->getVPSAccess()->setActiveVPSId( sps->getVPSId() );
@@ -584,5 +594,8 @@
   m_apcSlicePilot->setPPS(pps);
   m_apcSlicePilot->setSPS(sps);
-#if VIDYO_VPS_INTEGRATION
+#if MVHEVC
+  TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId());
+#endif
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   m_apcSlicePilot->setVPS(vps);
 #endif
@@ -626,9 +639,23 @@
   m_apcSlicePilot->setPPS(m_parameterSetManagerDecoder.getPrefetchedPPS(0));
   m_apcSlicePilot->setSPS(m_parameterSetManagerDecoder.getPrefetchedSPS(0));
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
+#if MVHEVC
+  m_apcSlicePilot->setIsDepth(false);
+#endif
   m_apcSlicePilot->setVPS(m_parameterSetManagerDecoder.getPrefetchedVPS(0));
 #endif
   m_apcSlicePilot->initTiles();
-
+#if MVHEVC
+  m_apcSlicePilot->setViewId( nalu.m_layerId );
+  m_apcSlicePilot->setViewId( nalu.m_layerId );
+  m_apcSlicePilot->setViewOrderIdx(m_apcSlicePilot->getVPS()->getViewId(nalu.m_layerId), nalu.m_layerId);
+  Int iNumDirectRef = m_apcSlicePilot->getVPS()->getNumDirectRefLayer(nalu.m_layerId);
+  m_apcSlicePilot->getSPS()->setNumberOfUsableInterViewRefs(iNumDirectRef);
+  for(Int iNumIvRef = 0; iNumIvRef < iNumDirectRef; iNumIvRef ++)
+  {
+    Int iDeltaLayerId = m_apcSlicePilot->getVPS()->getDirectRefLayerId( nalu.m_layerId, iNumIvRef);
+    m_apcSlicePilot->getSPS()->setUsableInterViewRef(iNumIvRef, (iDeltaLayerId-nalu.m_layerId));
+  }
+#endif
   if (m_bFirstSliceInPicture)
   {
@@ -645,4 +672,8 @@
   if( m_bFirstSliceInPicture )
   {
+#if MVHEVC
+    if( nalu.m_layerId == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; }
+    else                     { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, 0 )->getNalUnitTypeBaseView(); }
+#else
 #if VIDYO_VPS_INTEGRATION
     if( m_apcSlicePilot->getVPS()->getViewId(nalu.m_layerId) == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; }
@@ -652,5 +683,5 @@
     else                     { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, nalu.m_isDepth )->getNalUnitTypeBaseView(); }
 #endif
-    
+#endif
     m_apcSlicePilot->setNalUnitTypeBaseViewMvc( m_nalUnitTypeBaseView );
   }
@@ -951,4 +982,5 @@
 
     // Set reference list 
+#if !MVHEVC
 #if VIDYO_VPS_INTEGRATION
     pcSlice->setViewId( pcSlice->getVPS()->getViewId(nalu.m_layerId) );
@@ -957,4 +989,5 @@
     pcSlice->setViewId(m_viewId);
     pcSlice->setIsDepth(m_isDepth);
+#endif
 #endif
 
@@ -1071,4 +1104,12 @@
   m_cGopDecoder.decompressGop(nalu.m_Bitstream, pcPic, false);
 
+#if IV_AS_LT
+  std::vector<TComPic*> apcInterViewRefPics = m_tAppDecTop->getInterViewRefPics( m_viewId, pcSlice->getPOC(), m_isDepth, pcSlice->getSPS() );
+  for( Int k = 0; k < apcInterViewRefPics.size(); k++ )
+  {
+    TComPic*  pcPicIv = apcInterViewRefPics[k];
+    pcPicIv->setIsLongTerm( 0 );
+  }
+#endif
   if( m_pcCamParsCollector )
   {
@@ -1082,5 +1123,5 @@
 }
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
 Void TDecTop::xDecodeVPS()
 {
@@ -1089,5 +1130,7 @@
   m_cEntropyDecoder.decodeVPS( vps );
   m_parameterSetManagerDecoder.storePrefetchedVPS(vps);  
+#if !MVHEVC
   getTAppDecTop()->getVPSAccess()->addVPS( vps );
+#endif
 }
 #endif
@@ -1155,5 +1198,5 @@
   switch (nalu.m_nalUnitType)
   {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
     case NAL_UNIT_VPS:
       xDecodeVPS();
@@ -1178,5 +1221,7 @@
     case NAL_UNIT_CODED_SLICE_IDR:
 #if H0566_TLA
+#if !QC_REM_IDV
     case NAL_UNIT_CODED_SLICE_IDV:
+#endif
     case NAL_UNIT_CODED_SLICE_CRA:
     case NAL_UNIT_CODED_SLICE_TLA:
@@ -1193,4 +1238,30 @@
 }
 
+#if MVHEVC
+Void TDecTop::xCopyVPS( TComVPS* pVPSV0 )
+{
+  m_parameterSetManagerDecoder.storePrefetchedVPS(pVPSV0);  
+}
+
+Void TDecTop::xCopySPS( TComSPS* pSPSV0 )
+{
+  TComSPS* sps = new TComSPS();
+  sps = pSPSV0;
+  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
+#if LCU_SYNTAX_ALF
+  m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
+#endif
+}
+
+Void TDecTop::xCopyPPS(TComPPS* pPPSV0 )
+{
+  m_parameterSetManagerDecoder.storePrefetchedPPS( pPPSV0 );
+
+  //!!!KS: Activate parameter sets for parsing APS (unless dependency is resolved)
+  m_apcSlicePilot->setPPSId(pPPSV0->getPPSId());
+  xActivateParameterSets();
+  m_apcSlicePilot->initTiles();
+}
+#endif
 /** Function for checking if picture should be skipped because of random access
  * \param iSkipFrame skip frame counter
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecTop.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibDecoder/TDecTop.h	(revision 194)
@@ -88,4 +88,7 @@
   Int**   m_aaiCodedScale;
   Int*    m_aiViewOrderIndex;
+#if MVHEVC
+  Int*    m_aiViewId;
+#endif
   Int*    m_aiViewReceived;
   UInt    m_uiCamParsCodedPrecision;
@@ -168,5 +171,9 @@
   
   Void  deletePicBuffer();
-
+#if MVHEVC
+  Void      xCopySPS( TComSPS* pSPSV0);
+  Void      xCopyPPS( TComPPS* pPPSV0);
+  Void      xCopyVPS( TComVPS* pVPSV0);
+#endif
 #if HHI_INTER_VIEW_RESIDUAL_PRED
   Void      deleteExtraPicBuffers   ( Int iPoc );
@@ -195,5 +202,8 @@
   TAppDecTop*         getTAppDecTop()                           { return  m_tAppDecTop; }
   NalUnitType         getNalUnitTypeBaseView()                  { return m_nalUnitTypeBaseView; }
-
+#if MVHEVC
+  bool                m_bFirstNal; //used to copy SPS, PPS, VPS
+  ParameterSetManagerDecoder* xGetParaSetDec ()        {return  &m_parameterSetManagerDecoder;}
+#endif
 protected:
   Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
@@ -208,5 +218,5 @@
   Bool      xDecodeSlice(InputNALUnit &nalu, Int iSkipFrame, Int iPOCLastDisplay);
 #endif
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Void      xDecodeVPS();
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/NALwrite.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/NALwrite.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/NALwrite.cpp	(revision 194)
@@ -64,4 +64,8 @@
 #endif
 
+#if MVHEVC
+  bsNALUHeader.write(nalu.m_layerId,        5); // when nal_ref_flag is signalled, 5 bits here. otherwise, 6 bits
+  bsNALUHeader.write(nalu.m_temporalId + 1, 3); // temporal_id
+#else
 #if VIDYO_VPS_INTEGRATION
   bsNALUHeader.write(nalu.m_temporalId, 3); // temporal_id
@@ -79,5 +83,7 @@
   case NAL_UNIT_CODED_SLICE_IDR:
 #if H0566_TLA
+#if !QC_REM_IDV
   case NAL_UNIT_CODED_SLICE_IDV:
+#endif
   case NAL_UNIT_CODED_SLICE_CRA:
   case NAL_UNIT_CODED_SLICE_TLA:
@@ -95,5 +101,5 @@
 #endif
 #endif
-  
+#endif 
   out.write(bsNALUHeader.getByteStream(), bsNALUHeader.getByteStreamLength());
 
@@ -196,4 +202,5 @@
 }
 
+#if !MVHEVC
 /**
  * Copy NALU from naluSrc to naluDest
@@ -222,4 +229,5 @@
   naluDest.m_Bitstream   = naluSrc.m_Bitstream;
 }
+#endif
 
 //! \}
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/NALwrite.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/NALwrite.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/NALwrite.h	(revision 194)
@@ -62,5 +62,5 @@
     NalRefIdc nalRefIDC,
 #endif
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
     unsigned layerId,
 #else
@@ -70,5 +70,5 @@
     unsigned temporalID = 0)
 #if NAL_REF_FLAG
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   : NALUnit(nalUnitType, nalRefFlag, layerId, temporalID)
 #else
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 194)
@@ -375,4 +375,92 @@
 }
 
+#if MVHEVC
+Void TEncCavlc::codeVPS( TComVPS* pcVPS )
+{
+  WRITE_CODE( pcVPS->getVPSId(),               4,        "video_parameter_set_id"     );
+  WRITE_FLAG( pcVPS->getTemporalNestingFlag() -1,        "temporal_id_nesting_flag"   );
+  WRITE_CODE( 0,                 2,        "vps_reserved_zero_2bits"    );
+  WRITE_CODE( pcVPS->getMaxLayers() - 1,       6,        "vps_max_layers_minus1"      );
+  WRITE_CODE( pcVPS->getMaxTLayers() - 1,      3,        "vps_max_sub_layers_minus1"  );
+  //to be determined
+  //profile_tier_level( 1, vps_max_sub_layers_minus1 );
+  //to be modified
+  WRITE_CODE( 0,                              12,         "vps_extension_offset"      );
+  for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++)
+  {
+    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i),           "max_dec_pic_buffering[i]" );
+    WRITE_UVLC( pcVPS->getNumReorderPics(i),               "num_reorder_pics[i]"      );
+    WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i),           "max_latency_increase[i]"  );
+  }
+  //!!!waste one bit: 3-view, 3; 2-view or more views: 1
+  WRITE_UVLC(pcVPS->getNumHRDParameters(),                 "vps_num_hrd_parameters"   );
+  assert(pcVPS->getNumHRDParameters()==0);
+  for ( UInt i = 0; i < pcVPS->getNumHRDParameters(); i ++)
+  {
+   //   if( i > 0 )  
+    //{
+    //  WRITE_UVLC (0, "op_num_layer_id_values_minus1[ opIdx ]");
+    //  for( i = 0; i <= op_num_layer_id_values_minus1[ opIdx ]; i++ )  
+    //    WRITE_CODE(0, 6, "op_layer_id[ opIdx ][ i ]");
+    //}  
+    //hrd_parameters( i  = =  0, vps_max_sub_layers_minus1 );  
+  }
+  WRITE_CODE( 1,      1,        "bit_equal_to_one" ); 
+  //btye aligned
+  m_pcBitIf->writeAlignOne();
+
+  if(pcVPS->getMaxLayers() == 3)
+    pcVPS->setNumAddiLayerOperationPoints (pcVPS->getMaxLayers());    //may be configured 
+  else
+    pcVPS->setNumAddiLayerOperationPoints (1);    
+  pcVPS->setNumAddiProLevelSets         (1);
+  WRITE_CODE( pcVPS->getNumAddiLayerOperationPoints(),         8,               "num_additional_layer_operation_points" );    
+  WRITE_CODE( pcVPS->getNumAddiProLevelSets(),                 8,               "num_additional_profile_level_sets"     );    
+  for(UInt i=0; i <= pcVPS->getMaxLayers()-1; i++)
+  {
+    WRITE_CODE( 0,         4,               "num_types_zero_4bits[i]" );   
+    WRITE_CODE( 0,         4,               "type_zero_4bits[i]"      );   
+    WRITE_CODE( pcVPS->getViewId(i),         8,               "view_id[i]" );    
+    if(i)
+    {
+      WRITE_CODE( pcVPS->getNumDirectRefLayer(i), 6,  "num_direct_ref_layers[ i ]" );    
+      for (UInt j = 0; j< pcVPS->getNumDirectRefLayer(i); j++)
+      {
+        WRITE_CODE( pcVPS->getDirectRefLayerId (i, j), 6,  "ref_layer_id[i][j]" ); 
+      }
+    }
+  }
+  for( UInt i=1; i<=pcVPS->getNumAddiProLevelSets(); i++)
+  {
+    //profile_tier_level
+  }
+  for( UInt i=1; i<= pcVPS->getNumAddiLayerOperationPoints(); i++)
+  {   
+    if(pcVPS->getMaxLayers() == 3)
+    {
+      pcVPS->setNumOpLayerIdMinus1((i < pcVPS->getNumAddiLayerOperationPoints() ? 1: 2), (i-1)); 
+    }
+    else if( i==1 )
+    {
+      assert(pcVPS->getNumAddiLayerOperationPoints()==1);
+      pcVPS->setNumOpLayerIdMinus1(pcVPS->getMaxLayers()-1, (i-1)); 
+    }
+    WRITE_UVLC( pcVPS->getNumOpLayerIdMinus1(i-1),           "op_num_layer_id_values_minus1[ opIdx ]" );
+    for(UInt j = 0; j <= pcVPS->getNumOpLayerIdMinus1(i-1); j++ )
+    {
+      if(pcVPS->getMaxLayers() == 3 && i== 2 && j==1)
+        pcVPS->setNumOpLayerId (2, i-1, j);
+      else
+        pcVPS->setNumOpLayerId (j, i-1, j);
+      WRITE_UVLC( pcVPS->getNumOpLayerId(i-1, j),           "op_layer_id[ opIdx ][ i ]" );
+    }
+    if (pcVPS->getNumAddiProLevelSets())
+    {
+      //profile_level_idx[ i ]
+    }
+  }
+  return;
+}
+#else
 #if VIDYO_VPS_INTEGRATION
 Void TEncCavlc::codeVPS( TComVPS* pcVPS )
@@ -419,5 +507,5 @@
 }
 #endif
-
+#endif
 #if HHI_MPI
 Void TEncCavlc::codeSPS( TComSPS* pcSPS, Bool bIsDepth )
@@ -620,5 +708,5 @@
 #endif
   WRITE_FLAG( 1, "sps_extension_flag" );
-
+#if !MVHEVC
   WRITE_FLAG( (pcSPS->getNumberOfUsableInterViewRefs() > 0) ? 1 : 0, "interview_refs_present_flag" );
   if( pcSPS->getNumberOfUsableInterViewRefs() > 0 )
@@ -719,4 +807,5 @@
   }
   WRITE_FLAG( 0, "sps_extension2_flag" );
+#endif
 }
 
@@ -795,5 +884,9 @@
   if (!bEntropySlice)
   {
+#if MVHEVC
+    WRITE_UVLC( 0, "pic_parameter_set_id" );
+#else
     WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "pic_parameter_set_id" );
+#endif
 #if H0388
     if( pcSlice->getPPS()->getOutputFlagPresentFlag() )
@@ -802,5 +895,9 @@
     }
 #endif
+#if QC_REM_IDV
+    if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR && pcSlice->getViewId() == 0) 
+#else
     if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR) 
+#endif
     {
       WRITE_UVLC( 0, "idr_pic_id" );
@@ -810,5 +907,9 @@
     {
       WRITE_CODE( (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC()), pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
+#if QC_REM_IDV
+      if( pcSlice->getPOC() == 0 && !(pcSlice->getSPS()->getViewId() && (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)))
+#else
       if( pcSlice->getPOC() == 0 && pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV )
+#endif
       {
         TComReferencePictureSet* rps = pcSlice->getRPS();
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.h	(revision 194)
@@ -114,5 +114,5 @@
   UInt  getCoeffCost          ()                { return  m_uiCoeffCost;  }
   
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Void  codeVPS                 ( TComVPS* pcVPS );
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncCfg.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncCfg.h	(revision 194)
@@ -307,5 +307,5 @@
 #endif
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   UInt     m_layerId;
 #endif
@@ -820,5 +820,5 @@
   Int       getTSIG()                            { return m_signHidingThreshold; }
 #endif
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION |MVHEVC
   Void      setLayerId             ( UInt layerId )   { m_layerId = layerId; }
   UInt      getLayerId             ()               { return m_layerId; }
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 194)
@@ -121,5 +121,5 @@
 }
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
 Void TEncEntropy::encodeVPS( TComVPS* pcVPS )
 {
@@ -129,5 +129,5 @@
 #endif
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
 Void  codeVPS                 ( TComVPS* pcVPS );
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.h	(revision 194)
@@ -76,5 +76,5 @@
   virtual UInt  getCoeffCost          ()                = 0;
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
 #endif
@@ -242,5 +242,5 @@
   
 public:
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Void encodeVPS               ( TComVPS* pcVPS);
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 194)
@@ -246,5 +246,5 @@
 
       std::vector<TComAPS>& vAPS = m_pcEncTop->getAPS();
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
     m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, uiPOCCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getEncTop()->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS() );
 #else
@@ -298,6 +298,10 @@
       if( pcSlice->getSliceType() == B_SLICE )
       {
-        if( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_sliceType == 'P' ) { pcSlice->setSliceType( P_SLICE ); }
-      }
+#if QC_REM_IDV
+      if( m_pcCfg->getGOPEntry(pcSlice->getSPS()->getViewId() && ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA))? MAX_GOP : iGOPid ).m_sliceType == 'P' ) { pcSlice->setSliceType( P_SLICE ); }
+#else
+      if( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_sliceType == 'P' ) { pcSlice->setSliceType( P_SLICE ); }
+#endif
+    }
 
       // Set the nal unit type
@@ -332,9 +336,15 @@
 #endif
 
+#if !QC_REM_IDV
       pcSlice->setNumRefIdx( REF_PIC_LIST_0, min( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) );
       pcSlice->setNumRefIdx( REF_PIC_LIST_1, min( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) );
-
-      TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
-      refPicListModification->setRefPicListModificationFlagL0( false );
+#else
+
+    Bool bNalRAP = ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR)) && (pcSlice->getSPS()->getViewId())  ? 1: 0;
+    pcSlice->setNumRefIdx( REF_PIC_LIST_0, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) );
+    pcSlice->setNumRefIdx( REF_PIC_LIST_1, min( m_pcCfg->getGOPEntry( bNalRAP ? MAX_GOP : iGOPid ).m_numRefPicsActive, (pcSlice->getRPS()->getNumberOfPictures() + pcSlice->getSPS()->getNumberOfUsableInterViewRefs()) ) );
+#endif
+    TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
+    refPicListModification->setRefPicListModificationFlagL0( false );
 #if !H0137_0138_LIST_MODIFICATION
       refPicListModification->setNumberOfRefPicListModificationsL0(0);
@@ -363,5 +373,10 @@
       if( pcSlice->getSliceType() == B_SLICE )
       {
+#if !QC_REM_IDV
         if( m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid ).m_sliceType == 'P' ) { pcSlice->setSliceType( P_SLICE ); }
+#else
+      Bool bRAP = ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR)) && (pcSlice->getSPS()->getViewId())  ? 1: 0;
+      if( m_pcCfg->getGOPEntry( bRAP ? MAX_GOP : iGOPid ).m_sliceType == 'P' ) { pcSlice->setSliceType( P_SLICE ); }
+#endif
       }
       
@@ -830,5 +845,9 @@
       if ( m_bSeqFirst )
       {
-#if VIDYO_VPS_INTEGRATION
+#if MVHEVC
+      if(!m_pcEncTop->getLayerId())
+      {
+#endif
+#if VIDYO_VPS_INTEGRATION|MVHEVC
         {
           OutputNALUnit nalu(NAL_UNIT_VPS, true, m_pcEncTop->getLayerId());
@@ -840,5 +859,5 @@
 #endif
 #if NAL_REF_FLAG
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
         OutputNALUnit nalu(NAL_UNIT_SPS, true, m_pcEncTop->getLayerId());
 #else
@@ -861,6 +880,10 @@
 
 #if NAL_REF_FLAG
-#if VIDYO_VPS_INTEGRATION 
+#if VIDYO_VPS_INTEGRATION|MVHEVC 
+#if MVHEVC
         nalu = NALUnit(NAL_UNIT_PPS, true, m_pcEncTop->getLayerId());
+#else
+        nalu = NALUnit(NAL_UNIT_PPS, true, m_pcEncTop->getLayerId());
+#endif
 #else
         nalu = NALUnit(NAL_UNIT_PPS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
@@ -873,7 +896,9 @@
         writeRBSPTrailingBits(nalu.m_Bitstream);
         accessUnit.push_back(new NALUnitEBSP(nalu));
-
-        m_bSeqFirst = false;
-      }
+#if MVHEVC
+      }
+#endif
+      m_bSeqFirst = false;
+    }
 
       /* use the main bitstream buffer for storing the marshalled picture */
@@ -993,5 +1018,5 @@
 #if NAL_REF_FLAG
         OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced(),
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION &!MVHEVC
                            m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer() );
 #else
@@ -1469,5 +1494,5 @@
           {
 #if NAL_REF_FLAG
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION | MVHEVC
             OutputNALUnit nalu(NAL_UNIT_APS, true, m_pcEncTop->getLayerId());
 #else
@@ -1535,5 +1560,5 @@
 
 #if NAL_REF_FLAG
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION | MVHEVC
         OutputNALUnit nalu(NAL_UNIT_SEI, false, m_pcEncTop->getLayerId());
 #else
@@ -1973,5 +1998,7 @@
   case NAL_UNIT_CODED_SLICE: return "SLICE";
 #if H0566_TLA
+#if !QC_REM_IDV
   case NAL_UNIT_CODED_SLICE_IDV: return "IDV";
+#endif
   case NAL_UNIT_CODED_SLICE_CRA: return "CRA";
   case NAL_UNIT_CODED_SLICE_TLA: return "TLA";
@@ -2188,5 +2215,9 @@
     if( bInterViewOnlySlice ) 
     { 
+#if !QC_REM_IDV
       return NAL_UNIT_CODED_SLICE_IDV; 
+#else
+      return NAL_UNIT_CODED_SLICE_IDR;
+#endif
     }
     else
@@ -2201,5 +2232,9 @@
       if( bInterViewOnlySlice ) 
       { 
+#if !QC_REM_IDV
         return NAL_UNIT_CODED_SLICE_IDV; 
+#else
+        return NAL_UNIT_CODED_SLICE_CRA; 
+#endif
       }
       else
@@ -2216,5 +2251,9 @@
       if( bInterViewOnlySlice ) 
       { 
+#if !QC_REM_IDV
         return NAL_UNIT_CODED_SLICE_IDV; 
+#else
+        return NAL_UNIT_CODED_SLICE_IDR;
+#endif
       }
       else
@@ -2454,5 +2493,10 @@
 
   // analyze inter-view modifications
+#if !QC_REM_IDV
   GOPEntryMvc gem = m_pcCfg->getGOPEntry( (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDV) ? MAX_GOP : iGOPid );
+#else
+  Bool bRAP = ((getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_IDR) || (getNalUnitType(uiPOCCurr) == NAL_UNIT_CODED_SLICE_CRA)) && (pcSlice->getSPS()->getViewId()) ? 1:0;
+  GOPEntryMvc gem = m_pcCfg->getGOPEntry( bRAP ? MAX_GOP : iGOPid );
+#endif
   Int numL0Modifications = 0;
   Int numL1Modifications = 0;
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 194)
@@ -396,5 +396,5 @@
 }
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
 Void TEncSbac::codeVPS( TComVPS* pcVPS )
 {
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSbac.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSbac.h	(revision 194)
@@ -98,5 +98,5 @@
   //--SBAC RD
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Void  codeVPS                 ( TComVPS* pcVPS );
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 194)
@@ -4284,5 +4284,7 @@
   }
 #endif
-
+#if MVHEVC
+  m_pcRdCost->setMultiviewReg( 0 );
+#endif
   setWpScalingDistParam( pcCU, iRefIdxPred, eRefPicList );
   //  Do integer search
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 194)
@@ -162,5 +162,5 @@
  \param pPPS          PPS associated with the slice
  */
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
 Void TEncSlice::initEncSlice( TComPic* pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS * pVPS, TComSPS* pSPS, TComPPS *pPPS )
 #else
@@ -172,5 +172,5 @@
   
   rpcSlice = pcPic->getSlice(0);
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   rpcSlice->setVPS( pVPS );
 #endif
@@ -820,7 +820,7 @@
   UInt uiTileStartLCU = 0;
   UInt uiTileLCUX     = 0;
-
+#if !MVHEVC
   Int iLastPosY = -1;
-
+#endif
   // for every CU in slice
   UInt uiEncCUOrder;
@@ -833,5 +833,5 @@
     TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
     pcCU->initCU( rpcPic, uiCUAddr );
-
+#if !MVHEVC
     if ( m_pcRdCost->getUseRenModel() )
     {
@@ -847,5 +847,5 @@
       }
     }    
-
+#endif
     // inherit from TR if necessary, select substream to use.
     if( m_pcCfg->getUseSBACRD() )
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSlice.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSlice.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncSlice.h	(revision 194)
@@ -110,5 +110,5 @@
   
   /// preparation of slice encoding (reference marking, QP and lambda)
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   Void    initEncSlice        ( TComPic*  pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS );
 #else
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncTop.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/TEncTop.cpp	(revision 194)
@@ -785,5 +785,9 @@
   else
   {
+#if MVHEVC
+    m_cSPS.initMultiviewSPS   ( m_viewId);
+#else
     m_cSPS.initMultiviewSPS           ( m_viewId, m_iViewOrderIdx, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset );
+#endif
     if( m_viewId )
     {
@@ -993,5 +997,9 @@
 Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic )
 {
+#if QC_REM_IDV
+  if( (slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR ||slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) && slice->getSPS()->getViewId() && POCCurr == 0 )
+#else
   if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && POCCurr == 0 )
+#endif
   {
     TComReferencePictureSet* rps = slice->getLocalRPS();
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibExtractor/TExtrTop.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibExtractor/TExtrTop.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibExtractor/TExtrTop.cpp	(revision 194)
@@ -55,5 +55,5 @@
 Bool TExtrTop::extract( InputNALUnit& nalu, std::set<UInt>& rsuiExtractLayerIds )
 {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   //extraction now has to be done using layer_id
   UInt uiLayerId = nalu.m_layerId;
@@ -65,5 +65,5 @@
   m_cEntropyDecoder.setBitstream     ( nalu.m_Bitstream );
   
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   if ( nalu.m_nalUnitType == NAL_UNIT_VPS )
   {
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibExtractor/TExtrTop.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibExtractor/TExtrTop.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibExtractor/TExtrTop.h	(revision 194)
@@ -54,5 +54,5 @@
 {
 private:
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|MVHEVC
   TComVPS                 m_cVPS;
 #endif
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp	(revision 194)
@@ -36,5 +36,5 @@
 #include "TRenFilter.h"
 #include "TRenModSetupStrParser.h"
-
+#if !MVHEVC
 Int
 TRenModSetupStrParser::getNumOfModels()
@@ -450,2 +450,4 @@
   rcNextChar = m_pchSetStr[iPos];
 }
+#endif
+
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModSetupStrParser.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModSetupStrParser.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModSetupStrParser.h	(revision 194)
@@ -31,5 +31,5 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
-
+#if !MVHEVC
 #ifndef __TRENMODSETUPSTRPARSER__
 #define __TRENMODSETUPSTRPARSER__
@@ -127,2 +127,4 @@
 
 #endif //__TRENMODEL__
+#endif
+
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModel.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModel.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModel.cpp	(revision 194)
@@ -35,5 +35,5 @@
 #include "TRenFilter.h"
 #include "TRenModel.h"
-
+#if !MVHEVC
 ///////////  TRENMODEL //////////////////////
 TRenModel::TRenModel()
@@ -697,2 +697,4 @@
   }
 }
+#endif
+
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModel.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModel.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenModel.h	(revision 194)
@@ -32,5 +32,5 @@
  */
 
-
+#if !MVHEVC
 #ifndef __TRENMODEL__
 #define __TRENMODEL__
@@ -156,2 +156,4 @@
 
 #endif //__TRENMODEL__
+#endif
+
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenSingleModel.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 194)
@@ -36,4 +36,5 @@
 #include "TRenSingleModel.h"
 
+#if !MVHEVC
 ////////////// TRENSINGLE MODEL ///////////////
 template <BlenMod iBM, Bool bBitInc>
@@ -1956,2 +1957,4 @@
 }
 #endif
+#endif
+
Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenSingleModel.h
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenSingleModel.h	(revision 193)
+++ branches/HTM-5.0-Qualcomm/source/Lib/TLibRenderer/TRenSingleModel.h	(revision 194)
@@ -32,6 +32,6 @@
  */
 
-
-#ifndef __TRENSINGLEMODEL__
+#if !MVHEVC
+#ifndef __TRENSINGLEMODEL__ 
 #define __TRENSINGLEMODEL__
 
@@ -391,2 +391,4 @@
 
 #endif //__TRENSINGLEMODEL__
+#endif
+
