Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.cpp	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.cpp	(revision 795)
@@ -153,4 +153,9 @@
   m_pucInterSDCMask       = NULL;
 #endif
+
+#if MTK_DDD_G0063
+  m_pucDisparityDerivedDepth = NULL;
+  m_pbUseDDD = NULL;
+#endif
 }
 
@@ -298,4 +303,9 @@
   m_pcPattern            = (TComPattern*)xMalloc(TComPattern, 1);
   
+#if MTK_DDD_G0063
+  m_pucDisparityDerivedDepth         = (UChar*  )xMalloc( UChar,  uiNumPartition);
+  m_pbUseDDD                         = (Bool*  ) xMalloc( Bool,   uiNumPartition);
+#endif 
+
   // create motion vector fields
   
@@ -375,4 +385,9 @@
 #if H_3D_NBDV 
     if ( m_pDvInfo            ) { xFree(m_pDvInfo);             m_pDvInfo           = NULL; }
+#endif
+
+#if MTK_DDD_G0063
+    if ( m_pucDisparityDerivedDepth ) { xFree(m_pucDisparityDerivedDepth);          m_pucDisparityDerivedDepth        = NULL; }
+    if ( m_pbUseDDD                 ) { xFree(m_pbUseDDD);                          m_pbUseDDD                        = NULL; }
 #endif
 
@@ -525,4 +540,10 @@
     m_pbICFlag[ui]   =  pcFrom->m_pbICFlag[ui];
 #endif
+
+#if MTK_DDD_G0063
+    m_pucDisparityDerivedDepth[ui] = pcFrom->m_pucDisparityDerivedDepth[ui];
+    m_pbUseDDD[ui] = pcFrom->m_pbUseDDD[ui];
+#endif
+
     m_puhWidth  [ui] = pcFrom->getWidth(ui);
     m_puhHeight [ui] = pcFrom->getHeight(ui);
@@ -602,4 +623,10 @@
     memset( m_pbICFlag          + firstElement, false,                    numElements * sizeof( *m_pbICFlag )   );
 #endif
+
+#if MTK_DDD_G0063
+    memset( m_pucDisparityDerivedDepth        + firstElement, 0,           numElements * sizeof( *m_pucDisparityDerivedDepth ) );
+    memset( m_pbUseDDD                        + firstElement, 0,           numElements * sizeof( *m_pbUseDDD ) );
+#endif
+
 #if H_3D_DIM
     for( Int i = 0; i < DIM_NUM_TYPE; i++ )
@@ -774,4 +801,10 @@
       m_pbICFlag[ui]  = false;
 #endif
+
+#if MTK_DDD_G0063
+      m_pucDisparityDerivedDepth[ui] = 0;
+      m_pbUseDDD[ui] = 0;
+#endif
+
 #if H_3D_DIM
       for( Int i = 0; i < DIM_NUM_TYPE; i++ )
@@ -879,4 +912,10 @@
   memset( m_puhARPW,            0, iSizeInUchar  );
 #endif
+
+#if MTK_DDD_G0063
+  memset( m_pucDisparityDerivedDepth,         0, iSizeInUchar );
+  memset( m_pbUseDDD,                         0, iSizeInBool );
+#endif
+
   UChar uhWidth  = g_uiMaxCUWidth  >> uiDepth;
   UChar uhHeight = g_uiMaxCUHeight >> uiDepth;
@@ -964,4 +1003,10 @@
       m_pbICFlag          [ui] = pcCU->m_pbICFlag[uiPartOffset+ui];
 #endif
+
+#if MTK_DDD_G0063
+      m_pucDisparityDerivedDepth[ui] = pcCU->m_pucDisparityDerivedDepth[uiPartOffset+ui];
+      m_pbUseDDD[ui]                 = pcCU->m_pbUseDDD[uiPartOffset+ui];
+#endif
+
 #if H_3D_DIM
       for( Int i = 0; i < DIM_NUM_TYPE; i++ )
@@ -1109,4 +1154,9 @@
 #endif
 
