Index: branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComDataCU.cpp	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComDataCU.cpp	(revision 303)
@@ -3596,5 +3596,9 @@
 #if H3D_IVMP
 #if MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137
+#if FCO_FIX
+  const Int extraMergeCand = ( ( ( getSlice()->getIsDepth() && m_pcSlice->getTexturePic() ) || getSlice()->getSPS()->getMultiviewMvPredMode() )? 1 : 0 );
+#else
   const Int extraMergeCand = ( ( getSlice()->getIsDepth() || getSlice()->getSPS()->getMultiviewMvPredMode() )? 1 : 0 );
+#endif
 #else
   const Int extraMergeCand = ( getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 );
@@ -3651,4 +3655,7 @@
   if(!bNoPdmMerge)
   {
+#if FCO_DVP_REFINE_C0132_C0170
+    if( !getPic()->getDepthCoded() )
+#endif
     getDisMvpCandNBDV(uiPUIdx, uiAbsPartIdx, &cDisInfo , true
 #if MERL_VSP_C0152
@@ -3657,4 +3664,20 @@
 );
   }
+#if FCO_DVP_REFINE_C0132_C0170
+  if(getPic()->getDepthCoded() )
+  {
+    TComPic*      pcCodedDepthMap = getPic()->getRecDepthMap();
+    TComMv        cColMv;
+
+    cColMv.setZero();
+    estimateDVFromDM(uiPUIdx, pcCodedDepthMap, uiAbsPartIdx, &cColMv, false);
+
+    cDisInfo.iN = 1;
+    cDisInfo.m_acMvCand[0].setHor( cColMv.getHor() );
+    cDisInfo.m_acMvCand[0].setVer( cColMv.getVer() );
+    cDisInfo.m_aVIdxCan[0] = 0;
+
+  }
+#endif
   if(cDisInfo.iN==0)
   {
@@ -3669,5 +3692,9 @@
 
 #if MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137
+#if FCO_FIX
+  if( m_pcSlice->getIsDepth() && m_pcSlice->getTexturePic() )
+#else
   if( m_pcSlice->getIsDepth())
+#endif
   {
     UInt uiPartIdxCenter;
@@ -6079,4 +6106,7 @@
       DisInfo cDisInfo;
       cDisInfo.iN = 0;
+#if FCO_DVP_REFINE_C0132_C0170
+      if( !getPic()->getDepthCoded() )
+#endif
       getDisMvpCandNBDV(uiPartIdx, uiPartAddr, &cDisInfo, false
 #if MERL_VSP_C0152
@@ -6084,4 +6114,19 @@
 #endif
               ); 
+#if FCO_DVP_REFINE_C0132_C0170
+      if(getPic()->getDepthCoded() )
+      {
+        TComPic*      pcCodedDepthMap = getPic()->getRecDepthMap();
+        TComMv        cColMv;
+
+        cColMv.setZero();
+        estimateDVFromDM(uiPartIdx, pcCodedDepthMap, uiPartAddr, &cColMv, false);
+
+        cDisInfo.iN = 1;
+        cDisInfo.m_acMvCand[0].setHor( cColMv.getHor() );
+        cDisInfo.m_acMvCand[0].setVer( cColMv.getVer() );
+        cDisInfo.m_aVIdxCan[0] = 0;
+      }
+#endif
       if(cDisInfo.iN==0)
       {
@@ -7921,4 +7966,21 @@
   PartSize m_peSaved =  getPartitionSize( 0 );
   m_pePartSize[0] =  SIZE_2Nx2N;
+#if FCO_DVP_REFINE_C0132_C0170
+  if(getPic()->getDepthCoded() )
+  {
+    TComPic*      pcCodedDepthMap = getPic()->getRecDepthMap();
+    TComMv        cColMv;
+
+    cColMv.setZero();
+    estimateDVFromDM(0, pcCodedDepthMap, 0, &cColMv, false);
+
+    cDisInfo.iN = 1;
+    cDisInfo.m_acMvCand[0].setHor( cColMv.getHor() );
+    cDisInfo.m_acMvCand[0].setVer( cColMv.getVer() );
+    cDisInfo.m_aVIdxCan[0] = 0;
+
+  }
+  else
+#endif
   getDisMvpCandNBDV( 0, 0,  &cDisInfo, false );
   if( cDisInfo.iN == 0)
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComPic.cpp	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComPic.cpp	(revision 303)
@@ -59,4 +59,8 @@
 #endif
 #endif
+#if FCO_DVP_REFINE_C0132_C0170
+  m_bDepthCoded       = false;
+  m_pcRecDepthMap     = NULL;
+#endif
 #if H3D_IVMP
   m_pcOrgDepthMap     = NULL;
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComPic.h	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComPic.h	(revision 303)
@@ -73,4 +73,9 @@
 #endif
 
+#if FCO_DVP_REFINE_C0132_C0170
+  Bool                  m_bDepthCoded;
+  TComPic*              m_pcRecDepthMap;   
+#endif
+
 #if LG_ZEROINTRADEPTHRESI_A0087
   Int                   m_uiIntraPeriod;
@@ -171,4 +176,11 @@
   Bool          getCandPicCheckedFlag ()                { return m_checked;}
 #endif
+#endif
+
+#if FCO_DVP_REFINE_C0132_C0170
+  void setRecDepthMap(TComPic * pRecPic)                { m_pcRecDepthMap = pRecPic; }
+  TComPic * getRecDepthMap()                            { return m_pcRecDepthMap; }
+  void setDepthCoded(Bool flag)                         { m_bDepthCoded = flag; }
+  Bool getDepthCoded()                                  { return m_bDepthCoded; }
 #endif
 
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComPrediction.cpp	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComPrediction.cpp	(revision 303)
@@ -1434,5 +1434,4 @@
   Int dstStride = dstPic->getStride();
   Int depStride =  pPicBaseDepth->getStride();
-
   Int depthPosX = Clip3(0,   widthLuma - size_x - 1,  (posX/nTxtPerDepthX) + (mv->getHor()>>2));
   Int depthPosY = Clip3(0,   heightLuma- size_y - 1,  (posY/nTxtPerDepthY) + (mv->getVer()>>2));
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComSlice.cpp	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComSlice.cpp	(revision 303)
@@ -1761,5 +1761,9 @@
 
 Void
+#if FCO_FIX_SPS_CHANGE
+TComSPS::initMultiviewSPSDepth( UInt uiViewId, Int iViewOrderIdx, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset )
+#else
 TComSPS::initMultiviewSPSDepth( UInt uiViewId, Int iViewOrderIdx )
+#endif
 {
   AOT( uiViewId == 0 && iViewOrderIdx != 0 );
@@ -1769,8 +1773,28 @@
   m_iViewOrderIdx         = iViewOrderIdx;
   m_bDepth                = true;
+#if FCO_FIX_SPS_CHANGE
+  m_uiCamParPrecision     = ( m_uiViewId ? uiCamParPrecision : 0 );
+  m_bCamParInSliceHeader  = ( m_uiViewId ? bCamParSlice  : false );
+#else
   m_uiCamParPrecision     = 0;
   m_bCamParInSliceHeader  = false;
+#endif
   ::memset( m_aaiCodedScale,  0x00, sizeof( m_aaiCodedScale  ) );
   ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) );
+#if FCO_FIX_SPS_CHANGE
+#if !QC_MVHEVC_B0046
+  if( !m_bCamParInSliceHeader )
+  {
+    for( UInt uiBaseViewId = 0; uiBaseViewId < m_uiViewId; uiBaseViewId++ )
+    {
+      m_aaiCodedScale [ 0 ][ uiBaseViewId ] = aaiScale [ uiBaseViewId ][   m_uiViewId ];
+      m_aaiCodedScale [ 1 ][ uiBaseViewId ] = aaiScale [   m_uiViewId ][ uiBaseViewId ];
+      m_aaiCodedOffset[ 0 ][ uiBaseViewId ] = aaiOffset[ uiBaseViewId ][   m_uiViewId ];
+      m_aaiCodedOffset[ 1 ][ uiBaseViewId ] = aaiOffset[   m_uiViewId ][ uiBaseViewId ];
+    }
+  }
+#endif
+#endif
+
 }
 
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComSlice.h	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TComSlice.h	(revision 303)
@@ -623,5 +623,9 @@
 
   Void initMultiviewSPS      ( UInt uiViewId, Int iViewOrderIdx = 0, UInt uiCamParPrecision = 0, Bool bCamParSlice = false, Int** aaiScale = 0, Int** aaiOffset = 0 );
+#if FCO_FIX_SPS_CHANGE
+  Void initMultiviewSPSDepth ( UInt uiViewId, Int iViewOrderIdx, UInt uiCamParPrecision = 0, Bool bCamParSlice = false, Int** aaiScale = 0, Int** aaiOffset = 0 );
+#else
   Void initMultiviewSPSDepth ( UInt uiViewId, Int iViewOrderIdx );
+#endif
 
   UInt getViewId             ()  { return m_uiViewId; }
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TypeDef.h	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibCommon/TypeDef.h	(revision 303)
@@ -171,4 +171,12 @@
 #if FLEX_CODING_ORDER_M23723
 #define DISABLE_FCO_FOR_VSO               0 // Optional compile settings to disable VSO with FCO.
+#define FCO_DVP_REFINE_C0132_C0170        0 // depth oriented disparity vector prediction from JCT3V-C0132 and JCT3V-C0170
+#define FCO_FIX                           0 // Bug fix for C0137 and C0152 on FCO
+#define FCO_FIX_SPS_CHANGE                0 // Sending camera parameters in SPS of depth for depth to disparity conversion used by VSP and DoDVP
+#else
+#define DISABLE_FCO_FOR_VSO               0 // Optional compile settings to disable VSO with FCO.
+#define FCO_DVP_REFINE_C0132_C0170        0 // depth oriented disparity vector prediction from JCT3V-C0132 and JCT3V-C0170
+#define FCO_FIX                           0 // Fixing bugs from HTM 6.0 which 
+#define FCO_FIX_SPS_CHANGE                0 // Fixing bugs from HTM 6.0 which 
 #endif
 
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 303)
@@ -1501,9 +1501,45 @@
       if( uiCode )
       {
+#if FCO_FIX_SPS_CHANGE
+        UInt  uiViewId, uiCamParPrecision;
+        Int   iVOI;
+        Bool  bCamParSlice;
+        READ_UVLC( uiCode, "view_id" ); 
+        READ_SVLC( iCode, "view_order_idx" );
+        uiViewId = uiCode;
+        iVOI = iCode;
+
+        if ( uiViewId == 0 )
+        {
+          pcSPS->initMultiviewSPSDepth    ( uiViewId, iVOI );
+        }
+        else
+        {
+          READ_UVLC( uiCamParPrecision, "camera_parameter_precision" );
+          READ_FLAG( uiCode, "camera_parameter_in_slice_header" );    bCamParSlice = ( uiCode == 1 );
+          if( !bCamParSlice )
+          {
+            for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ )
+            {
+              READ_SVLC( iCode, "coded_scale" );   m_aaiTempScale [ uiBaseId ][ uiViewId ] = iCode;
+              READ_SVLC( iCode, "coded_offset" );   m_aaiTempOffset[ uiBaseId ][ uiViewId ] = iCode;
+              READ_SVLC( iCode, "inverse_coded_scale_plus_coded_scale" );   m_aaiTempScale [ uiViewId ][ uiBaseId ] = iCode - m_aaiTempScale [ uiBaseId ][ uiViewId ];
+              READ_SVLC( iCode, "inverse_coded_offset_plus_coded_offset" );   m_aaiTempOffset[ uiViewId ][ uiBaseId ] = iCode - m_aaiTempOffset[ uiBaseId ][ uiViewId ];
+            }
+          }
+          pcSPS->initMultiviewSPSDepth( uiViewId, iVOI, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset );
+
+        }
+#else
         READ_UVLC( uiCode, "view_id" ); 
         READ_SVLC(  iCode, "view_order_idx" ); 
         pcSPS->initMultiviewSPSDepth    ( uiCode, iCode );
