Index: /trunk/CommonTestConditionsCfgs/baseCfg_2view+depth.cfg
===================================================================
--- /trunk/CommonTestConditionsCfgs/baseCfg_2view+depth.cfg	(revision 209)
+++ /trunk/CommonTestConditionsCfgs/baseCfg_2view+depth.cfg	(revision 210)
@@ -195,4 +195,8 @@
 InterViewSkip             : 0                                      # interview SKIP mode
 InterViewSkipLambdaScale  : 8                                      # lambda scale for inter-view skip mode
+DisparitySearchRangeRestriction : 0                                # 0: No disparity restriction 1: Use disparity restriction
+VerticalDisparitySearchRange    : 56                               # vertical disparity search range (in luma samples)
+FCO                        : 0                                     # Flexible coding order flag in 3DV
+FCOCodingOrder             : T0D0D1T1                              # Coding order for Flexible coding order in 3DV
 
 
@@ -207,4 +211,5 @@
 #========== view synthesis optimization (VSO) ==========
 VSOConfig                 : [cx0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) I(s0.25 s0.5 s0.75)]  # VSO configuration string
+#VSOConfig                 : [ox0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) I(s0.25 s0.5 s0.75)]  # VSO configuration string
 WVSO                      : 1                                    # use of WVSO (Depth distortion metric with a weighted depth fidelity term) 
 VSOWeight                 : 10                                   # weight of VSO ( in SAD case, cf. squared in SSE case )
Index: /trunk/CommonTestConditionsCfgs/baseCfg_2view.cfg
===================================================================
--- /trunk/CommonTestConditionsCfgs/baseCfg_2view.cfg	(revision 209)
+++ /trunk/CommonTestConditionsCfgs/baseCfg_2view.cfg	(revision 210)
@@ -189,5 +189,6 @@
 InterViewSkip             : 0                                      # interview SKIP mode
 InterViewSkipLambdaScale  : 8                                      # lambda scale for inter-view skip mode
-
+DisparitySearchRangeRestriction : 0                                # 0: No disparity restriction 1: Use disparity restriction
+VerticalDisparitySearchRange    : 56                               # vertical disparity search range (in luma samples)
 
 #========== depth coding tools ==========
Index: /trunk/CommonTestConditionsCfgs/baseCfg_3view+depth.cfg
===================================================================
--- /trunk/CommonTestConditionsCfgs/baseCfg_3view+depth.cfg	(revision 209)
+++ /trunk/CommonTestConditionsCfgs/baseCfg_3view+depth.cfg	(revision 210)
@@ -199,4 +199,8 @@
 InterViewSkip             : 0                                      # interview SKIP mode
 InterViewSkipLambdaScale  : 8                                      # lambda scale for inter-view skip mode
+DisparitySearchRangeRestriction : 0                                # 0: No disparity restriction 1: Use disparity restriction
+VerticalDisparitySearchRange    : 56                               # vertical disparity search range (in luma samples)
+FCO                        : 0                                      # Flexible coding order flag in 3DV
+FCOCodingOrder             : T0D0D1D2T1T2                           # Coding order for Flexible coding order in 3DV
 
 
@@ -211,4 +215,5 @@
 #========== view synthesis optimization (VSO) ==========
 VSOConfig                 : [cx0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) B(oo2) I(s0.25 s0.5 s0.75 s1.25 s1.5 s1.75)][cx2 B(cc1) I(s1.25 s1.5 s1.75)] # VSO configuration string
+#VSOConfig                 : [ox0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) B(oo2) I(s0.25 s0.5 s0.75 s1.25 s1.5 s1.75)][ox2 B(cc1) I(s1.25 s1.5 s1.75)] # VSO configuration string for FCO = 1
 WVSO                       : 1                                     # use of WVSO (Depth distortion metric with a weighted depth fidelity term) 
 VSOWeight                  : 10                                    # weight of VSO ( in SAD case, cf. squared in SSE case )
Index: /trunk/CommonTestConditionsCfgs/baseCfg_3view.cfg
===================================================================
--- /trunk/CommonTestConditionsCfgs/baseCfg_3view.cfg	(revision 209)
+++ /trunk/CommonTestConditionsCfgs/baseCfg_3view.cfg	(revision 210)
@@ -191,4 +191,6 @@
 InterViewSkip             : 0                                      # interview SKIP mode
 InterViewSkipLambdaScale  : 8                                      # lambda scale for inter-view skip mode
+DisparitySearchRangeRestriction : 0                                # 0: No disparity restriction 1: Use disparity restriction
+VerticalDisparitySearchRange    : 56                               # vertical disparity search range (in luma samples)
 
 
Index: /trunk/cfg/encoder_mvd.cfg
===================================================================
--- /trunk/cfg/encoder_mvd.cfg	(revision 209)
+++ /trunk/cfg/encoder_mvd.cfg	(revision 210)
@@ -198,4 +198,8 @@
 InterViewSkip             : 0                                      # interview SKIP mode
 InterViewSkipLambdaScale  : 8                                      # lambda scale for inter-view skip mode
+DisparitySearchRangeRestriction : 0                                # 0: No disparity restriction 1: Use disparity restriction
+VerticalDisparitySearchRange    : 56                               # vertical disparity search range (in luma samples)
+FCO                        : 0                                     # Flexible coding order flag in 3DV
+FCOCodingOrder             : T0D0D1T1D2T2                              # Coding order for Flexible coding order in 3DV
 
 
@@ -211,4 +215,6 @@
 VSOConfig                 : [cx0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) B(oo2) I(s0.25 s0.5 s0.75 s1.25 s1.5 s1.75)][cx2 B(cc1) I(s1.25 s1.5 s1.75)] # VSO configuration string (3 view) 
 VSOConfig                 : [cx0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0)        I(s0.25 s0.5 s0.75)]                                                   # VSO configuration string (2 view) 
+#VSOConfig                 : [ox0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) B(oo2) I(s0.25 s0.5 s0.75 s1.25 s1.5 s1.75)][ox2 B(cc1) I(s1.25 s1.5 s1.75)] # VSO configuration string 
+#VSOConfig                 : [ox0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) I(s0.25 s0.5 s0.75)]  # VSO configuration string
 WVSO                      : 1                                    # use of WVSO (Depth distortion metric with a weighted depth fidelity term) 
 VSOWeight                 : 10                                   # weight of VSO ( in SAD case, cf. squared in SSE case )
Index: /trunk/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- /trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 209)
+++ /trunk/source/App/TAppDecoder/TAppDecTop.cpp	(revision 210)
@@ -82,5 +82,5 @@
 Void TAppDecTop::decode()
 {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   increaseNumberOfViews( 0, 0, 0 );
 #else
@@ -88,4 +88,12 @@
 #endif
   
+#if FLEX_CODING_ORDER_M23723
+  Int iDepthViewIdx = 0;
+  Int iTextureViewIdx=0;
+  Bool firstFrame=1;
+  Bool viewIdZero=true;
+  Int fcoIndex=0;  //when the current frame is not first frame,use FCO_index stand for viewDepth. 
+#endif
+
 #if SONY_COLPIC_AVAILABILITY
   m_tDecTop[0]->setViewOrderIdx(0);
@@ -102,4 +110,12 @@
     pcListPic[i] = NULL;
     newPicture[i] = false;
+#if FLEX_CODING_ORDER_M23723
+#if  FIX_FCO_COMP_WARNING
+    m_fcoOrder[i] = ' ';
+#else
+    m_fcoOrder[i]=NULL;
+#endif
+#endif
+
   }
 
@@ -145,4 +161,9 @@
     {
       read(nalu, nalUnit);
+#if QC_MVHEVC_B0046
+    viewDepthId = nalu.m_layerId;
+    Int depth = 0;
+    Int viewId = viewDepthId;
+#else
 #if VIDYO_VPS_INTEGRATION
       Int viewId = 0;
@@ -156,15 +177,114 @@
         depth = getVPSAccess()->getActiveVPS()->getDepthFlag(nalu.m_layerId);
       }