+#if MTK_DDD_G0063
+  m_pucDisparityDerivedDepth          = pcCU->getDDDepth()        + uiPart;
+  m_pbUseDDD                          = pcCU->getUseDDD()         + uiPart;
+#endif
+
   m_puhLumaIntraDir     = pcCU->getLumaIntraDir()     + uiPart;
   m_puhChromaIntraDir   = pcCU->getChromaIntraDir()   + uiPart;
@@ -1256,4 +1306,9 @@
 #if H_3D_ARP
   m_puhARPW            = pcCU->getARPW()                  + uiAbsPartIdx;
+#endif
+
+#if MTK_DDD_G0063
+  m_pucDisparityDerivedDepth         = pcCU->getDDDepth()              + uiAbsPartIdx;
+  m_pbUseDDD                         = pcCU->getUseDDD()              + uiAbsPartIdx;
 #endif
 
@@ -1314,4 +1369,10 @@
   memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar );
   
+#if MTK_DDD_G0063
+  memcpy( m_pucDisparityDerivedDepth          + uiOffset, pcCU->getDDDepth(),         iSizeInUchar );
+  memcpy( m_pbUseDDD                          + uiOffset, pcCU->getUseDDD(),          iSizeInBool );
+#endif
+
+
 #if H_3D_DIM
   for( Int i = 0; i < DIM_NUM_TYPE; i++ )
@@ -1410,4 +1471,9 @@
 #if H_3D_NBDV
   memcpy( rpcCU->getDvInfo()         + m_uiAbsIdxInLCU, m_pDvInfo,    sizeof(* m_pDvInfo)     * m_uiNumPartition );
+#endif
+
+#if MTK_DDD_G0063
+  memcpy( rpcCU->getDDDepth()          + m_uiAbsIdxInLCU, m_pucDisparityDerivedDepth,         iSizeInUchar  );
+  memcpy( rpcCU->getUseDDD()           + m_uiAbsIdxInLCU, m_pbUseDDD,                         iSizeInBool  );
 #endif
 
@@ -1544,4 +1610,9 @@
   memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar );
   
+#if MTK_DDD_G0063
+  memcpy( rpcCU->getDDDepth()          + uiPartOffset, m_pucDisparityDerivedDepth,         iSizeInUchar );
+  memcpy( rpcCU->getUseDDD()           + uiPartOffset, m_pbUseDDD,                         iSizeInBool );
+#endif
+
 #if H_3D_DIM
   for( Int i = 0; i < DMM_NUM_TYPE; i++ )
@@ -1611,4 +1682,22 @@
 #endif
 }
+
+#if MTK_DDD_G0063
+Void TComDataCU::setDDDepthSubParts ( UChar ucDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
+{
+    setSubPart<UChar>( ucDDD, m_pucDisparityDerivedDepth, uiAbsPartIdx, uiDepth, uiPartIdx );
+}
+
+Void TComDataCU::setUseDDD        ( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
+{
+    setSubPart<Bool>( bUseDDD, m_pbUseDDD, uiAbsPartIdx, uiDepth, uiPartIdx );
+}
+
+Void TComDataCU::setUseDDD( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiDepth )
+{
+    memset( m_pbUseDDD + uiAbsPartIdx, bUseDDD, (m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ))*sizeof(Bool) );
+}
+
+#endif
 
 // --------------------------------------------------------------------------------------------------------------------
@@ -3881,4 +3970,8 @@
   TComMvField tmpMV[2];
   UChar tmpDir;
+
+#if MTK_DDD_G0063
+  m_iUseDDDCandIdx = -1;
+#endif
 
   //////////////////////////////////
@@ -4328,5 +4421,109 @@
 #endif
   }
