Index: trunk/source/Lib/TLibEncoder/NALwrite.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/NALwrite.cpp	(revision 189)
+++ trunk/source/Lib/TLibEncoder/NALwrite.cpp	(revision 210)
@@ -64,4 +64,8 @@
 #endif
 
+#if QC_MVHEVC_B0046
+  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_B0046
   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 !QC_MVHEVC_B0046
 /**
  * Copy NALU from naluSrc to naluDest
@@ -222,4 +229,5 @@
   naluDest.m_Bitstream   = naluSrc.m_Bitstream;
 }
+#endif
 
 //! \}
Index: trunk/source/Lib/TLibEncoder/NALwrite.h
===================================================================
--- trunk/source/Lib/TLibEncoder/NALwrite.h	(revision 189)
+++ trunk/source/Lib/TLibEncoder/NALwrite.h	(revision 210)
@@ -62,5 +62,5 @@
     NalRefIdc nalRefIDC,
 #endif
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
     unsigned layerId,
 #else
@@ -70,5 +70,5 @@
     unsigned temporalID = 0)
 #if NAL_REF_FLAG
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   : NALUnit(nalUnitType, nalRefFlag, layerId, temporalID)
 #else
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 210)
@@ -375,4 +375,92 @@
 }
 
+#if QC_MVHEVC_B0046
+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 !QC_MVHEVC_B0046
   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 QC_MVHEVC_B0046
+    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_B0046
+    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_B0046
+      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: trunk/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 210)
@@ -114,5 +114,5 @@
   UInt  getCoeffCost          ()                { return  m_uiCoeffCost;  }
   
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   Void  codeVPS                 ( TComVPS* pcVPS );
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 210)
@@ -183,5 +183,8 @@
   Int       m_iSearchRange;                     //  0:Full frame
   Int       m_bipredSearchRange;
-
+#if DV_V_RESTRICTION_B0037
+  Bool      m_bUseDisparitySearchRangeRestriction;
+  Int       m_iVerticalDisparitySearchRange;
+#endif
   //====== Quality control ========
   Int       m_iMaxDeltaQP;                      //  Max. absolute delta QP (1:default)
@@ -307,5 +310,5 @@
 #endif
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   UInt     m_layerId;
 #endif
@@ -322,4 +325,8 @@
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
   Bool     m_bUseDMM;
+#endif
+
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER_M23723
+  Bool m_bUseDMM34;
 #endif
 
@@ -468,5 +475,8 @@
   Void      setSearchRange                  ( Int   i )      { m_iSearchRange = i; }
   Void      setBipredSearchRange            ( Int   i )      { m_bipredSearchRange = i; }
-
+#if DV_V_RESTRICTION_B0037
+  Void      setUseDisparitySearchRangeRestriction ( Bool   b )      { m_bUseDisparitySearchRangeRestriction = b; }
+  Void      setVerticalDisparitySearchRange ( Int   i )      { m_iVerticalDisparitySearchRange = i; }
+#endif
 #if HHI_INTER_VIEW_MOTION_PRED
   UInt      getMultiviewMvRegMode           ()      { return  m_uiMultiviewMvRegMode; }
@@ -559,5 +569,8 @@
   Int       getFastSearch                   ()      { return  m_iFastSearch; }
   Int       getSearchRange                  ()      { return  m_iSearchRange; }
-
+#if DV_V_RESTRICTION_B0037
+  Bool      getUseDisparitySearchRangeRestriction ()      { return  m_bUseDisparitySearchRangeRestriction; }
+  Int       getVerticalDisparitySearchRange ()      { return  m_iVerticalDisparitySearchRange; }
+#endif
 #if HHI_VSO
   //==== VSO  ==========
@@ -820,5 +833,5 @@
   Int       getTSIG()                            { return m_signHidingThreshold; }
 #endif
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION |QC_MVHEVC_B0046
   Void      setLayerId             ( UInt layerId )   { m_layerId = layerId; }
   UInt      getLayerId             ()               { return m_layerId; }
@@ -833,4 +846,9 @@
   Void      setUseDMM( Bool b) { m_bUseDMM = b;    }
   Bool      getUseDMM()        { return m_bUseDMM; }
+#endif
+
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER_M23723
+  Void setUseDMM34( Bool b) { m_bUseDMM34 = b;    }
+  Bool getUseDMM34()        { return m_bUseDMM34; }
 #endif
 
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 210)
@@ -121,5 +121,5 @@
 }
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
 Void TEncEntropy::encodeVPS( TComVPS* pcVPS )
 {
@@ -129,5 +129,5 @@
 #endif
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
 Void  codeVPS                 ( TComVPS* pcVPS );
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.h	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.h	(revision 210)
@@ -76,5 +76,5 @@
   virtual UInt  getCoeffCost          ()                = 0;
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
 #endif
@@ -242,5 +242,5 @@
   
 public:
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   Void encodeVPS               ( TComVPS* pcVPS);
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 210)
@@ -246,5 +246,5 @@
 
       std::vector<TComAPS>& vAPS = m_pcEncTop->getAPS();
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
     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_B0046
+      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_B0046
       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);
@@ -353,8 +363,34 @@
       assert( tAppEncTop != NULL );
 
+
+#if FLEX_CODING_ORDER_M23723
+      TComPic * pcTexturePic; 
+      if(m_pcEncTop->getIsDepth() == 1)
+      {
+        TComPicYuv * recText;
+        recText = tAppEncTop->getPicYuvFromView(m_pcEncTop->getViewId(), pcSlice->getPOC(), false ,true);
+        if(recText == NULL)
+        {
+           pcSlice->setTexturePic(NULL);
+        }
+        else
+        {
+           pcTexturePic = m_pcEncTop->getIsDepth() ? tAppEncTop->getPicFromView( m_pcEncTop->getViewId(), pcSlice->getPOC(), false ) : NULL;
+           pcSlice->setTexturePic( pcTexturePic );
+        }
+      }
+      else
+    {
+        pcTexturePic = m_pcEncTop->getIsDepth() ? tAppEncTop->getPicFromView( m_pcEncTop->getViewId(), pcSlice->getPOC(), false ) : NULL;
+        assert( !m_pcEncTop->getIsDepth() || pcTexturePic != NULL );
+          pcSlice->setTexturePic( pcTexturePic );
+      }
+
+#else
       TComPic * const pcTexturePic = m_pcEncTop->getIsDepth() ? tAppEncTop->getPicFromView( m_pcEncTop->getViewId(), pcSlice->getPOC(), false ) : NULL;
       assert( !m_pcEncTop->getIsDepth() || pcTexturePic != NULL );
       pcSlice->setTexturePic( pcTexturePic );
 
+#endif 
       std::vector<TComPic*> apcInterViewRefPics = tAppEncTop->getInterViewRefPics( m_pcEncTop->getViewId(), pcSlice->getPOC(), m_pcEncTop->getIsDepth(), pcSlice->getSPS() );
       pcSlice->setRefPicListMvc( rcListPic, apcInterViewRefPics );
@@ -363,5 +399,10 @@
       if( pcSlice->getSliceType() == B_SLICE )
       {
+#if !QC_REM_IDV_B0046
         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
       }
       
@@ -451,6 +492,15 @@
 
 #if SAIT_VSO_EST_A0033
-    m_pcRdCost->setVideoRecPicYuv( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), false, true ) );
-    m_pcRdCost->setDepthPicYuv   ( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), true, false ) );
+#ifdef FLEX_CODING_ORDER_M23723    
+{
+  Bool flagRec;
+  flagRec =  ((m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), false, true) == NULL) ? false: true);
+  m_pcRdCost->setVideoRecPicYuv( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), false, flagRec ) );
+  m_pcRdCost->setDepthPicYuv   ( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), true, false ) );
+}
+#else
+  m_pcRdCost->setVideoRecPicYuv( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), false, true ) );
+  m_pcRdCost->setDepthPicYuv   ( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), true, false ) );
+#endif
 #endif
 #if LGE_WVSO_A0119
@@ -830,5 +880,9 @@
       if ( m_bSeqFirst )
       {
-#if VIDYO_VPS_INTEGRATION
+#if QC_MVHEVC_B0046
+      if(!m_pcEncTop->getLayerId())
+      {
+#endif
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
         {
           OutputNALUnit nalu(NAL_UNIT_VPS, true, m_pcEncTop->getLayerId());
@@ -840,5 +894,5 @@
 #endif
 #if NAL_REF_FLAG
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
         OutputNALUnit nalu(NAL_UNIT_SPS, true, m_pcEncTop->getLayerId());
 #else
@@ -861,6 +915,10 @@
 
 #if NAL_REF_FLAG
-#if VIDYO_VPS_INTEGRATION 
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 
+#if QC_MVHEVC_B0046
         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 +931,9 @@
         writeRBSPTrailingBits(nalu.m_Bitstream);
         accessUnit.push_back(new NALUnitEBSP(nalu));
-
-        m_bSeqFirst = false;
-      }
+#if QC_MVHEVC_B0046
+      }
+#endif
+      m_bSeqFirst = false;
+    }
 
       /* use the main bitstream buffer for storing the marshalled picture */