+#if FLEX_CODING_ORDER_M23723
+      if (viewId>0)
+      {
+        viewIdZero=false;
+      }
+      if (viewIdZero==false&&viewId==0)
+      {
+        firstFrame=0; //if viewId has been more than zero and now it set to zero again, we can see that it is not the first view
+      }
+      if (firstFrame)
+      { // if the current view is first frame, we set the viewDepthId as texture plus depth and get the FCO order 
+        viewDepthId = iDepthViewIdx+iTextureViewIdx;
+        m_fcoViewDepthId=viewDepthId;
+      }
+      else
+      {//if current view is not first frame, we set the viewDepthId depended on the FCO order
+        viewDepthId=0;
+        if (depth)
+        {
+          for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
+          {
+            if (m_fcoOrder[fcoIndex]=='D')
+            {
+              if (viewId==viewDepthId)
+                break;
+              else
+                viewDepthId++;
+            }
+          }
+        }
+        else
+        {
+          for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
+          {
+            if (m_fcoOrder[fcoIndex]=='T')
+            {
+              if (viewId==viewDepthId)
+                break;
+              else
+                viewDepthId++;
+            }
+          }
+        }
+
+        viewDepthId=fcoIndex;
+
+      }
+
+
+#else
       viewDepthId = nalu.m_layerId;   // coding order T0D0T1D1T2D2
+#endif
+    
 #else
       Int viewId = nalu.m_viewId;
       Int depth = nalu.m_isDepth ? 1 : 0;
+#if FLEX_CODING_ORDER_M23723
+      if (viewId>0)
+      {
+        viewIdZero=false;
+      }
+      if (viewIdZero==false&&viewId==0)
+      {
+        firstFrame=0;
+      }
+      if (firstFrame)
+      {
+        viewDepthId = iDepthViewIdx+iTextureViewIdx;
+        m_fcoViewDepthId=viewDepthId;
+      }
+      else
+      {
+        viewDepthId=0;
+        if (depth)
+        {
+          for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
+          {
+            if (m_fcoOrder[fcoIndex]=='D')
+            {
+              if (viewId==viewDepthId)
+                break;
+              else
+                viewDepthId++;
+            }
+          }
+        }
+        else
+        {
+          for (fcoIndex=0;fcoIndex<2*MAX_VIEW_NUM;fcoIndex++ )
+          {
+            if (m_fcoOrder[fcoIndex]=='T')
+            {
+              if (viewId==viewDepthId)
+                break;
+              else
+                viewDepthId++;
+            }
+          }
+        }
+        viewDepthId=fcoIndex;
+      }
+#else
       viewDepthId = viewId * 2 + depth;   // coding order T0D0T1D1T2D2
 #endif
-      
+#endif
+#endif     
       newPicture[viewDepthId] = false;
       if( viewDepthId >= m_tDecTop.size() )      
       {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
         increaseNumberOfViews( viewDepthId, viewId, depth );
 #else
@@ -195,4 +315,14 @@
       if( !(m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) )
       {
+#if QC_MVHEVC_B0046
+        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])
@@ -209,4 +339,20 @@
         {
           previousPictureDecoded = true;
+#if FLEX_CODING_ORDER_M23723
+        if (firstFrame)
+        {
+            if (depth)
+            {
+                iDepthViewIdx++;
+                m_fcoOrder[viewDepthId]='D';
+            }
+            else
+           {
+                iTextureViewIdx++;
+                m_fcoOrder[viewDepthId]='T';
+           }
+          }
+
+#endif
         }
       }
@@ -218,5 +364,10 @@
     if( pcListPic[viewDepthId] )
     {
+#if QC_REM_IDV_B0046
+      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 +426,13 @@
         m_tDecTop[viewDepthIdx]->destroy() ;
       }
+#if QC_MVHEVC_B0046
+      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 +576,5 @@
   m_pocLastDisplay[viewDepthId] = -MAX_INT;
 }
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
 Void  TAppDecTop::increaseNumberOfViews  ( UInt layerId, UInt viewId, UInt isDepth )
 #else
@@ -422,5 +582,5 @@
 #endif
 {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   Int newNumberOfViewDepth = layerId + 1;
 #endif
@@ -429,5 +589,5 @@
     m_outputBitDepth = g_uiBitDepth + g_uiBitIncrement;
   }
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
   Int viewId = (newNumberOfViewDepth-1)>>1;   // coding order T0D0T1D1T2D2
   Bool isDepth = ((newNumberOfViewDepth % 2) == 0);  // coding order T0D0T1D1T2D2
@@ -442,5 +602,5 @@
       m_tVideoIOYuvReconFile.push_back(new TVideoIOYuv);
       Char buffer[4];
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
       sprintf(buffer,"_%i", viewId );
 #else
@@ -448,5 +608,5 @@
 #endif
       Char* nextFilename = NULL;
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
       if( isDepth)
 #else
@@ -463,5 +623,5 @@
         xAppendToFileNameEnd( m_pchReconFile, buffer, nextFilename);
       }
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
       if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
 #endif
@@ -480,5 +640,5 @@
   {
     m_tDecTop.push_back(new TDecTop);
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
     if( isDepth || ( !isDepth && (m_tVideoIOYuvReconFile.size() % 2) == 1 ) )
     {
@@ -490,5 +650,5 @@
       m_tDecTop.back()->setPictureDigestEnabled(m_pictureDigestEnabled);
       m_tDecTop.back()->setCamParsCollector( &m_cCamParsCollector );
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION&!QC_MVHEVC_B0046
     }
 #endif
@@ -498,5 +658,60 @@
 TDecTop* TAppDecTop::getTDecTop( Int viewId, Bool isDepth )
 { 
+#if FLEX_CODING_ORDER_M23723
+  Int viewnumber=0;
+  Int i=0;
+  Bool fcoFlag=0;
+  if (viewId>m_fcoViewDepthId)
+  {
+    return NULL;
+  }
+  else
+  {
+    if (isDepth)
+   {
+      for ( i=0; i<=m_fcoViewDepthId;i++)
+      {
+         if (m_fcoOrder[i]=='D')
+         {
+           if (viewnumber==viewId)
+           {
+             fcoFlag=1;
+             break;
+           }
+           else
+             viewnumber++;
+         }
+      }
+    }
+    else
+    {
+      for ( i=0; i<=m_fcoViewDepthId;i++)
+      {
+        if (m_fcoOrder[i]=='T')
+        {
+          if (viewnumber==viewId)
+          {
+            fcoFlag=1;
+            break;
+          }
+          else
+            viewnumber++;
+        }
+      }
+    }
+    if (fcoFlag)
+    {
+      return m_tDecTop[i];
+    }
+    else
+      return NULL;
+    
+  }
+
+    // coding order T0D0T1D1T2D2
+#else
   return m_tDecTop[(isDepth ? 1 : 0) + viewId * 2];  // coding order T0D0T1D1T2D2
+#endif
+ 
 } 
 
@@ -517,4 +732,7 @@
   assert( ( viewId >= 0 ) );
 
+#if FLEX_CODING_ORDER_M23723
+if (getTDecTop(viewId,isDepth))
+{
   TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic();
   TComPic* pcPic = NULL;
@@ -529,3 +747,20 @@
   return pcPic;
 }
+else
+  return NULL;
+#else
+
+  TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic();
+  TComPic* pcPic = NULL;
+  for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
+  {
+    if( (*it)->getPOC() == poc )
+    {
+      pcPic = *it;
+      break;
+    }
+  }
+  return pcPic;
+#endif
+}
 //! \}
Index: /trunk/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- /trunk/source/App/TAppDecoder/TAppDecTop.h	(revision 209)
+++ /trunk/source/App/TAppDecoder/TAppDecTop.h	(revision 210)
@@ -71,8 +71,13 @@
   Bool                            m_useDepth;
 