+#endif
 #if DEPTH_MAP_GENERATION
+#if FCO_FIX_SPS_CHANGE
+        pcSPS->setPredDepthMapGeneration( uiViewId, true );
+#else
         pcSPS->setPredDepthMapGeneration( uiCode, true );
+#endif
 #endif
 #if H3D_IVRP
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibDecoder/TDecTop.cpp	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibDecoder/TDecTop.cpp	(revision 303)
@@ -193,13 +193,18 @@
 
   AOF( pcSlice->getSPS()->getViewId() < MAX_VIEW_NUM );
+#if !FCO_FIX  // Under flexible coding order, depth may need the camera parameters
   if ( pcSlice->getSPS()->isDepth  () )
   {
     return;
   }
+#endif
   Bool  bFirstAU          = ( pcSlice->getPOC()               == 0 );
   Bool  bFirstSliceInAU   = ( pcSlice->getPOC()               != Int ( m_iLastPOC ) );
   Bool  bFirstSliceInView = ( pcSlice->getSPS()->getViewId()  != UInt( m_iLastViewId ) || bFirstSliceInAU );
   AOT(  bFirstSliceInAU  &&   pcSlice->getSPS()->getViewId()  != 0 );
+#if FCO_FIX
+#else
   AOT( !bFirstSliceInAU  &&   pcSlice->getSPS()->getViewId()   < UInt( m_iLastViewId ) );