@@ -993,5 +1053,5 @@
 #if NAL_REF_FLAG
         OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced(),
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION &!QC_MVHEVC_B0046
                            m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer() );
 #else
@@ -1469,5 +1529,5 @@
           {
 #if NAL_REF_FLAG
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION | QC_MVHEVC_B0046
             OutputNALUnit nalu(NAL_UNIT_APS, true, m_pcEncTop->getLayerId());
 #else
@@ -1535,5 +1595,5 @@
 
 #if NAL_REF_FLAG
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION | QC_MVHEVC_B0046
         OutputNALUnit nalu(NAL_UNIT_SEI, false, m_pcEncTop->getLayerId());
 #else
@@ -1973,5 +2033,7 @@
   case NAL_UNIT_CODED_SLICE: return "SLICE";
 #if H0566_TLA
+#if !QC_REM_IDV_B0046
   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 +2250,9 @@
     if( bInterViewOnlySlice ) 
     { 
+#if !QC_REM_IDV_B0046
       return NAL_UNIT_CODED_SLICE_IDV; 
+#else
+      return NAL_UNIT_CODED_SLICE_IDR;
+#endif
     }
     else
@@ -2201,5 +2267,9 @@
       if( bInterViewOnlySlice ) 
       { 
+#if !QC_REM_IDV_B0046
         return NAL_UNIT_CODED_SLICE_IDV; 
+#else
+        return NAL_UNIT_CODED_SLICE_CRA; 
+#endif
       }
       else
@@ -2216,5 +2286,9 @@
       if( bInterViewOnlySlice ) 
       { 
+#if !QC_REM_IDV_B0046
         return NAL_UNIT_CODED_SLICE_IDV; 
+#else
+        return NAL_UNIT_CODED_SLICE_IDR;
+#endif
       }
       else
@@ -2454,5 +2528,10 @@
 
   // analyze inter-view modifications
+#if !QC_REM_IDV_B0046
   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: trunk/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 210)