+#if FLEX_CODING_ORDER_M23723
+  Int  m_fcoViewDepthId;
+  Char m_fcoOrder[MAX_VIEW_NUM*2];
+#endif
+
   FILE*                           m_pScaleOffsetFile;
   CamParsCollector                m_cCamParsCollector;
 #if DEPTH_MAP_GENERATION
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   TComVPSAccess                   m_cVPSAccess;
 #endif
@@ -88,5 +93,5 @@
   Void  destroy           (); ///< destroy internal members
   Void  decode            (); ///< main decoding function
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   Void  increaseNumberOfViews  (UInt layerId, UInt viewId, UInt isDepth);
 #else
Index: /trunk/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 209)
+++ /trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 210)
@@ -111,4 +111,10 @@
   if (m_pchBitstreamFile != NULL)
     free (m_pchBitstreamFile) ;
+#if FLEX_CODING_ORDER_M23723
+  if (m_pchMVCJointCodingOrder != NULL)
+  {
+    free(m_pchMVCJointCodingOrder) ;
+  }
+#endif
 #if HHI_VSO
   if (  m_pchVSOConfig != NULL)
@@ -203,4 +209,9 @@
   string cfg_RowHeight;
   string cfg_ScalingListFile;
+
+ #if FLEX_CODING_ORDER_M23723
+  string cfg_JointCodingOrdering;
+#endif
+
   po::Options opts;
   opts.addOptions()
@@ -246,4 +257,8 @@
   
   ("NumberOfViews",         m_iNumberOfViews,    0, "Number of views")
+#if FLEX_CODING_ORDER_M23723
+  ("FCO",               m_b3DVFlexOrder,   false, "flexible coding order flag" )
+  ("FCOCodingOrder",   cfg_JointCodingOrdering,  string(""), "The coding order for joint texture-depth coding")
+#endif
   /* Unit definition parameters */
   ("MaxCUWidth",          m_uiMaxCUWidth,  64u)
@@ -276,4 +291,8 @@
   ("FastSearch", m_iFastSearch, 1, "0:Full search  1:Diamond  2:PMVFAST")
   ("SearchRange,-sr",m_iSearchRange, 96, "motion search range")
+#if DV_V_RESTRICTION_B0037
+  ("DisparitySearchRangeRestriction",m_bUseDisparitySearchRangeRestriction, false, "restrict disparity search range")
+  ("VerticalDisparitySearchRange",m_iVerticalDisparitySearchRange, 56, "vertical disparity search range")
+#endif
   ("BipredSearchRange", m_bipredSearchRange, 4, "motion search range for bipred refinement")
   ("HadamardME", m_bUseHADME, true, "hadamard ME for fractional-pel")
@@ -329,4 +348,7 @@
   /* Camera Paremetes */
   ("CameraParameterFile,cpf", m_pchCameraParameterFile,    (Char *) 0, "Camera Parameter File Name")
+#if QC_MVHEVC_B0046
+  ("BaseViewCameraNumbers" ,  m_aiVId,     std::vector<Int>(1, MAX_VIEW_NUM), "Numbers of base views")
+#endif
   ("BaseViewCameraNumbers" ,  m_pchBaseViewCameraNumbers,  (Char *) 0, "Numbers of base views")
 
@@ -526,5 +548,43 @@
   m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
   m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
-  
+#if FLEX_CODING_ORDER_M23723
+  m_pchMVCJointCodingOrder= cfg_JointCodingOrdering.empty()?NULL:strdup(cfg_JointCodingOrdering.c_str());
+  // If flexible order is enabled and if depth comes before the texture for a view, disable VSO
+#if HHI_VSO && DISABLE_FCO_FOR_VSO
+  Bool depthComesFirst = false;
+  int iter = 0;
+  if ( m_b3DVFlexOrder )
+  {
+    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
+    {
+      iter = 0; 
+      for ( Int ii=1; ii<12; ii+=2 )
+      {
+        Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0');
+        if ( iViewIdxCfg == iViewIdx )
+        {
+          iter ++; 
+          if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view
+          {
+            if(iter == 1)
+           { 
+            depthComesFirst = true;
+            break;
+           }
+          }
+          else
+          {
+            assert(m_pchMVCJointCodingOrder[ii-1]=='T');
+          }
+        }
+      }
+    }
+  }
+  if (depthComesFirst)
+  {
+    m_bUseVSO = false;
+  }
+#endif
+#endif
   m_pchColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
   m_pchRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
@@ -786,4 +846,5 @@
 }
 #else
+#if !QC_MVHEVC_B0046
   m_cCameraData     .init     ( (UInt)m_iNumberOfViews,
     m_uiInputBitDepth,
@@ -797,10 +858,12 @@
     LOG2_DISP_PREC_LUT );
 #endif
+#endif
 
 
   // check validity of input parameters
   xCheckParameter();
+#if !QC_MVHEVC_B0046
   m_cCameraData.check( false, true );
-  
+#endif
   // print-out parameters
   xPrintParameter();
@@ -850,4 +913,7 @@
   xConfirmPara( m_iFastSearch < 0 || m_iFastSearch > 2,                                     "Fast Search Mode is not supported value (0:Full search  1:Diamond  2:PMVFAST)" );
   xConfirmPara( m_iSearchRange < 0 ,                                                        "Search Range must be more than 0" );
+#if DV_V_RESTRICTION_B0037
+  xConfirmPara( m_iVerticalDisparitySearchRange <= 0 ,                                      "Vertical Disparity Search Range must be more than 0" );
+#endif
   xConfirmPara( m_bipredSearchRange < 0 ,                                                   "Search Range must be more than 0" );
   xConfirmPara( m_iMaxDeltaQP > 7,                                                          "Absolute Delta QP exceeds supported range (0 to 7)" );
@@ -1595,4 +1661,8 @@
   printf("Min PCM size                 : %d\n", 1 << m_uiPCMLog2MinSize);
   printf("Motion search range          : %d\n", m_iSearchRange );
+#if DV_V_RESTRICTION_B0037
+  printf("Disp search range restriction: %d\n", m_bUseDisparitySearchRangeRestriction );
+  printf("Vertical disp search range   : %d\n", m_iVerticalDisparitySearchRange );
+#endif
   printf("Intra period                 : %d\n", m_iIntraPeriod );
   printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType );
@@ -1745,4 +1815,12 @@
 #if TMVP_DEPTH_SWITCH
   printf("TMVP:%d ", (m_enableTMVP[1] ? 1 : 0) );
+#endif
+#if FLEX_CODING_ORDER_M23723
+  printf("FCO:%d ",   (m_b3DVFlexOrder ? 1: 0));
+
+  if(m_b3DVFlexOrder)
+  {
+    printf("CodingOrder: %s ", m_pchMVCJointCodingOrder);
+  }
 #endif
 #if HHI_VSO
Index: /trunk/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 209)
+++ /trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 210)
@@ -88,4 +88,10 @@
   Int       m_iNumberOfViews;                                 ///< number Views to Encode
   Bool      m_bUsingDepthMaps;
+  
+#if FLEX_CODING_ORDER_M23723
+  Char*  m_pchMVCJointCodingOrder;      ///<  texture-depth coding order
+  Bool    m_b3DVFlexOrder;    ///<  flexible coding order flag
+#endif
+
   // coding structure
   Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
@@ -109,4 +115,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 QC_MVHEVC_B0046
+  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)
@@ -200,4 +209,8 @@
   Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
   Int       m_iSearchRange;                                   ///< ME search range
+#if DV_V_RESTRICTION_B0037
+  Bool      m_bUseDisparitySearchRangeRestriction;            ///< restrict vertical search range for inter-view prediction
+  Int       m_iVerticalDisparitySearchRange;                  ///< ME vertical search range for inter-view prediction 
+#endif
   Int       m_bipredSearchRange;                              ///< ME search range for bipred refinement
   Bool      m_bUseFastEnc;                                    ///< flag for using fast encoder setting
@@ -285,6 +298,7 @@
   Char*     m_pchCameraParameterFile;                         ///< camera parameter file
   Char*     m_pchBaseViewCameraNumbers;