-
+#if MTK_DDD_G0063
+  if( m_pcSlice->getIsDepth() && m_pcSlice->getViewIndex() != 0  )
+  {
+      UInt uiPartIdx;
+      TComDataCU *pcTextureCU = m_pcSlice->getTexturePic()->getCU( getAddr() );
+      TComSlice *pcTextureSlice = pcTextureCU->getSlice();  
+
+
+      tmpMV[0].setMvField( cZeroMv, NOT_VALID );
+      tmpMV[1].setMvField( cZeroMv, NOT_VALID );
+      tmpDir = 0;
+
+      xDeriveCenterIdx( uiPUIdx, uiPartIdx); 
+
+      if ( pcTextureCU && !pcTextureCU->isIntra( uiPartIdx ) )
+      {
+
+          TComMvField cMVField;
+          UChar ucInterDir = pcTextureCU->getInterDir( uiPartIdx );
+
+          Int iDV = 0;
+          Int iViewIdx = 0;
+          if( ucInterDir & 1 )
+          {
+              pcTextureCU->getMvField( pcTextureCU, uiPartIdx, REF_PIC_LIST_0, cMVField );
+              if( pcTextureSlice->getRefPOC( REF_PIC_LIST_0, cMVField.getRefIdx()) == pcTextureSlice->getPOC() )
+              {
+                  iViewIdx = pcTextureSlice->getRefPic( REF_PIC_LIST_0, cMVField.getRefIdx())->getViewIndex();
+                  iDV = cMVField.getHor();
+
+
+                  Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_0, cMVField.getRefIdx() );
+
+                  if( iValidDepRef >= 0 )
+                  {
+                      const TComMv cAdd( 2, 2 );
+                      cMVField.getMv() += cAdd;
+                      cMVField.getMv() >>= 2;
+                      clipMv( cMVField.getMv() );
+                      tmpMV[ 0 ].setMvField( cMVField.getMv(), iValidDepRef );
+                      tmpDir = 1;
+                  }
+              }
+          }
+          if( !tmpDir && ( ucInterDir & 2 ))
+          {
+              pcTextureCU->getMvField( pcTextureCU, uiPartIdx, REF_PIC_LIST_1, cMVField );
+              if( pcTextureSlice->getRefPOC( REF_PIC_LIST_1, cMVField.getRefIdx()) == pcTextureSlice->getPOC() )
+              {
+                  iViewIdx = pcTextureSlice->getRefPic( REF_PIC_LIST_1, cMVField.getRefIdx())->getViewIndex();
+                  iDV = cMVField.getHor();
+
+                  Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_1, cMVField.getRefIdx() );
+
+                  if( iValidDepRef >= 0 )
+                  {
+                      const TComMv cAdd( 2, 2 );
+                      cMVField.getMv() += cAdd;
+                      cMVField.getMv() >>= 2;
+                      clipMv( cMVField.getMv() );
+                      tmpMV[ 1 ].setMvField( cMVField.getMv(), iValidDepRef );
+                      tmpDir = 2;
+                  }
+              }
+          }
+          if( tmpDir != 0 )
+          {
+              rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, 5-iCount, iCount3DV);
+              m_ucDDTmpDepth = m_pcSlice->getDepthFromDV( iDV,  iViewIdx );
+              m_iUseDDDCandIdx = iCount;
+
+              if( tmpDir == 1 )
+              {
+                  pcMvFieldNeighbours[ iCount << 1 ] = tmpMV[ 0 ];
+              }
+              else if( tmpDir == 2  )
+              {
+                  pcMvFieldNeighbours[( iCount << 1 ) + 1 ] = tmpMV[ 1 ];
+              }
+
+              abCandIsInter        [ iCount ] = true;
+              puhInterDirNeighbours[ iCount ] = tmpDir;
+
+              if ( mrgCandIdx == iCount )
+              {
+                  return;
+              }
+              iCount ++;
+
+              Int iLeftAboveAvail = 0;
+              if( iPosLeftAbove[ 0 ] != -1 )
+              {
+                  iPosLeftAbove[ 0 ] = iCount;
+                  iLeftAboveAvail = 1;
+              }
+              if( iPosLeftAbove[ 1 ] != -1 )
+              {
+                  iPosLeftAbove[ 1 ] = iCount + iLeftAboveAvail;
+              }
+
+          }
+      }      
+
+  }
+#endif
   /////////////////////////////////////////////////////////////////
   //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC  Candidates /////