@@ -396,5 +396,5 @@
 }
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
 Void TEncSbac::codeVPS( TComVPS* pcVPS )
 {
@@ -1076,4 +1076,13 @@
 #endif
 #if HHI_DMM_PRED_TEX
+
+#if FLEX_CODING_ORDER_M23723
+    if ( !pcCU->getSlice()->getSPS()->getUseDMM34() )
+    {
+      assert( uiDir != DMM_WEDGE_PREDTEX_D_IDX );
+      assert( uiDir != DMM_CONTOUR_PREDTEX_D_IDX );
+    }
+#endif
+
     if( uiDir == DMM_WEDGE_PREDTEX_D_IDX )     { xCodeWedgePredTexDeltaInfo  ( pcCU, uiAbsPartIdx ); }
     if( uiDir == DMM_CONTOUR_PREDTEX_D_IDX )   { xCodeContourPredTexDeltaInfo( pcCU, uiAbsPartIdx ); }
Index: trunk/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 210)
@@ -98,5 +98,5 @@
   //--SBAC RD
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   Void  codeVPS                 ( TComVPS* pcVPS );
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 210)
@@ -160,4 +160,8 @@
                       Int           iSearchRange,
                       Int           bipredSearchRange,
+#if DV_V_RESTRICTION_B0037
+                      Bool          bUseDisparitySearchRangeRestriction,
+                      Int           iVerticalDisparitySearchRange,
+#endif
                       Int           iFastSearch,
                       Int           iMaxDeltaQP,