+#if !QC_MVHEVC_B0046
   TAppComCamPara m_cCameraData;
-
+#endif
   Int       m_iCodedCamParPrecision;                          ///< precision for coding of camera parameters
 
Index: /trunk/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 209)
+++ /trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 210)
@@ -67,9 +67,15 @@
 Void TAppEncTop::xInitLibCfg()
 {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
+#if !QC_MVHEVC_B0046
   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 QC_MVHEVC_B0046
+  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 QC_MVHEVC_B0046
+    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 ========
@@ -170,5 +181,8 @@
     m_acTEncTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
     m_acTEncTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
-
+#if DV_V_RESTRICTION_B0037
+    m_acTEncTopList[iViewIdx]->setUseDisparitySearchRangeRestriction ( m_bUseDisparitySearchRangeRestriction );
+    m_acTEncTopList[iViewIdx]->setVerticalDisparitySearchRange( m_iVerticalDisparitySearchRange );
+#endif
   //====== Quality control ========
     m_acTEncTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
@@ -386,4 +400,29 @@
     for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
     {
+
+#if FLEX_CODING_ORDER_M23723
+      // Detect whether depth comes before than texture for this view
+      Bool isDepthFirst = false;
+      if ( m_b3DVFlexOrder )
+      {
+        for ( Int ii=1; ii<12; ii+=2 )
+        {
+          Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0');
+          if ( iViewIdxCfg == iViewIdx )
+          {
+            if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view
+            {
+              isDepthFirst = true;
+            }
+            else
+            {
+              assert(m_pchMVCJointCodingOrder[ii-1]=='T');
+            }
+            break;
+          }
+        }
+      }
+#endif
+
       m_depthFrameRcvd.push_back(0);
       m_acTEncDepthTopList.push_back(new TEncTop); 
@@ -406,5 +445,9 @@
       m_acTEncDepthTopList[iViewIdx]->setViewId                       ( iViewIdx );
       m_acTEncDepthTopList[iViewIdx]->setIsDepth                      ( true );
+#if QC_MVHEVC_B0046
+      m_acTEncDepthTopList[iViewIdx]->setLayerId                      ( iViewIdx );
+#else
       m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
+#endif
 #if VIDYO_VPS_INTEGRATION
       layerId = iViewIdx * 2 + 1;
@@ -473,5 +516,8 @@
       m_acTEncDepthTopList[iViewIdx]->setSearchRange                  ( m_iSearchRange );
       m_acTEncDepthTopList[iViewIdx]->setBipredSearchRange            ( m_bipredSearchRange );
-
+#if DV_V_RESTRICTION_B0037
+      m_acTEncDepthTopList[iViewIdx]->setUseDisparitySearchRangeRestriction ( m_bUseDisparitySearchRangeRestriction );
+      m_acTEncDepthTopList[iViewIdx]->setVerticalDisparitySearchRange( m_iVerticalDisparitySearchRange );
+#endif
       //====== Quality control ========
       m_acTEncDepthTopList[iViewIdx]->setMaxDeltaQP                   ( m_iMaxDeltaQP  );
@@ -661,9 +707,17 @@
     m_acTEncDepthTopList[iViewIdx]->setUseDMM                     ( m_bUseDMM );
 #endif
+#if FLEX_CODING_ORDER_M23723 && HHI_DMM_PRED_TEX
+    m_acTEncDepthTopList[iViewIdx]->setUseDMM34( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseDMM );
+#endif
+
 #if OL_QTLIMIT_PREDCODING_B0068
     m_acTEncDepthTopList[iViewIdx]->setUseQTLPC                   (m_bUseQTLPC);
 #endif
 #if HHI_MPI
+#if FLEX_CODING_ORDER_M23723
+    m_acTEncDepthTopList[iViewIdx]->setUseMVI( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseMVI );
+#else
      m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
+#endif
 #endif
 #if RWTH_SDC_DLT_B0036
@@ -821,4 +875,14 @@
   {
     m_acTEncTopList[iViewIdx]->init( this );
+#if QC_MVHEVC_B0046
+  //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 +926,7 @@
   TComPicYuv*       pcPicYuvOrg = new TComPicYuv;
   TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
+#if !QC_MVHEVC_B0046
   TComPicYuv*       pcPdmDepthOrg    = new TComPicYuv;
+#endif
   TComPicYuv*       pcPicYuvRec = NULL;
   TComPicYuv*       pcDepthPicYuvRec = NULL;
@@ -963,4 +1029,5 @@
     {
       Int  iNumEncoded = 0;
+#if !QC_MVHEVC_B0046
       UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId );
       if ( iNextPoc < m_iFrameToBeEncoded )
@@ -968,4 +1035,55 @@
       m_cCameraData.update( iNextPoc );
       }
+#endif
+
+#if FLEX_CODING_ORDER_M23723
+      if (m_b3DVFlexOrder)
+      {
+        Int  iNumDepthEncoded = 0;
+        iNumEncoded = 0;
+        Int i=0;
+        Int iViewIdx=0;
+        Int iNumberofDepthViews = m_bUsingDepthMaps?m_iNumberOfViews:0;
+        for (Int j=0; j < (m_iNumberOfViews+ iNumberofDepthViews); j++ )
+        {
+          if (m_pchMVCJointCodingOrder[i]=='T')
+          {
+
+            i++;
+            assert(isdigit(m_pchMVCJointCodingOrder[i]));
+            iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0');
+
+            m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId );
+            xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false);
+            outputAccessUnits.clear();
+            i++;
+          }
+          else if ( m_pchMVCJointCodingOrder[i] == 'D')
+          {
+
+            i++;
+            if( m_bUsingDepthMaps )
+            {
+              assert(isdigit(m_pchMVCJointCodingOrder[i]));
+              iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0');
+#if SAIT_VSO_EST_A0033
+              if( m_bUseVSO && iNextPoc < m_iFrameToBeEncoded )
+              {
+                m_cCameraData.xSetDispCoeff( iNextPoc, iViewIdx );
+                m_acTEncDepthTopList[iViewIdx]->setDispCoeff( m_cCameraData.getDispCoeff() );
+              }
+#endif
+              m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId );
+              xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true);
+              outputAccessUnits.clear();
+              i++;
+            }
+          }
+        }
+      }
+      else
+      {
+
+#endif
       for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
       {
@@ -991,4 +1109,9 @@
         }
       }
+ 
+#if FLEX_CODING_ORDER_M23723
+      }
+#endif
+
 #if HHI_INTERVIEW_SKIP || HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED
       for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
@@ -1023,5 +1146,10 @@
   pcDepthPicYuvOrg = NULL;
   
+#if !QC_MVHEVC_B0046
+#if FIX_DEL_NULLPTR
+  if ( pcPdmDepthOrg != NULL && m_uiMultiviewMvRegMode )
+#else
   if ( pcPdmDepthOrg != NULL )
+#endif
   {
     pcPdmDepthOrg->destroy();
@@ -1029,5 +1157,5 @@
     pcPdmDepthOrg = NULL; 
   };
-
+#endif
   
   for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
@@ -1233,5 +1361,7 @@
     case NAL_UNIT_CODED_SLICE:
 #if H0566_TLA
+#if !QC_REM_IDV_B0046
     case NAL_UNIT_CODED_SLICE_IDV:
+#endif
     case NAL_UNIT_CODED_SLICE_TLA:
     case NAL_UNIT_CODED_SLICE_CRA:
Index: /trunk/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- /trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 209)
+++ /trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 210)
@@ -87,5 +87,5 @@
 #endif
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   TComVPS                     m_cVPS;
 #endif
@@ -139,4 +139,7 @@
 #endif
   
+#if QC_MVHEVC_B0046
+  TComVPS*          getVPS()  { return &m_cVPS; }
+#endif
 #if VIDYO_VPS_INTEGRATION
   TComVPS*          getVPS()  { return &m_cVPS; }