+#endif
   AOT( !bFirstSliceInAU  &&   pcSlice->getSPS()->getViewId()   > UInt( m_iLastViewId + 1 ) );
   AOT( !bFirstAU         &&   pcSlice->getSPS()->getViewId()   > m_uiMaxViewId );
@@ -1171,4 +1176,27 @@
   }
 #endif
+
+#if FCO_DVP_REFINE_C0132_C0170
+  if(m_bFirstSliceInPicture)
+  {
+    pcPic->setDepthCoded(false);
+
+    if(m_viewId != 0)
+    {
+      if( m_isDepth == 0)
+      {
+        TComPic * recDepthMapBuffer;
+        recDepthMapBuffer = m_tAppDecTop->getPicFromView( m_viewId, pcSlice->getPOC(), true );
+        pcPic->setRecDepthMap(recDepthMapBuffer);
+
+        if(recDepthMapBuffer != NULL)
+        {
+          pcPic->setDepthCoded(true);
+        }
+      }
+    }
+  }
+#endif
+
 
 #if MERL_VSP_C0152 // set BW LUT 
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 303)
@@ -663,4 +663,21 @@
       WRITE_UVLC( pcSPS->getViewId(), "view_id" );
       WRITE_SVLC( pcSPS->getViewOrderIdx(), "view_order_idx" );