@@ -172,4 +176,8 @@
   m_iSearchRange         = iSearchRange;
   m_bipredSearchRange    = bipredSearchRange;
+#if DV_V_RESTRICTION_B0037
+  m_bUseDisparitySearchRangeRestriction = bUseDisparitySearchRangeRestriction;
+  m_iVerticalDisparitySearchRange = iVerticalDisparitySearchRange;
+#endif
   m_iFastSearch          = iFastSearch;
   m_iMaxDeltaQP          = iMaxDeltaQP;
@@ -2236,4 +2244,9 @@
 #endif
 #if HHI_DMM_PRED_TEX
+      
+#if FLEX_CODING_ORDER_M23723
+      if ( pcCU->getSlice()->getSPS()->getUseDMM34() )
+      {
+#endif
       UInt uiTexTabIdx  = 0;
       Int  iTexDeltaDC1 = 0;
@@ -2259,4 +2272,7 @@
         uiRdModeList[ numModesForFullRD++ ] = DMM_CONTOUR_PREDTEX_D_IDX;
       }
+#if FLEX_CODING_ORDER_M23723
+      }
+#endif
 #endif
     }
@@ -2303,4 +2319,13 @@
 
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER_M23723
+      if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight, pcCU->getSlice()->getSPS()->getUseDMM34() ) 
+#if LGE_EDGE_INTRA_A0070
+        && uiOrgMode < EDGE_INTRA_IDX
+#endif
+        )
+
+#else
+
       if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight ) 
 #if LGE_EDGE_INTRA_A0070
@@ -2308,4 +2333,5 @@
 #endif
         )
+#endif
       {
         continue;
@@ -4214,6 +4240,9 @@
   TComYuv*      pcYuv = pcYuvOrg;
   m_iSearchRange = m_aaiAdaptSR[eRefPicList][iRefIdxPred];
-  
+
   Int           iSrchRng      = ( bBi ? m_bipredSearchRange : m_iSearchRange );
+#if DV_V_RESTRICTION_B0037
+  Int           iVerDispSrchRng = m_iVerticalDisparitySearchRange;  
+#endif
   TComPattern*  pcPatternKey  = pcCU->getPattern        ();
   
@@ -4252,8 +4281,26 @@
   
   TComMv      cMvPred = *pcMvPred;
-  
+
+#if DV_V_RESTRICTION_B0037
+  Bool bMv_VRng_Restricted = false;
+  if( pcCU->getSlice()->getViewId() > 0 
+      &&
+      pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getPOC() == pcCU->getSlice()->getPOC()
+      &&
+      m_bUseDisparitySearchRangeRestriction
+     )
+  {
+      bMv_VRng_Restricted = true;
+  }
+#endif
+
+#if DV_V_RESTRICTION_B0037
+  if ( bBi )  xSetSearchRange   ( pcCU, rcMv   , iSrchRng, cMvSrchRngLT, cMvSrchRngRB, bMv_VRng_Restricted, iVerDispSrchRng );
+  else        xSetSearchRange   ( pcCU, cMvPred, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, bMv_VRng_Restricted, iVerDispSrchRng );
+#else
   if ( bBi )  xSetSearchRange   ( pcCU, rcMv   , iSrchRng, cMvSrchRngLT, cMvSrchRngRB );
   else        xSetSearchRange   ( pcCU, cMvPred, iSrchRng, cMvSrchRngLT, cMvSrchRngRB );
-  
+#endif
+
   m_pcRdCost->getMotionCost ( 1, 0 );
   
@@ -4280,9 +4327,15 @@
     if( bMultiviewReg && !bBi )
     {
+#if DV_V_RESTRICTION_B0037
+      xSetSearchRange( pcCU, cOrgDepthMapMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, bMv_VRng_Restricted, iVerDispSrchRng  );
+#else
       xSetSearchRange( pcCU, cOrgDepthMapMv, iSrchRng, cMvSrchRngLT, cMvSrchRngRB );
-    }
-  }
-#endif
-
+#endif
+    }
+  }
+#endif
+#if QC_MVHEVC_B0046
+  m_pcRdCost->setMultiviewReg( 0 );
+#endif
   setWpScalingDistParam( pcCU, iRefIdxPred, eRefPicList );
   //  Do integer search