Index: /trunk/source/App/TAppRenderer/RendererMain.cpp
===================================================================
--- /trunk/source/App/TAppRenderer/RendererMain.cpp	(revision 209)
+++ /trunk/source/App/TAppRenderer/RendererMain.cpp	(revision 210)
@@ -43,4 +43,5 @@
 int main(int argc, char* argv[])
   {
+#if !QC_MVHEVC_B0046
   TAppRendererTop  cTAppRendererTop;
 
@@ -78,4 +79,5 @@
 
   return 0;
+#endif
 }
 
Index: /trunk/source/App/TAppRenderer/TAppRendererCfg.cpp
===================================================================
--- /trunk/source/App/TAppRenderer/TAppRendererCfg.cpp	(revision 209)
+++ /trunk/source/App/TAppRenderer/TAppRendererCfg.cpp	(revision 210)
@@ -59,5 +59,5 @@
 // Constructor / destructor / initialization / destroy
 // ====================================================================================================================
-
+#if !QC_MVHEVC_B0046
 TAppRendererCfg::TAppRendererCfg()
 {
@@ -516,2 +516,3 @@
   g_uiIBDI_MAX     = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1);
 }
+#endif
Index: /trunk/source/App/TAppRenderer/TAppRendererCfg.h
===================================================================
--- /trunk/source/App/TAppRenderer/TAppRendererCfg.h	(revision 209)
+++ /trunk/source/App/TAppRenderer/TAppRendererCfg.h	(revision 210)
@@ -50,5 +50,5 @@
 #include <string>
 #include <vector>
-
+#if !QC_MVHEVC_B0046
 // ====================================================================================================================
 // Class definition
@@ -134,5 +134,5 @@
 
 
-
+#endif
 #endif // __TAppRENDERERCFG__
 
Index: /trunk/source/App/TAppRenderer/TAppRendererTop.cpp
===================================================================
--- /trunk/source/App/TAppRenderer/TAppRendererTop.cpp	(revision 209)
+++ /trunk/source/App/TAppRenderer/TAppRendererTop.cpp	(revision 210)
@@ -45,5 +45,5 @@
 // Constructor / destructor / initialization / destroy
 // ====================================================================================================================
-
+#if !QC_MVHEVC_B0046
 TAppRendererTop::TAppRendererTop()
 {
@@ -1034,2 +1034,3 @@
 
 }
+#endif
Index: /trunk/source/App/TAppRenderer/TAppRendererTop.h
===================================================================
--- /trunk/source/App/TAppRenderer/TAppRendererTop.h	(revision 209)
+++ /trunk/source/App/TAppRenderer/TAppRendererTop.h	(revision 210)
@@ -50,5 +50,5 @@
 #include "../../Lib/TLibRenderer/TRenModel.h"
 
-
+#if !QC_MVHEVC_B0046
 // ====================================================================================================================
 // Class definition
@@ -87,4 +87,5 @@
 };// END CLASS DEFINITION TAppRendererTop
 
-#endif // __TAppRendererTOP__
+#endif
 
+#endif
Index: /trunk/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- /trunk/source/Lib/TLibCommon/CommonDef.h	(revision 209)
+++ /trunk/source/Lib/TLibCommon/CommonDef.h	(revision 210)
@@ -58,5 +58,5 @@
 
 #define HM_VERSION        "6.1"
-#define NV_VERSION        "5.0.1"                  ///< Current software version
+#define NV_VERSION        "5.0"                  ///< Current software version
 
 // ====================================================================================================================
@@ -185,4 +185,7 @@
 // VPS constants
 // ====================================================================================================================
+#if QC_MVHEVC_B0046
+#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_B0046
+  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|QC_MVHEVC_B0046
   NAL_UNIT_VPS,
 #else
Index: /trunk/source/Lib/TLibCommon/NAL.h
===================================================================
--- /trunk/source/Lib/TLibCommon/NAL.h	(revision 209)
+++ /trunk/source/Lib/TLibCommon/NAL.h	(revision 210)
@@ -51,5 +51,5 @@
   NalRefIdc   m_nalRefIDC;   ///< nal_ref_idc
 #endif
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   unsigned    m_layerId;
   unsigned    m_temporalId;  ///< temporal_id
@@ -69,5 +69,5 @@
     NalUnitType nalUnitType,
     Bool        nalRefFlag,
-#if !VIDYO_VPS_INTEGRATION    
+#if !VIDYO_VPS_INTEGRATION & !QC_MVHEVC_B0046    
     Int         viewId,
     Bool        isDepth,
@@ -78,5 +78,5 @@
     :m_nalUnitType (nalUnitType)
     ,m_nalRefFlag  (nalRefFlag)
-#if !VIDYO_VPS_INTEGRATION
+#if !VIDYO_VPS_INTEGRATION & !QC_MVHEVC_B0046
     ,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_B0046    
         || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDV
+#endif
         || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA
         || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA
Index: /trunk/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- /trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 209)
+++ /trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 210)
@@ -4331,4 +4331,5 @@
   {
     // col [2]
+#if !QC_TMVP_IDX_MOD_B0046
     Int iRefIdxSkip[2] = {-1, -1};
     for (Int i=0; i<2; i++)
@@ -4350,4 +4351,5 @@
       iRefIdxSkip[i] = (iRefIdxTmp != -1) ? iRefIdxTmp : 0;
     }
+#endif
     //>> MTK colocated-RightBottom
     UInt uiPartIdxRB;
@@ -4361,6 +4363,9 @@
 
     TComMv cColMv;
+#if QC_TMVP_IDX_MOD_B0046
+    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
     {
@@ -4395,6 +4400,9 @@
       }
     }
+#if !QC_TMVP_IDX_MOD_B0046
     iRefIdx = iRefIdxSkip[0];
-
+#else
+    iRefIdx = 0;
+#endif
     Bool bExistMV = false;
     UInt uiPartIdxCenter;
@@ -4414,5 +4422,9 @@
       if ( getSlice()->isInterB() )
       {       
+#if !QC_TMVP_IDX_MOD_B0046
         iRefIdx = iRefIdxSkip[1];
+#else
+        iRefIdx = 0;
+#endif
         bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
         if( bExistMV == false )
@@ -6427,4 +6439,10 @@
   if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 )
   {
+#if QC_IV_AS_LT_B0046
+    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 ) )
     {
@@ -6433,4 +6451,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);
@@ -6569,10 +6588,19 @@
   Int iNeibRefPOC;
 
+#if QC_IV_AS_LT_B0046
+  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 QC_IV_AS_LT_B0046
+    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);
@@ -6592,10 +6620,14 @@
     TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
     TComMv rcMv;
-
+#if QC_IV_AS_LT_B0046
+    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 )
@@ -6612,4 +6644,7 @@
     pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
     return true;
+#if QC_IV_AS_LT_B0046
+    }
+#endif
   }
   //---------------------- V2(END) --------------------//
@@ -6619,10 +6654,14 @@
     TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
     TComMv rcMv;
-
+#if QC_IV_AS_LT_B0046
+    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 )
@@ -6639,4 +6678,7 @@
     pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
     return true;
+#if QC_IV_AS_LT_B0046
+  }
+#endif
   }
   //---------------------- V3(END) --------------------//
@@ -6749,5 +6791,9 @@
   Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale;
 #if SONY_COLPIC_AVAILABILITY
+#if QC_IV_AS_LT_B0046
+  Int iColViewOrderIdx, iCurrViewOrderIdx, iCurrRefViewOrderIdx;
+#else
   Int iColViewOrderIdx, iColRefViewOrderIdx, iCurrViewOrderIdx, iCurrRefViewOrderIdx;
+#endif
 #endif
   TComMv cColMv;
@@ -6780,5 +6826,5 @@
   }
 
-#if !SONY_COLPIC_AVAILABILITY
+#if !SONY_COLPIC_AVAILABILITY&!QC_IV_AS_LT_B0046
   if( m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewId() != m_pcSlice->getViewId() )
     return false;
