Index: branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/NALwrite.cpp
===================================================================
--- branches/HTM-5.0-Qualcomm/source/Lib/TLibEncoder/NALwrite.cpp	(revision 192)
+++ 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 192)
+++ 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 192)
+++ 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 192)
+++ 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 192)
+++ 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 192)
+++ 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 192)
+++ 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 192)
+++ 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 192)
+++ 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 192)
+++ 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 192)
+++ 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 192)
+++ 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 192)
+++ 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 192)
+++ 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();