@@ -4330,6 +4383,9 @@
 }
 
-
+#if DV_V_RESTRICTION_B0037
+Void TEncSearch::xSetSearchRange ( TComDataCU* pcCU, TComMv& cMvPred, Int iSrchRng, TComMv& rcMvSrchRngLT, TComMv& rcMvSrchRngRB, Bool bMv_VRng_Restricted, Int iVerDispSrchRng )
+#else
 Void TEncSearch::xSetSearchRange ( TComDataCU* pcCU, TComMv& cMvPred, Int iSrchRng, TComMv& rcMvSrchRngLT, TComMv& rcMvSrchRngRB )
+#endif
 {
   Int  iMvShift = 2;
@@ -4346,4 +4402,17 @@
   rcMvSrchRngRB.setHor( cTmpMvPred.getHor() + (iSrchRng << iMvShift) );
   rcMvSrchRngRB.setVer( cTmpMvPred.getVer() + (iSrchRng << iMvShift) );
+
+#if DV_V_RESTRICTION_B0037
+  if ( bMv_VRng_Restricted ) {
+    Int iRestrictMvVrange = ( iVerDispSrchRng ) << iMvShift;    
+    if ( rcMvSrchRngRB.getVer() >= iRestrictMvVrange  ){
+      rcMvSrchRngRB.setVer( iRestrictMvVrange );
+    }
+    //restrict minus vector too
+    if ( rcMvSrchRngLT.getVer() <= -iRestrictMvVrange ){
+      rcMvSrchRngLT.setVer( -iRestrictMvVrange );
+    }
+  }
+#endif
   pcCU->clipMv        ( rcMvSrchRngLT );
   pcCU->clipMv        ( rcMvSrchRngRB );
@@ -6415,5 +6484,9 @@
 
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+#if ((HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX)&&FLEX_CODING_ORDER_M23723)
+Bool TEncSearch::predIntraLumaDMMAvailable( UInt uiMode, UInt uiWidth, UInt uiHeight, Bool bDMMAvailable34 )
+#else
 Bool TEncSearch::predIntraLumaDMMAvailable( UInt uiMode, UInt uiWidth, UInt uiHeight )
+#endif
 {
   if( uiMode < NUM_INTRA_MODE ) return true;
@@ -6443,4 +6516,12 @@
       bDMMAvailable = false;
     }
+
+#if FLEX_CODING_ORDER_M23723
+    if ( !bDMMAvailable34 )
+    {
+      bDMMAvailable = false;
+    }
+#endif
+
   }
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 210)
@@ -94,4 +94,8 @@
   Int             m_iSearchRange;
   Int             m_bipredSearchRange; // Search range for bi-prediction