@@ -6808,4 +6854,5 @@
   iColRefPOC = pColCU->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);
 
+#if !QC_IV_AS_LT_B0046
 #if SONY_COLPIC_AVAILABILITY
   iColRefViewOrderIdx = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewOrderIdx();
@@ -6816,8 +6863,53 @@
   }
 #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 QC_IV_AS_LT_B0046
+  {
+    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
+#if QC_MVHEVC_B0046
+      rcMv = cColMv; //inter-view
+#else
+    {
+#if SONY_COLPIC_AVAILABILITY
+      Int iColRefViewOrderIdx = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewOrderIdx();
+      iScale = xGetDistScaleFactor(iCurrViewOrderIdx, iCurrRefViewOrderIdx, iColViewOrderIdx, iColRefViewOrderIdx);
+      if ( iScale == 4096 )
+      {
+        rcMv = cColMv;
+      }
+      else
+      {
+        rcMv = cColMv.scaleMv( iScale );
+      }
+#else
+      return false;
+#endif
+    }
+#endif
+  }
+#else
 #if SONY_COLPIC_AVAILABILITY
   iScale = 0;
@@ -6841,5 +6933,5 @@
     rcMv = cColMv.scaleMv( iScale );
   }
-
+#endif
   return true;
 }
Index: /trunk/source/Lib/TLibCommon/TComDepthMapGenerator.h
===================================================================
--- /trunk/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 209)
+++ /trunk/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 210)
@@ -239,5 +239,5 @@
   Bool              m_bDecoder;
   TComPrediction*   m_pcPrediction;
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   TComVPSAccess*    m_pcVPSAccess;
 #endif
Index: /trunk/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- /trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 209)
+++ /trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 210)
@@ -519,5 +519,10 @@
       UInt uiTempLayer = currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice()->getTLayer(); 
       Int iTempDiff = (iTempPoc > iPOCCurr) ? (iTempPoc - iPOCCurr): (iPOCCurr - iTempPoc);
+#if QC_REM_IDV_B0046
+      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: /trunk/source/Lib/TLibCommon/TComPic.h
===================================================================
--- /trunk/source/Lib/TLibCommon/TComPic.h	(revision 209)
+++ /trunk/source/Lib/TLibCommon/TComPic.h	(revision 210)
@@ -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|QC_MVHEVC_B0046
   TComVPS*      getVPS()              { return  m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getVPS();  }
 #endif
Index: /trunk/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- /trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 209)
+++ /trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 210)
@@ -924,6 +924,8 @@
 }
 #endif
+#if !QC_MVHEVC_B0046
   Int     ixFrac      = iHor & 0x3;
   Int     iyFrac      = iVer & 0x3;
+#endif
   Int     iRefOffset  = ( iHor >> 2 ) + ( iVer >> 2 ) * iRefStride;
 #endif
Index: /trunk/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- /trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 209)
+++ /trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 210)
@@ -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: /trunk/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 209)
+++ /trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 210)
@@ -44,5 +44,9 @@
 
 TComSlice::TComSlice()
+#if QC_MVHEVC_B0046
+: m_iPPSId                        ( 0  )
+#else
 : m_iPPSId                        ( -1 )
+#endif
 , m_iPOC                          ( 0 )
 , m_iLastIDR                      ( 0 )
@@ -142,4 +146,11 @@
   resetWpScalingLC(m_weightPredTableLC);
   initWpAcDcParam();
+#if QC_IV_AS_LT_B0046
+  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 QC_IV_AS_LT_B0046
+    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 QC_IV_AS_LT_B0046
+    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 QC_IV_AS_LT_B0046
+      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 QC_IV_AS_LT_B0046
+       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 QC_IV_AS_LT_B0046
+     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 QC_MVHEVC_B0046
+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|QC_MVHEVC_B0046
 : m_VPSId                     (  0)
 , m_SPSId                     (  0)
@@ -1481,5 +1548,9 @@
 , m_bLCMod                    (false)
 #if H0412_REF_PIC_LIST_RESTRICTION
+#if QC_MVHEVC_B0046
+, m_restrictedRefPicListsFlag   (  0)
+#else
 , m_restrictedRefPicListsFlag   (  1)
+#endif
 , m_listsModificationPresentFlag(  0)
 #endif
@@ -1522,4 +1593,7 @@
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
 , m_bUseDMM                   (false)
+#endif
+#if FLEX_CODING_ORDER_M23723 && HHI_DMM_PRED_TEX
+, m_bUseDMM34                   (false)
 #endif
 #if OL_QTLIMIT_PREDCODING_B0068
@@ -1734,8 +1808,9 @@
 TComSPS::initMultiviewSPS( UInt uiViewId, Int iViewOrderIdx, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset )
 {
+#if !QC_MVHEVC_B0046
   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 +1820,5 @@
   ::memset( m_aaiCodedScale,  0x00, sizeof( m_aaiCodedScale  ) );
   ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) );
+#if !QC_MVHEVC_B0046
   if( !m_bCamParInSliceHeader )
   {
@@ -1755,4 +1831,5 @@
     }
   }
+#endif
 }
 
@@ -2374,5 +2451,5 @@
 , m_ppsMap(MAX_NUM_PPS)
 , m_apsMap(MAX_NUM_APS)
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
 , m_vpsMap(MAX_NUM_VPS)
 #endif
Index: /trunk/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /trunk/source/Lib/TLibCommon/TComSlice.h	(revision 209)
+++ /trunk/source/Lib/TLibCommon/TComSlice.h	(revision 210)
@@ -144,5 +144,5 @@
 #endif
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
 /// VPS class
 
@@ -156,10 +156,23 @@
 
   UInt        m_uiExtensionType;
-  
+#if !QC_MVHEVC_B0046  
   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 !QC_MVHEVC_B0046  
   Bool        m_bDepthFlag[MAX_LAYER_NUM];
+#endif
   Int         m_iViewOrderIdx[MAX_LAYER_NUM];
+#if !QC_MVHEVC_B0046  
   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 !QC_MVHEVC_B0046
   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 !QC_MVHEVC_B0046 
   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 !QC_MVHEVC_B0046   
   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 QC_MVHEVC_B0046
+  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|QC_MVHEVC_B0046
   Int          m_VPSId;
 #endif
@@ -363,4 +394,8 @@
 #endif
 
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER_M23723
+  Bool  m_bUseDMM34;
+#endif
+
 #if OL_QTLIMIT_PREDCODING_B0068
   Bool m_bUseQTLPC;
@@ -391,5 +426,5 @@
   TComSPS();
   virtual ~TComSPS();
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   Int  getVPSId       ()         { return m_VPSId;          }
   Void setVPSId       (Int i)    { m_VPSId = i;             }
@@ -643,4 +678,9 @@
 #endif
 
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER_M23723
+  Bool getUseDMM34()         { return m_bUseDMM34; }
+  Void setUseDMM34( Bool b ) { m_bUseDMM34 = b;    }
+#endif
+
 #if OL_QTLIMIT_PREDCODING_B0068
   Void setUseQTLPC( Bool b ) { m_bUseQTLPC = b;    }
@@ -1221,6 +1261,9 @@
   
   // access channel
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   TComVPS*    m_pcVPS;
+#endif
+#if QC_IV_AS_LT_B0046
+  Bool                  m_bWasLongTerm[2][MAX_NUM_REF+1]; //was long-term picture
 #endif
   TComSPS*    m_pcSPS;
@@ -1297,5 +1340,5 @@
   Int        m_aaiCodedOffset[2][MAX_VIEW_NUM];
 
-#if SONY_COLPIC_AVAILABILITY
+#if SONY_COLPIC_AVAILABILITY|QC_MVHEVC_B0046
   Int         m_iViewOrderIdx;
 #endif
@@ -1311,8 +1354,13 @@
   Void      initTiles();
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   Void      setVPS          ( TComVPS* pcVPS ) { m_pcVPS = pcVPS; }
   TComVPS*  getVPS          () { return m_pcVPS; }
 #endif