@@ -4398,4 +4595,10 @@
       for(; iCnloop >= 0; iCnloop --)
       {
+#if MTK_DDD_G0063
+          if( iCnloop == m_iUseDDDCandIdx )
+          {
+              continue;
+          }
+#endif
         if(ivCandDir[0] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==tmpMV[0] && pcMvFieldNeighbours[(iCnloop<<1)+1]==tmpMV[1])  // F0125 compatible with F0093
         {
@@ -4595,4 +4798,11 @@
 #endif
 
+#if MTK_DDD_G0063
+  // early termination
+  if ( iCount >= getSlice()->getMaxNumMergeCand()) 
+  {
+      return;
+  }
+#endif
 
 #if H_3D_IV_MERGE 
Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.h	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.h	(revision 795)
@@ -250,4 +250,11 @@
 #endif
 
+#if MTK_DDD_G0063
+  UChar*        m_pucDisparityDerivedDepth;
+  Bool*         m_pbUseDDD;
+  Int           m_iUseDDDCandIdx;
+  UChar         m_ucDDTmpDepth;
+#endif
+
 protected:
   
@@ -755,4 +762,21 @@
   UInt          getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra);
 
+#if MTK_DDD_G0063
+  UChar*       getDDDepth        ()                        { return m_pucDisparityDerivedDepth;        }
+  UChar        getDDDepth        ( UInt uiIdx )            { return m_pucDisparityDerivedDepth[uiIdx]; }
+  Void         setDDDepth        ( UInt uiIdx, UChar n )   { m_pucDisparityDerivedDepth[uiIdx] = n;    }
+  Void         setDDDepthSubParts( UChar ucDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+
+  Bool*        getUseDDD        ()                        { return m_pbUseDDD;        }
+  Bool         getUseDDD        ( UInt uiIdx )            { return m_pbUseDDD[uiIdx]; }
+  Void         setUseDDD        ( UInt uiIdx, Bool n )     { m_pbUseDDD[uiIdx] = n;    }
+  Void         setUseDDD( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiDepth );
+
+  Void         setUseDDD        ( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+
+  UChar        getDDTmpDepth(){ return m_ucDDTmpDepth; }
+  Int          getUseDDDCandIdx(){ return m_iUseDDDCandIdx;}
+
+#endif
 };
 
Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComPrediction.cpp	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComPrediction.cpp	(revision 795)
@@ -783,4 +783,41 @@
   TComMv      cMv         = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
   pcCU->clipMv(cMv);
+
+#if MTK_DDD_G0063
+  if( pcCU->getUseDDD( uiPartAddr ) )
+  {
+      assert( pcCU->getSPIVMPFlag( uiPartAddr ) == 0 );
+      assert( pcCU->getSlice()->getViewIndex() != 0 );
+
+      Int dstStride = rpcYuvPred->getStride();
+      Int dstStrideC = rpcYuvPred->getCStride();
+      Pel *dst      = rpcYuvPred->getLumaAddr( uiPartAddr );
+      Pel *dstU     = rpcYuvPred->getCbAddr( uiPartAddr );
+      Pel *dstV     = rpcYuvPred->getCrAddr( uiPartAddr );
+
+      Int iWidthC  = iWidth >> 1;
+      Int iHeightC = iHeight >> 1;
+      Int DefaultC = 1 << ( g_bitDepthY - 1);
+      for ( Int i = 0; i < iHeight; i++)
+      {
+          for ( Int j = 0; j < iWidth ; j++)
+          {
+              dst[j] = pcCU->getDDDepth( uiPartAddr );
+          }
+          dst += dstStride;
+      }
+      for ( Int i = 0; i < iHeightC; i++)
+      {
+          for ( Int j = 0; j < iWidthC; j++)
+          {
+              dstU[j] = dstV[j] = DefaultC;
+          }
+          dstU += dstStrideC;
+          dstV += dstStrideC;
+      }
+
+      //return;
+  } else
+#endif
 #if H_3D_ARP
   if(pcCU->getARPW( uiPartAddr ) > 0  && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC())
Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComSlice.cpp	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComSlice.cpp	(revision 795)
@@ -3272,4 +3272,14 @@
 #endif
 
+#if MTK_DDD_G0063
+  if( getIsDepth() && getViewIndex() > 0 )
+  {
+      TComSlice *pcTextSlice = getTexturePic()->getSlice( 0 );
+      memcpy( m_aiDDDInvScale, pcTextSlice->m_aiDDDInvScale, sizeof( Int ) * getViewIndex() );
+      memcpy( m_aiDDDInvOffset, pcTextSlice->m_aiDDDInvOffset, sizeof( Int ) * getViewIndex() );
+      memcpy( m_aiDDDShift, pcTextSlice->m_aiDDDShift, sizeof( Int ) * getViewIndex() );             
+  }  
+#endif 
+
   if( !setupLUT )
     return; 
@@ -3319,8 +3329,74 @@
       m_depthToDisparityF[ i ][ d ] = ( invCodScale[ i ] * d + invOffset ) >> log2Div; 
     }
-  }
-}
-#endif
-#endif
+
+#if MTK_DDD_G0063
+    InitializeDDDPara( vps->getCamParPrecision(), codScale[ i ], codOffset[ i ], i );
+#endif
+  }
+}
+#endif
+#endif
+
+#if MTK_DDD_G0063
+Void TComSlice::InitializeDDDPara( UInt uiCamParsCodedPrecision, Int  iCodedScale,Int  iCodedOffset, Int iBaseViewIdx )
+{
+    UInt uiViewId     = getViewIndex();
+
+    if( uiViewId == 0 )
+    {
+        m_aiDDDInvScale[ iBaseViewIdx ] = m_aiDDDInvOffset[ iBaseViewIdx ] = m_aiDDDShift[ iBaseViewIdx ] = 0;
+        return;
+    }
+
+
+    Int iSign = iCodedScale >= 0 ? 1 : -1;
+    iCodedScale = abs( iCodedScale );
+
+    Int iBitWidth = 0;
+
+    const Int iInvPres = 9;
+
+    while( ((( 1 << iBitWidth ) << 1 ) <= iCodedScale ) )
+    {
+        iBitWidth ++;
+    }
+    iBitWidth += iInvPres;
+    Int iTargetValue =  1 << iBitWidth;
+
+    Int iMinError = MAX_INT;
+    Int iBestD = 1 << ( iInvPres - 1 );
+    for( Int d = 1 << ( iInvPres - 1 ); d < ( 1 << iInvPres ); d++ )
+    {
+        Int iError = abs( iCodedScale * d - iTargetValue );
+        if( iError < iMinError )
+        {
+            iMinError = iError;
+            iBestD = d;
+        }
+        if( iMinError == 0 )
+        {
+            break;
+        }
+    }
+    Int iRoundingDir = 0;
+    if( iCodedScale * iBestD > iTargetValue )
+    {
+        iRoundingDir = -1;
+    }
+    else if( iCodedScale * iBestD < iTargetValue )
+    {
+        iRoundingDir = 1;
+    }
+    Int iCamPres = uiCamParsCodedPrecision - 1;
+    m_aiDDDInvScale [ iBaseViewIdx ] = ( iBestD << ( iCamPres + g_bitDepthY )) * iSign;
+    m_aiDDDInvOffset[ iBaseViewIdx ] = -iSign * iBestD * ( iCodedOffset << g_bitDepthY );
+    m_aiDDDShift    [ iBaseViewIdx ] = iBitWidth;
+    m_aiDDDInvOffset[ iBaseViewIdx ] += 1 << ( m_aiDDDShift[ iBaseViewIdx ] - 1 );
+    m_aiDDDInvOffset[ iBaseViewIdx ] += ( 1 << ( m_aiDDDShift[ iBaseViewIdx ] - 4 ) ) * iRoundingDir;
+
+    return;
+}
+#endif
+
 /** get scaling matrix from RefMatrixID
  * \param sizeId size index
Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComSlice.h	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TComSlice.h	(revision 795)
@@ -2062,4 +2062,11 @@
 #endif
 #endif
+
+#if MTK_DDD_G0063
+  Int          m_aiDDDInvScale [MAX_NUM_LAYERS];
+  Int          m_aiDDDInvOffset[MAX_NUM_LAYERS];
+  UInt         m_aiDDDShift    [MAX_NUM_LAYERS];
+#endif
+
 public:
   TComSlice();
@@ -2408,4 +2415,13 @@
   TComPic* getPicFromRefPicSetInterLayer( Int setIdc, Int layerId );
 #endif
+
+#if MTK_DDD_G0063
+  Void InitializeDDDPara( UInt uiCamParsCodedPrecision, Int  iCodedScale,Int  iCodedOffset, Int iBaseViewIdx );
+  Int  getDepthFromDV( Int iDV, Int iBaseViewIdx )
+  {
+      return ClipY(( iDV * m_aiDDDInvScale[ iBaseViewIdx ] + m_aiDDDInvOffset[ iBaseViewIdx ] ) >> m_aiDDDShift[ iBaseViewIdx ]);
+  }
+#endif
+
 protected:
   TComPic*  xGetRefPic  (TComList<TComPic*>& rcListPic,
Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TypeDef.h	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibCommon/TypeDef.h	(revision 795)
@@ -258,4 +258,6 @@
 #define MTK_RBIP_VSP_G0069                1   // Restricted bi-prediction for VSP
 #endif
+
+#define MTK_DDD_G0063                     1   // Disparity derived depth coding
 
 ///// ***** ILLUMATION COMPENSATION *********
Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibDecoder/TDecCu.cpp	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibDecoder/TDecCu.cpp	(revision 795)
@@ -213,4 +213,5 @@
   DTRACE_CU("cqtDepth"  , uiDepth)
 #endif
+
   TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
   Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
@@ -274,4 +275,9 @@
 #if H_MV_ENC_DEC_TRAC
   DTRACE_CU_S("=========== coding_unit ===========\n")
+#endif
+
+
+#if MTK_DDD_G0063
+      pcCU->setUseDDD( false, uiAbsPartIdx, uiDepth );
 #endif
 
@@ -437,4 +443,13 @@
 #endif
     pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
+
+#if MTK_DDD_G0063
+    if( uiMergeIndex == m_ppcCU[uiDepth]->getUseDDDCandIdx() )
+    {
+        assert( pcCU->getSlice()->getViewIndex() != 0 );
+        pcCU->setUseDDD( true, uiAbsPartIdx, 0, uiDepth );
+        pcCU->setDDDepthSubParts( m_ppcCU[uiDepth]->getDDTmpDepth(),uiAbsPartIdx, 0, uiDepth );
+    }
+#endif
 
     TComMv cTmpMv( 0, 0 );
Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 795)
@@ -320,4 +320,17 @@
       pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
 
+#if MTK_DDD_G0063
+      if( uiMergeIndex == pcSubCU->getUseDDDCandIdx() )
+      {
+          assert( pcCU->getSlice()->getViewIndex() != 0 );
+          pcCU->setUseDDD( true, uiSubPartIdx, uiPartIdx, uiDepth );
+          pcCU->setDDDepthSubParts( pcSubCU->getDDTmpDepth(),uiSubPartIdx, uiPartIdx, uiDepth );
+      }
+      else
+      {
+          pcCU->setUseDDD( false, uiSubPartIdx, uiPartIdx, uiDepth );
+      }
+#endif
+
       TComMv cTmpMv( 0, 0 );
       for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibDecoder/TDecTop.h	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibDecoder/TDecTop.h	(revision 795)
@@ -82,4 +82,10 @@
 #endif
 
+#if MTK_DDD_G0063
+  Int getCodedScale( Int iBaseView, Int iCureView){ return m_aaiCodedScale[ iBaseView ][ iCureView ];}
+  Int getCodedOffset( Int iBaseView, Int iCureView){ return m_aaiCodedOffset[ iBaseView ][ iCureView ];}
+  UInt getCamParsCodedPrecision(){ return m_uiCamParsCodedPrecision; }
+#endif
+
 private:
   Bool  xIsComplete ();
Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibEncoder/TEncCu.cpp	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibEncoder/TEncCu.cpp	(revision 795)
@@ -1881,4 +1881,11 @@
 
 #endif
+
+#if MTK_DDD_G0063
+    Int iDDDCand = rpcTempCU->getUseDDDCandIdx(); 
+    UChar ucDDDepth = rpcTempCU->getDDTmpDepth();
+    rpcTempCU->setUseDDD( false, 0, uhDepth );
+#endif
+
   for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual )
   {
@@ -1914,4 +1921,17 @@
           rpcTempCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeCand].m_acDvInfo, 0, 0, uhDepth );
 #endif
+
+#if MTK_DDD_G0063
+          if( rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getViewIndex() != 0 && iDDDCand == uiMergeCand )
+          {
+              rpcTempCU->setUseDDD( true, 0, 0, uhDepth );
+              rpcTempCU->setDDDepthSubParts( ucDDDepth, 0, 0, uhDepth );
+          }
+          else
+          {
+              rpcTempCU->setUseDDD( false, 0, 0, uhDepth );
+          }
+#endif
+
 #if H_3D_SPIVMP
           rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth);
@@ -2122,4 +2142,8 @@
   rpcTempCU->setCUTransquantBypassSubParts  ( m_pcEncCfg->getCUTransquantBypassFlagValue(),      0, uhDepth );
   
+#if MTK_DDD_G0063
+  rpcTempCU->setUseDDD( false, 0, uhDepth );
+#endif
+
 #if H_3D_ARP
   rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 795)
@@ -3675,4 +3675,16 @@
 #endif
 
+#if MTK_DDD_G0063
+      if( uiMergeCand == pcCU->getUseDDDCandIdx() )
+      {
+          pcCU->setUseDDD( true, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
+          pcCU->setDDDepthSubParts( pcCU->getDDTmpDepth(), uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
+      }
+      else
+      {
+          pcCU->setUseDDD( false, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
+      }
+#endif
+
       xGetInterPredictionError( pcCU, pcYuvOrg, iPUIdx, uiCostCand, m_pcEncCfg->getUseHADME() );
       uiBitsCand = uiMergeCand + 1;
@@ -4372,4 +4384,19 @@
         pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMRGIndex].m_acDvInfo, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
 #endif
+
+#if MTK_DDD_G0063
+        if( uiMRGIndex == pcCU->getUseDDDCandIdx() )
+        {
+            assert( vspFlag[uiMRGIndex]     == 0 );
+            assert( bSPIVMPFlag[uiMRGIndex] == 0 );
+            pcCU->setUseDDD( true, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+            pcCU->setDDDepthSubParts( pcCU->getDDTmpDepth(), uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+        }
+        else
+        {
+            pcCU->setUseDDD( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+        }
+#endif
+
 #if H_3D_SPIVMP
         pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );  
@@ -4422,4 +4449,8 @@
 #if H_3D_SPIVMP        
         pcCU->setSPIVMPFlagSubParts(0, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 
+#endif
+
+#if MTK_DDD_G0063
+        pcCU->setUseDDD( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
 #endif
         // set ME result
Index: branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibEncoder/TEncSlice.h
===================================================================
--- branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibEncoder/TEncSlice.h	(revision 793)
+++ branches/HTM-9.3-dev1-MediaTek/source/Lib/TLibEncoder/TEncSlice.h	(revision 795)
@@ -107,4 +107,10 @@
   UInt                    m_uiSliceIdx;
   std::vector<TEncSbac*> CTXMem;
+
+#if MTK_DDD_G0063
+  Int          m_iDDDScale;
+  Int          m_iDDDOffset;
+  UInt         m_uiDDDPrecision;
+#endif
 public:
   TEncSlice();
@@ -147,4 +153,8 @@
   Void      setCtxMem( TEncSbac* sb, Int b )   { CTXMem[b] = sb; }
 
+#if MTK_DDD_G0063
+  Void setDDDPar( Int iScale, Int iOffset, UInt uiPrecision ){ m_iDDDScale = iScale; m_iDDDOffset = iOffset; m_uiDDDPrecision = uiPrecision; }
+#endif
+
 private:
   Double  xGetQPValueAccordingToLambda ( Double lambda );