+#if FCO_FIX_SPS_CHANGE
+      if ( pcSPS->getViewId() )
+      {
+        WRITE_UVLC( pcSPS->getCamParPrecision(), "camera_parameter_precision" );
+        WRITE_FLAG( pcSPS->hasCamParInSliceHeader() ? 1 : 0, "camera_parameter_in_slice_header" );
+        if( !pcSPS->hasCamParInSliceHeader() )
+        {
+          for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ )
+          {
+            WRITE_SVLC( pcSPS->getCodedScale    ()[ uiId ], "coded_scale" );
+            WRITE_SVLC( pcSPS->getCodedOffset   ()[ uiId ], "coded_offset" );
+            WRITE_SVLC( pcSPS->getInvCodedScale ()[ uiId ] + pcSPS->getCodedScale ()[ uiId ], "inverse_coded_scale_plus_coded_scale" );
+            WRITE_SVLC( pcSPS->getInvCodedOffset()[ uiId ] + pcSPS->getCodedOffset()[ uiId ], "inverse_coded_offset_plus_coded_offset" );
+          }
+        }      
+      }
+#endif
     }
     else
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 303)
@@ -726,4 +726,22 @@
       m_uiStoredStartCUAddrForEncodingEntropySlice[uiStartCUAddrEntropySliceIdx++]  = uiNextCUAddr;
 
+#if FCO_DVP_REFINE_C0132_C0170
+      pcPic->setDepthCoded(false);
+
+      if(pcSlice->getViewId() != 0)
+      {
+        if(pcSlice->getSPS()->isDepth() == 0 )
+        {
+          TComPic * recDepthMapBuffer;
+          recDepthMapBuffer = m_pcEncTop->getEncTop()->getPicFromView( pcSlice->getViewId(), pcSlice->getPOC(), true );
+          pcSlice->getPic()->setRecDepthMap(recDepthMapBuffer);
+          if(recDepthMapBuffer->getReconMark())
+          {
+            pcPic->setDepthCoded(true);
+          }
+        }
+      }
+#endif
+
 #if DEPTH_MAP_GENERATION
       // init view component and predict virtual depth map
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 303)
@@ -60,4 +60,8 @@
   m_pcBufferLowLatSbacCoders    = NULL;
   m_pcBufferLowLatBinCoderCABACs  = NULL;
+#if FCO_DVP_REFINE_C0132_C0170
+  m_pPicBaseTxt = NULL;
+  m_pPicBaseDepth = NULL;
+#endif
 }
 
Index: branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncTop.cpp	(revision 302)
+++ branches/HTM-6.0-Mediatek/source/Lib/TLibEncoder/TEncTop.cpp	(revision 303)
@@ -712,5 +712,10 @@
   if( m_isDepth )
   {
+#if FCO_FIX_SPS_CHANGE
+    m_cSPS.initMultiviewSPSDepth    ( m_viewId, m_iViewOrderIdx, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset );
+#else
     m_cSPS.initMultiviewSPSDepth    ( m_viewId, m_iViewOrderIdx );
+#endif
+
 #if DEPTH_MAP_GENERATION
     m_cSPS.setPredDepthMapGeneration( m_viewId, true );