+#if QC_IV_AS_LT_B0046
+  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 +1635,8 @@
   Void setViewId( Int viewId )       { m_viewId = viewId;   }
   Int  getViewId()                   { return m_viewId;     }
+#if QC_MVHEVC_B0046
+  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 +1707,10 @@
   }
 
+#if QC_MVHEVC_B0046
+  Void clearPSList()
+  {
+    m_paramsetMap.clear();
+  }
+#endif
 private:
   std::map<Int,T *> m_paramsetMap;
@@ -1665,5 +1723,5 @@
   ParameterSetManager();
   virtual ~ParameterSetManager();
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   //! store video parameter set and take ownership of it 
   Void storeVPS(TComVPS *vps) { m_vpsMap.storePS( vps->getVPSId(), vps); };
@@ -1671,4 +1729,9 @@
   TComVPS* getVPS(Int vpsId)  { return m_vpsMap.getPS(vpsId); };
   TComVPS* getFirstVPS()      { return m_vpsMap.getFirstPS(); };
+#if QC_MVHEVC_B0046
+  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 +1756,5 @@
   ParameterSetMap<TComPPS> m_ppsMap; 
   ParameterSetMap<TComAPS> m_apsMap; 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   ParameterSetMap<TComVPS> m_vpsMap; 
 #endif
Index: /trunk/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /trunk/source/Lib/TLibCommon/TypeDef.h	(revision 209)
+++ /trunk/source/Lib/TLibCommon/TypeDef.h	(revision 210)
@@ -41,5 +41,14 @@
 //! \ingroup TLibCommon
 //! \{
-
+#define QC_MVHEVC_B0046                   0   //JCT3V-B0046: disable 3DHEVC tools
+#define QC_IV_AS_LT_B0046                 1   //JCT3V-B0046: inter-view reference pictures are treated as long-term pictures, scaling of motion vectors for DCP based on ViewId/ViewOrderIdx is disabled  
+#define QC_TMVP_IDX_MOD_B0046             1   //JCT3V-B0046: the reference index for temporal merging candidate is set to 0, as defined in HEVC
+#define QC_REM_IDV_B0046                  1   //JCT3V-B0046: removal of IDV NAL unit type
+#define FIX_DEL_NULLPTR                   1
+#define FIX_MISUSE_REFINDEX               1
+#define FIX_FCO_COMP_WARNING              1
+#define DV_V_RESTRICTION_B0037            1   // JCT3V-B0037 disparity vector vertical range restriction
+
+#if !QC_MVHEVC_B0046
 ///// ***** FIXES *********
 // A
@@ -52,6 +61,11 @@
 #define FIX_DMM_NEG_DIST                  1
 #define FIX_LGE_DVMCP_B0133               1
-#define FIX_MISUSE_REFINDEX               1
-
+
+
+// FCO 
+#define FLEX_CODING_ORDER_M23723          1
+#if FLEX_CODING_ORDER_M23723
+  #define DISABLE_FCO_FOR_VSO             0 // Optional compile settings to disable VSO with FCO.
+#endif
 
 ///// ***** PATCHES *********
@@ -178,5 +192,5 @@
 
 #define HHI_MPI_MERGE_POS                 0
-
+#endif
 ///// ***** HM 6.1 *********
 #define SKIPFRAME_BUGFIX                  1 ///< bug fix to enable skipFrame at decoder
@@ -478,8 +492,12 @@
 // VPS INTEGRATION
 // ====================================================================================================================
-
+#if !QC_MVHEVC_B0046
 #if VIDYO_VPS_INTEGRATION
 #define MAX_NUM_VPS 10
 #endif
+#else
+#define MAX_NUM_VPS 1
+#endif
+
 
 // ====================================================================================================================
Index: /trunk/source/Lib/TLibDecoder/NALread.cpp
===================================================================
--- /trunk/source/Lib/TLibDecoder/NALread.cpp	(revision 209)
+++ /trunk/source/Lib/TLibDecoder/NALread.cpp	(revision 210)
@@ -132,4 +132,9 @@
 #endif
 
+#if QC_MVHEVC_B0046
+  //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_B0046
+    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_B0046
   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_B0046
+        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: /trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 209)
+++ /trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 210)
@@ -1338,5 +1338,83 @@
   }
 }
-
+#if QC_MVHEVC_B0046
+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 !QC_MVHEVC_B0046
   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 !QC_MVHEVC_B0046
   if(uiCode)
   {
@@ -1803,4 +1883,5 @@
     }
   }
+#endif
 }
 
@@ -1907,5 +1988,13 @@
     }
 #endif
+#if QC_REM_IDV_B0046
+#if !QC_MVHEVC_B0046
+  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_B0046
+#if !QC_MVHEVC_B0046
+      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 QC_MVHEVC_B0046
+    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 QC_MVHEVC_B0046
+    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 QC_MVHEVC_B0046
+    if( rpcSlice->getViewId() && rpcSlice->getSPS()->getListsModificationPresentFlag() )
+#else
+    if(rpcSlice->getSPS()->getListsModificationPresentFlag() )
+#endif
       {
 #endif
@@ -2944,4 +3052,29 @@
 }
 