+#if DV_V_RESTRICTION_B0037
+  Bool            m_bUseDisparitySearchRangeRestriction;
+  Int             m_iVerticalDisparitySearchRange;
+#endif
   Int             m_iFastSearch;
   Int             m_aaiAdaptSR[2][33];
@@ -132,4 +136,8 @@
             Int           iSearchRange,
             Int           bipredSearchRange,
+#if DV_V_RESTRICTION_B0037
+            Bool          bUseDisparitySearchRangeRestriction,
+            Int           iVerticalDisparitySearchRange,
+#endif
             Int           iFastSearch,
             Int           iMaxDeltaQP,
@@ -325,7 +333,14 @@
 
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+
   Bool predIntraLumaDMMAvailable  ( UInt           uiMode, 
                                     UInt           uiWidth, 
-                                    UInt           uiHeight );
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER_M23723
+                                    UInt         uiHeight, 
+                                    Bool         bDMMAvailable34 );
+#else
+                                    UInt         uiHeight );
+#endif
+
   Void xGetWedgeDeltaDCsMinDist   ( TComWedgelet*  pcWedgelet, 
                                     TComDataCU*    pcCU, 
@@ -523,4 +538,13 @@
                                     UInt&         ruiSAD );
   
+#if DV_V_RESTRICTION_B0037
+  Void xSetSearchRange            ( TComDataCU*   pcCU,
+                                    TComMv&       cMvPred,
+                                    Int           iSrchRng,
+                                    TComMv&       rcMvSrchRngLT,
+                                    TComMv&       rcMvSrchRngRB,
+                                    Bool          bDispSrchRngRst,
+                                    Int           iDispVerSrchRng );
+#else
   Void xSetSearchRange            ( TComDataCU*   pcCU,
                                     TComMv&       cMvPred,
@@ -528,4 +552,5 @@
                                     TComMv&       rcMvSrchRngLT,
                                     TComMv&       rcMvSrchRngRB );
+#endif
   
   Void xPatternSearchFast         ( TComDataCU*   pcCU,
Index: trunk/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 210)
@@ -162,5 +162,5 @@
  \param pPPS          PPS associated with the slice
  */
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
 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|QC_MVHEVC_B0046
   rpcSlice->setVPS( pVPS );
 #endif
@@ -820,7 +820,7 @@
   UInt uiTileStartLCU = 0;
   UInt uiTileLCUX     = 0;
-
+#if !QC_MVHEVC_B0046
   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 !QC_MVHEVC_B0046
     if ( m_pcRdCost->getUseRenModel() )
     {
@@ -847,5 +847,5 @@
       }
     }    
-
+#endif
     // inherit from TR if necessary, select substream to use.
     if( m_pcCfg->getUseSBACRD() )
Index: trunk/source/Lib/TLibEncoder/TEncSlice.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSlice.h	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncSlice.h	(revision 210)
@@ -110,5 +110,5 @@
   
   /// preparation of slice encoding (reference marking, QP and lambda)
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   Void    initEncSlice        ( TComPic*  pcPic, Int iPOCLast, UInt uiPOCCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS );
 #else
Index: trunk/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 189)
+++ trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 210)
@@ -375,6 +375,9 @@
   
   // initialize encoder search class
+#if DV_V_RESTRICTION_B0037
+  m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_bUseDisparitySearchRangeRestriction, m_iVerticalDisparitySearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() );
+#else
   m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() );
-
+#endif
   if(m_bUseALF)
   {
@@ -766,4 +769,9 @@
   m_cSPS.setUseDMM( m_bUseDMM );
 #endif
+
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER_M23723
+  m_cSPS.setUseDMM34( m_bUseDMM34 );
+#endif
+
 #if OL_QTLIMIT_PREDCODING_B0068
   m_cSPS.setUseQTLPC( m_bUseQTLPC );
@@ -785,5 +793,9 @@
   else
   {
+#if QC_MVHEVC_B0046
+    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 +1005,9 @@
 Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic )
 {
+#if QC_REM_IDV_B0046
+  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();