+#if QC_MVHEVC_B0046
+/** 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: /trunk/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- /trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 209)
+++ /trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 210)
@@ -75,5 +75,7 @@
   Void  xReadFlagTr           (              UInt& rValue, const Char *pSymbolName);
 #endif
-  
+#if QC_MVHEVC_B0046
+  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|QC_MVHEVC_B0046
   Void  parseVPS            ( TComVPS* pcVPS );
 #endif
Index: /trunk/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- /trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 209)
+++ /trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 210)
@@ -71,5 +71,5 @@
 #endif
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   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|QC_MVHEVC_B0046
   Void    decodeVPS                   ( TComVPS* pcVPS ) { m_pcEntropyDecoderIf->parseVPS(pcVPS); }
 #endif
Index: /trunk/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- /trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 209)
+++ /trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 210)
@@ -87,5 +87,5 @@
   Void  setBitstream              ( TComInputBitstream* p  ) { m_pcBitstream = p; m_pcTDecBinIf->init( p ); }
   
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   Void  parseVPS                  ( TComVPS* pcVPS )  {}
 #endif
Index: /trunk/source/Lib/TLibDecoder/TDecSlice.cpp
===================================================================
--- /trunk/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 209)
+++ /trunk/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 210)
@@ -446,5 +446,5 @@
 , m_ppsBuffer(16)
 , m_apsBuffer(64)
-#if VIDYO_VPS_INTEGRATION 
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 
 , m_vpsBuffer(16)
 #endif
@@ -458,5 +458,5 @@
 }
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
 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|QC_MVHEVC_B0046
   m_vpsMap.mergePSList(m_vpsBuffer);
 #endif
Index: /trunk/source/Lib/TLibDecoder/TDecSlice.h
===================================================================
--- /trunk/source/Lib/TLibDecoder/TDecSlice.h	(revision 209)
+++ /trunk/source/Lib/TLibDecoder/TDecSlice.h	(revision 210)
@@ -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|QC_MVHEVC_B0046
   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|QC_MVHEVC_B0046 
   ParameterSetMap<TComVPS> m_vpsBuffer;
 #endif
Index: /trunk/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 209)
+++ /trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 210)
@@ -50,4 +50,7 @@
   m_aaiCodedScale          = new Int* [ MAX_VIEW_NUM ];
   m_aiViewOrderIndex       = new Int  [ MAX_VIEW_NUM ];
+#if QC_MVHEVC_B0046
+  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 QC_MVHEVC_B0046
+  m_bFirstNal                  = false;
+#endif
 }
 
@@ -578,5 +584,9 @@
   TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId());
   assert (vps != 0);
+#if !QC_REM_IDV_B0046
   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 QC_MVHEVC_B0046
+  TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId());
+#endif
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   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|QC_MVHEVC_B0046
+#if QC_MVHEVC_B0046
+  m_apcSlicePilot->setIsDepth(false);
+#endif
   m_apcSlicePilot->setVPS(m_parameterSetManagerDecoder.getPrefetchedVPS(0));
 #endif
   m_apcSlicePilot->initTiles();
-
+#if QC_MVHEVC_B0046
+  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 QC_MVHEVC_B0046
+    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 !QC_MVHEVC_B0046
 #if VIDYO_VPS_INTEGRATION
     pcSlice->setViewId( pcSlice->getVPS()->getViewId(nalu.m_layerId) );
@@ -958,4 +990,5 @@
     pcSlice->setIsDepth(m_isDepth);
 #endif
+#endif
 
 #if SONY_COLPIC_AVAILABILITY
@@ -969,6 +1002,16 @@
     assert( m_tAppDecTop != NULL );
     TComPic * const pcTexturePic = m_isDepth ? m_tAppDecTop->getPicFromView(  m_viewId, pcSlice->getPOC(), false ) : NULL;
+
+#if FLEX_CODING_ORDER_M23723
+    if (pcTexturePic != NULL)
+    {
+      assert( !m_isDepth || pcTexturePic != NULL );
+      pcSlice->setTexturePic( pcTexturePic );
+    }
+#else
     assert( !m_isDepth || pcTexturePic != NULL );
     pcSlice->setTexturePic( pcTexturePic );
+#endif
+
 
     std::vector<TComPic*> apcInterViewRefPics = m_tAppDecTop->getInterViewRefPics( m_viewId, pcSlice->getPOC(), m_isDepth, pcSlice->getSPS() );
@@ -1071,4 +1114,12 @@
   m_cGopDecoder.decompressGop(nalu.m_Bitstream, pcPic, false);
 
+#if QC_IV_AS_LT_B0046
+  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 +1133,5 @@
 }
 
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
 Void TDecTop::xDecodeVPS()
 {
@@ -1089,5 +1140,7 @@
   m_cEntropyDecoder.decodeVPS( vps );
   m_parameterSetManagerDecoder.storePrefetchedVPS(vps);  
+#if !QC_MVHEVC_B0046
   getTAppDecTop()->getVPSAccess()->addVPS( vps );
+#endif
 }
 #endif
@@ -1155,5 +1208,5 @@
   switch (nalu.m_nalUnitType)
   {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
     case NAL_UNIT_VPS:
       xDecodeVPS();
@@ -1178,5 +1231,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:
@@ -1193,4 +1248,30 @@
 }
 
+#if QC_MVHEVC_B0046
+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: /trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- /trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 209)
+++ /trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 210)
@@ -88,4 +88,7 @@
   Int**   m_aaiCodedScale;
   Int*    m_aiViewOrderIndex;
+#if QC_MVHEVC_B0046
+  Int*    m_aiViewId;
+#endif
   Int*    m_aiViewReceived;
   UInt    m_uiCamParsCodedPrecision;
@@ -168,5 +171,9 @@
   
   Void  deletePicBuffer();
-
+#if QC_MVHEVC_B0046
+  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 QC_MVHEVC_B0046
+  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|QC_MVHEVC_B0046
   Void      xDecodeVPS();
 #endif
Index: /trunk/source/Lib/TLibEncoder/NALwrite.cpp
===================================================================
--- /trunk/source/Lib/TLibEncoder/NALwrite.cpp	(revision 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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 209)
+++ /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();
Index: /trunk/source/Lib/TLibExtractor/TExtrTop.cpp
===================================================================
--- /trunk/source/Lib/TLibExtractor/TExtrTop.cpp	(revision 209)
+++ /trunk/source/Lib/TLibExtractor/TExtrTop.cpp	(revision 210)
@@ -55,5 +55,5 @@
 Bool TExtrTop::extract( InputNALUnit& nalu, std::set<UInt>& rsuiExtractLayerIds )
 {
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   //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|QC_MVHEVC_B0046
   if ( nalu.m_nalUnitType == NAL_UNIT_VPS )
   {
Index: /trunk/source/Lib/TLibExtractor/TExtrTop.h
===================================================================
--- /trunk/source/Lib/TLibExtractor/TExtrTop.h	(revision 209)
+++ /trunk/source/Lib/TLibExtractor/TExtrTop.h	(revision 210)
@@ -54,5 +54,5 @@
 {
 private:
-#if VIDYO_VPS_INTEGRATION
+#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
   TComVPS                 m_cVPS;
 #endif
Index: /trunk/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp
===================================================================
--- /trunk/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp	(revision 209)
+++ /trunk/source/Lib/TLibRenderer/TRenModSetupStrParser.cpp	(revision 210)
@@ -36,5 +36,5 @@
 #include "TRenFilter.h"
 #include "TRenModSetupStrParser.h"
-
+#if !QC_MVHEVC_B0046
 Int
 TRenModSetupStrParser::getNumOfModels()
@@ -450,2 +450,4 @@
   rcNextChar = m_pchSetStr[iPos];
 }
+#endif
+
Index: /trunk/source/Lib/TLibRenderer/TRenModSetupStrParser.h
===================================================================
--- /trunk/source/Lib/TLibRenderer/TRenModSetupStrParser.h	(revision 209)
+++ /trunk/source/Lib/TLibRenderer/TRenModSetupStrParser.h	(revision 210)
@@ -31,5 +31,5 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
-
+#if !QC_MVHEVC_B0046
 #ifndef __TRENMODSETUPSTRPARSER__
 #define __TRENMODSETUPSTRPARSER__
@@ -127,2 +127,4 @@
 
 #endif //__TRENMODEL__
+#endif
+
Index: /trunk/source/Lib/TLibRenderer/TRenModel.cpp
===================================================================
--- /trunk/source/Lib/TLibRenderer/TRenModel.cpp	(revision 209)
+++ /trunk/source/Lib/TLibRenderer/TRenModel.cpp	(revision 210)
@@ -35,5 +35,5 @@
 #include "TRenFilter.h"
 #include "TRenModel.h"
-
+#if !QC_MVHEVC_B0046
 ///////////  TRENMODEL //////////////////////
 TRenModel::TRenModel()
@@ -697,2 +697,4 @@
   }
 }
+#endif
+
Index: /trunk/source/Lib/TLibRenderer/TRenModel.h
===================================================================
--- /trunk/source/Lib/TLibRenderer/TRenModel.h	(revision 209)
+++ /trunk/source/Lib/TLibRenderer/TRenModel.h	(revision 210)
@@ -32,5 +32,5 @@
  */
 
-
+#if !QC_MVHEVC_B0046
 #ifndef __TRENMODEL__
 #define __TRENMODEL__
@@ -156,2 +156,4 @@
 
 #endif //__TRENMODEL__
+#endif
+
Index: /trunk/source/Lib/TLibRenderer/TRenSingleModel.cpp
===================================================================
--- /trunk/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 209)
+++ /trunk/source/Lib/TLibRenderer/TRenSingleModel.cpp	(revision 210)
@@ -36,4 +36,5 @@
 #include "TRenSingleModel.h"
 
+#if !QC_MVHEVC_B0046
 ////////////// TRENSINGLE MODEL ///////////////
 template <BlenMod iBM, Bool bBitInc>
@@ -1956,2 +1957,4 @@
 }
 #endif
+#endif
+
Index: /trunk/source/Lib/TLibRenderer/TRenSingleModel.h
===================================================================
--- /trunk/source/Lib/TLibRenderer/TRenSingleModel.h	(revision 209)
+++ /trunk/source/Lib/TLibRenderer/TRenSingleModel.h	(revision 210)
@@ -32,6 +32,6 @@
  */
 
-
-#ifndef __TRENSINGLEMODEL__
+#if !QC_MVHEVC_B0046
+#ifndef __TRENSINGLEMODEL__ 
 #define __TRENSINGLEMODEL__
 
@@ -391,2 +391,4 @@
 
 #endif //__TRENSINGLEMODEL__
+#endif
+
