Index: branches/HTM-8.2-dev0/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- branches/HTM-8.2-dev0/source/Lib/TLibCommon/ContextTables.h	(revision 709)
+++ branches/HTM-8.2-dev0/source/Lib/TLibCommon/ContextTables.h	(revision 710)
@@ -371,7 +371,13 @@
 INIT_ARPW[3][NUM_ARPW_CTX] = 
 {
+#if LGE_ARP_CTX_F0161
+    { 162, 153, 154, 162 },
+    { 162, 153, 154, 162 },
+    { 162, 153, 154, 162 },
+#else
   { 154, 154, 154, 154 }, 
   { 154, 154, 154, 154 }, 
   { 154, 154, 154, 154 }, 
+#endif
 };
 #endif
Index: branches/HTM-8.2-dev0/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-8.2-dev0/source/Lib/TLibCommon/TComPrediction.cpp	(revision 709)
+++ branches/HTM-8.2-dev0/source/Lib/TLibCommon/TComPrediction.cpp	(revision 710)
@@ -664,4 +664,11 @@
   pcCU->clipMv(cMv);
 #if H_3D_ARP
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+  if(pcCU->getARPW( uiPartAddr ) > 0  && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC())
+  {
+      xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , bi );
+  }
+  else
+#endif
   if(  pcCU->getARPW( uiPartAddr ) > 0 
     && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N 
@@ -744,8 +751,17 @@
   // fetch virtual depth map
   pcBaseViewDepthPicYuv->extendPicBorder();
+
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+  Int vspSize=0;
+  xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp,vspSize );
+  // sub-PU based compensation
+  xPredInterLumaBlkFromDM   ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi, vspSize);
+  xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi, vspSize);
+#else
   xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp );
   // sub-PU based compensation
   xPredInterLumaBlkFromDM   ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
   xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
+#endif
 }
 #endif
@@ -777,5 +793,10 @@
   if( cDistparity.bDV ) 
   {
+#if SHARP_ARP_REF_CHECK_F0105
+    Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList);
+    if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() )
+#else
     if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC()!= pcCU->getSlice()->getPOC() )
+#endif
     {
       bTobeScaled = true;
@@ -783,7 +804,14 @@
 
     pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
+
+#if SHARP_ARP_REF_CHECK_F0105
+    pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan );
+
+    if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
+#else
     pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC(), cDistparity.m_aVIdxCan );
     
     if( ( !pcPicYuvBaseCol || pcPicYuvBaseCol->getPOC() != pcCU->getSlice()->getPOC() ) || ( !pcPicYuvBaseRef || pcPicYuvBaseRef->getPOC() != pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ) )
+#endif
     {
       dW = 0;
@@ -792,5 +820,9 @@
     else
     {
+#if SHARP_ARP_REF_CHECK_F0105
+      assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC() );
+#else
       assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() );
+#endif
     }
 
@@ -841,4 +873,111 @@
   }
 }
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
+{
+  Int         iRefIdx       = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
+  TComMv      cDMv          = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
+  TComMv      cTempDMv      = cDMv;
+  UChar       dW            = pcCU->getARPW ( uiPartAddr );
+
+  TComPic* pcPicYuvBaseTRef = NULL;
+  TComPic* pcPicYuvCurrTRef = NULL;
+  TComPic* pcPicYuvBaseCol  = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx );  
+  TComPicYuv* pcYuvBaseCol  = pcPicYuvBaseCol->getPicYuvRec();   
+  Bool bTMVAvai = false;     
+  TComMv cBaseTMV;
+  if( pNewMvFiled )
+  {
+    iRefIdx = pNewMvFiled->getRefIdx(); 
+    cDMv = pNewMvFiled->getMv();
+  }
+  pcCU->clipMv(cTempDMv);
+
+  assert(dW > 0);
+#if SHARP_ARP_REF_CHECK_F0105
+  if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, pcPicYuvBaseCol->getViewIndex()))
+  {
+    dW = 0;
+  }
+#endif
+  Int uiLCUAddr,uiAbsPartAddr;
+  Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
+  Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
+
+  irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
+  irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY);  
+  pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
+  TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
+
+  if(!pColCU->isIntra(uiAbsPartAddr))
+  {
+    TComMvField puMVField;
+    for(Int iList = 0; iList < (pColCU->getSlice()->isInterB() ? 2: 1) && !bTMVAvai; iList ++)
+    {
+      RefPicList eRefPicListCurr = RefPicList(iList);
+      Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr);
+      if( iRef != -1)
+      {
+        pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef);  
+        Int  iCurrPOC    = pColCU->getSlice()->getPOC();
+        Int  iCurrRefPOC = pcPicYuvBaseTRef->getPOC();
+        Int  iCurrRef    = pcCU->getSlice()->getFirstTRefIdx(eRefPicListCurr);
+        if( iCurrRef >= 0)
+        {
+          pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic(eRefPicListCurr,iCurrRef);  
+          Int iTargetPOC = pcPicYuvCurrTRef->getPOC();
+          {
+            pcPicYuvBaseTRef =  pcCU->getSlice()->getBaseViewRefPic(iTargetPOC,  pcPicYuvBaseCol->getViewIndex() );  
+            if(pcPicYuvBaseTRef)
+            {
+              cBaseTMV = pColCU->getCUMvField(eRefPicListCurr)->getMv(uiAbsPartAddr);
+              Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC);
+              if ( iScale != 4096 )
+                cBaseTMV = cBaseTMV.scaleMv( iScale );                  
+              bTMVAvai = true;
+              break;
+            }
+          }
+        }
+      }
+    }
+  }
+  if (bTMVAvai == false)
+  { 
+    bTMVAvai = true;
+    cBaseTMV.set(0, 0);
+    pcPicYuvBaseTRef =  pColCU->getSlice()->getRefPic(eRefPicList,  pcCU->getSlice()->getFirstTRefIdx(eRefPicList));  
+    pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic  (eRefPicList,  pcCU->getSlice()->getFirstTRefIdx(eRefPicList));      
+  }
+
+  xPredInterLumaBlk  ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi,        bTMVAvai);
+  xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi,        bTMVAvai);
+
+  if( dW > 0 && bTMVAvai ) 
+  {
+    TComYuv*    pYuvCurrTRef    = &m_acYuvPredBase[0];
+    TComYuv*    pYuvBaseTRef    = &m_acYuvPredBase[1];
+    TComPicYuv* pcYuvCurrTref   = pcPicYuvCurrTRef->getPicYuvRec();        
+    TComPicYuv* pcYuvBaseTref   = pcPicYuvBaseTRef->getPicYuvRec();  
+    TComMv      cTempMv         = cDMv + cBaseTMV;
+
+    pcCU->clipMv(cBaseTMV);
+    pcCU->clipMv(cTempMv);
+
+    xPredInterLumaBlk  ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, bi,   true);
+    xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, bi,   true);
+    xPredInterLumaBlk  ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, bi,   true); 
+    xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, bi,   true); 
+
+    pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight );  
+    if(dW == 2)
+    {
+      pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
+    }
+    rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi ); 
+  }
+}
+#endif
+
 #endif
 
@@ -1499,5 +1638,9 @@
 #if H_3D_VSP
 // not fully support iRatioTxtPerDepth* != 1
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int &vspSize, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY )
+#else
 Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY )
+#endif
 {
   Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE;
@@ -1527,4 +1670,5 @@
   Pel *depth = yuvDepth->getLumaAddr();
 
+#if !SHARP_VSP_BLOCK_IN_AMP_F0102
   if( width<8 || height<8 )
   { // no split
@@ -1546,4 +1690,10 @@
       depth += depStrideBlock;
     }
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+  if(width==4)
+    vspSize=0;
+  else
+    vspSize=1;
+#endif
   }
   else
@@ -1558,5 +1708,16 @@
     Pel repDepth4x8[2] = {0, 0};
     Pel repDepth8x4[2] = {0, 0};
-
+#endif
+
+#if !MTK_F0109_LG_F0120_VSP_BLOCK
+#if SHARP_VSP_BLOCK_IN_AMP_F0102
+    Int blocksize    = 8;
+    Int subblocksize = 4;
+    Int depStrideBlock = depStride * blocksize;
+    Pel *depthTmp = NULL;
+    Int depStrideTmp = depStride * nTxtPerDepthY;
+    Int offset[4] = { 0, subblocksize-1, subblocksize, blocksize-1 };
+    Pel *refDepthTmp[4] = { NULL, NULL, NULL, NULL };
+#endif
     Int refDepStrideBlock    = refDepStride * blocksize;
     Int refDepStrideSubBlock = refDepStride * subblocksize;
@@ -1567,4 +1728,76 @@
     refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock;
 
+#if SHARP_VSP_BLOCK_IN_AMP_F0102
+    Int subBlockW, subBlockH;
+    Int blockW, blockH;
+    subBlockW = subBlockH = 8;
+    if (height % 8)
+    {
+      subBlockW = 8;
+      subBlockH = 4;
+      blockW = width;  // no further split
+      blockH = height; // no further split
+    }
+    else if (width % 8)
+    {
+      subBlockW = 4;
+      subBlockH = 8;
+      blockW = width;  // no further split
+      blockH = height; // no further split
+    }
+    else
+    {
+      blockW = blockH = 8;
+    }
+    for( Int y=0; y<height; y+=blockH )
+    {
+      for( Int x=0; x<width; x+=blockW )
+      {
+        if (blockW == 8 && blockH == 8)
+        {
+          Bool ULvsBR = false, URvsBL = false;
+          ULvsBR = refDepthTmp[0][x+offset[0]] < refDepthTmp[3][x+offset[3]];
+          URvsBL = refDepthTmp[0][x+offset[3]] < refDepthTmp[3][x+offset[0]];
+          if( ULvsBR ^ URvsBL )
+          { // 4x8
+            subBlockW = 4;
+            subBlockH = 8;
+          }
+          else
+          {
+            subBlockW = 8;
+            subBlockH = 4;
+          }
+        }
+        for( Int yy=0; yy<blockH; yy+=subBlockH )
+        {
+          for( Int xx=0; xx<blockW; xx+=subBlockW )
+          {
+            Pel  maxDepthVal = 0;
+            Int xP0, xP1, yP0, yP1;
+            xP0 = x+xx;
+            xP1 = x+xx+subBlockW-1;
+            yP0 = yy;
+            yP1 = yy+subBlockH-1;
+            maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP0+yP0*refDepStride]);
+            maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP1+yP0*refDepStride]);
+            maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP0+yP1*refDepStride]);
+            maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP1+yP1*refDepStride]);
+            depthTmp = &depth[x+xx+yy*depStride];
+            for( Int sY=0; sY<subBlockH; sY+=nTxtPerDepthY )
+            {
+              for( Int sX=0; sX<subBlockW; sX+=nTxtPerDepthX )
+              {
+                depthTmp[sX] = maxDepthVal;
+              }
+              depthTmp += depStrideTmp;
+            }
+          }
+        }
+      }
+      refDepthTmp[0] += refDepStrideBlock;
+      depth       += depStrideBlock;
+    }
+#else // SHARP_VSP_BLOCK_IN_AMP_F0102
     for( Int y=0; y<height; y+=blocksize )
     {
@@ -1662,14 +1895,203 @@
       depth       += depStrideBlock;
     }
-  }
-
-
-}
-
+#endif // SHARP_VSP_BLOCK_IN_AMP_F0102
+#else
+#if SHARP_VSP_BLOCK_IN_AMP_F0102
+  if ((height % 8))
+  {
+    vspSize = 1; // 8x4
+  }
+  else if ((width % 8))
+  {
+    vspSize = 0; // 4x8
+  }
+  else
+  {
+    Bool ULvsBR, URvsBL;
+    ULvsBR = refDepth[0]       < refDepth[refDepStride * (height-1) + width-1];
+    URvsBL = refDepth[width-1] < refDepth[refDepStride * (height-1)];
+    vspSize = ( ULvsBR ^ URvsBL ) ? 0 : 1;
+  }
+  Int subBlockW, subBlockH;
+  Int depStrideTmp = depStride * nTxtPerDepthY;
+  if (vspSize)
+  {
+    subBlockW = 8;
+    subBlockH = 4;
+  }
+  else
+  {
+    subBlockW = 4;
+    subBlockH = 8;
+  }
+  for( Int y=0; y<height; y+=subBlockH )
+  {
+    Pel *refDepthTmp[4];
+    refDepthTmp[0] = refDepth + refDepStride * y;
+    refDepthTmp[1] = refDepthTmp[0] + subBlockW - 1;
+    refDepthTmp[2] = refDepthTmp[0] + refDepStride * (subBlockH - 1);
+    refDepthTmp[3] = refDepthTmp[2] + subBlockW - 1;
+    for( Int x=0; x<width; x+=subBlockW )
+    {
+      Pel  maxDepthVal;
+      maxDepthVal = refDepthTmp[0][x];
+      maxDepthVal = std::max( maxDepthVal, refDepthTmp[1][x]);
+      maxDepthVal = std::max( maxDepthVal, refDepthTmp[2][x]);
+      maxDepthVal = std::max( maxDepthVal, refDepthTmp[3][x]);
+      Pel *depthTmp = &depth[x+y*depStride];
+      for( Int sY=0; sY<subBlockH; sY+=nTxtPerDepthY )
+      {
+        for( Int sX=0; sX<subBlockW; sX+=nTxtPerDepthX )
+        {
+          depthTmp[sX] = maxDepthVal;
+        }
+        depthTmp += depStrideTmp;
+      }
+    }
+  }
+#else // SHARP_VSP_BLOCK_IN_AMP_F0102
+    Int refDepStrideBlock    = refDepStride * height;
+    Int refDepStrideSubBlock = refDepStride * height/2;
+    refDepthTmp[0] = refDepth;
+    refDepthTmp[2] = refDepthTmp[0] + refDepStrideSubBlock;
+    refDepthTmp[1] = refDepthTmp[2] - refDepStride;
+    refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock;
+    offset[3] = width-1;
+    Bool ULvsBR = false, URvsBL = false;
+    ULvsBR = refDepthTmp[0][0+offset[0]] < refDepthTmp[3][0+offset[3]];
+    URvsBL = refDepthTmp[0][0+offset[3]] < refDepthTmp[3][0+offset[0]];
+    refDepStrideBlock    = refDepStride * blocksize;
+    refDepStrideSubBlock = refDepStride * subblocksize;
+    refDepthTmp[0] = refDepth;
+    refDepthTmp[2] = refDepthTmp[0] + refDepStrideSubBlock;
+    refDepthTmp[1] = refDepthTmp[2] - refDepStride;
+    refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock;
+    offset[3] = blocksize-1;
+    if( ULvsBR ^ URvsBL )
+    {
+    vspSize = 0;//4x8
+    for( Int y=0; y<height; y+=blocksize )
+    {
+      for( Int x=0; x<width; x+=blocksize )
+      {
+        { // 4x8
+          repDepth4x8[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[1]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[1]];
+          if( repDepth4x8[0] < refDepthTmp[3][x+offset[0]] )
+          {
+            repDepth4x8[0] = refDepthTmp[3][x+offset[0]];
+          }
+          if( repDepth4x8[0] < refDepthTmp[3][x+offset[1]] )
+          {
+            repDepth4x8[0] = refDepthTmp[3][x+offset[1]];
+          }
+          repDepth4x8[1] = refDepthTmp[0][x+offset[2]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[2]] : refDepthTmp[0][x+offset[3]];
+          if( repDepth4x8[1] < refDepthTmp[3][x+offset[2]] )
+          {
+            repDepth4x8[1] = refDepthTmp[3][x+offset[2]];
+          }
+          if( repDepth4x8[1] < refDepthTmp[3][x+offset[3]] )
+          {
+            repDepth4x8[1] = refDepthTmp[3][x+offset[3]];
+  }
+
+          depthTmp = &depth[x];
+          for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY )
+          {
+            for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX )
+            {
+              depthTmp[sX] = repDepth4x8[0];
+            }
+            depthTmp += depStrideTmp;
+          }
+          depthTmp = &depth[x+subblocksize];
+          for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY )
+          {
+            for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX )
+            {
+              depthTmp[sX] = repDepth4x8[1];
+            }
+            depthTmp += depStrideTmp;
+          }
+        }
+      }
+      refDepthTmp[0] += refDepStrideBlock;
+      refDepthTmp[1] += refDepStrideBlock;
+      refDepthTmp[2] += refDepStrideBlock;
+      refDepthTmp[3] += refDepStrideBlock;
+      depth       += depStrideBlock;
+    }
+  }
+  else
+  { // 8x4
+    vspSize = 1;
+    for( Int y=0; y<height; y+=blocksize )
+    {
+      for( Int x=0; x<width; x+=blocksize )
+      {
+        repDepth8x4[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[3]];
+        if( repDepth8x4[0] < refDepthTmp[1][x+offset[0]] )
+        {
+          repDepth8x4[0] = refDepthTmp[1][x+offset[0]];
+        }
+        if( repDepth8x4[0] < refDepthTmp[1][x+offset[3]] )
+        {
+          repDepth8x4[0] = refDepthTmp[1][x+offset[3]];
+        }
+        repDepth8x4[1] = refDepthTmp[2][x+offset[0]] > refDepthTmp[2][x+offset[3]] ? refDepthTmp[2][x+offset[0]] : refDepthTmp[2][x+offset[3]];
+        if( repDepth8x4[1] < refDepthTmp[3][x+offset[0]] )
+        {
+          repDepth8x4[1] = refDepthTmp[3][x+offset[0]];
+        }
+        if( repDepth8x4[1] < refDepthTmp[3][x+offset[3]] )
+        {
+          repDepth8x4[1] = refDepthTmp[3][x+offset[3]];
+        }
+
+        depthTmp = &depth[x];
+        for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY )
+        {
+          for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX )
+          {
+            depthTmp[sX] = repDepth8x4[0];
+          }
+          depthTmp += depStrideTmp;
+        }
+        for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY )
+        {
+          for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX )
+          {
+            depthTmp[sX] = repDepth8x4[1];
+          }
+          depthTmp += depStrideTmp;
+}
+      }
+      refDepthTmp[0] += refDepStrideBlock;
+      refDepthTmp[1] += refDepStrideBlock;
+      refDepthTmp[2] += refDepStrideBlock;
+      refDepthTmp[3] += refDepStrideBlock;
+      depth       += depStrideBlock;
+    }
+  }
+#endif    
+#endif
+#if !SHARP_VSP_BLOCK_IN_AMP_F0102
+  }
+#endif
+
+
+}
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+Void TComPrediction::xPredInterLumaBlkFromDM( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi, Int vspSize)
+#else
 Void TComPrediction::xPredInterLumaBlkFromDM( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi )
+#endif
 {
   Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE;
   Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE;
   
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+  nTxtPerDepthX = nTxtPerDepthX << vspSize;
+  nTxtPerDepthY = nTxtPerDepthY << (1-vspSize);
+#endif
   Int refStride = picRef->getStride();
   Int dstStride = yuvDst->getStride();
@@ -1777,5 +2199,9 @@
 }
 
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+Void TComPrediction::xPredInterChromaBlkFromDM  ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi, Int vspSize)
+#else
 Void TComPrediction::xPredInterChromaBlkFromDM  ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi )
+#endif
 {
 #if (H_3D_VSP_BLOCKSIZE==1)
@@ -1787,4 +2213,8 @@
 #endif
 
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+  nTxtPerDepthX = nTxtPerDepthX << vspSize;
+  nTxtPerDepthY = nTxtPerDepthY << (1-vspSize);
+#endif
   Int refStride = picRef->getCStride();
   Int dstStride = yuvDst->getCStride();
Index: branches/HTM-8.2-dev0/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-8.2-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 709)
+++ branches/HTM-8.2-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 710)
@@ -751,5 +751,17 @@
     if ( this->getNumRefIdx( RefPicList( uiRefListIdx ) ) == 0)
         continue;
-
+#if !SHARP_ARP_REF_CHECK_F0105
+// move the following to setARPStepNum() to define ARP related thing in ARP function.
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+     for(Int i = 0; i < this->getNumRefIdx(RefPicList(uiRefListIdx)); i++ )
+       {
+       if ( this->getRefPic(RefPicList(uiRefListIdx), i)->getPOC() != getPOC() )
+       {
+         this->setFirstTRefIdx (RefPicList(uiRefListIdx), i);
+         break;
+       }
+     }
+#endif
+#endif
     Bool bZeroIdxLtFlag = this->getRefPic(RefPicList(uiRefListIdx), 0)->getIsLongTerm();
     for(Int i = 1; i < this->getNumRefIdx(RefPicList(uiRefListIdx)); i++ )
@@ -2834,9 +2846,20 @@
 
 #if H_3D_ARP
+#if SHARP_ARP_REF_CHECK_F0105
+Void TComSlice::setARPStepNum( TComPicLists*ivPicLists )
+#else
 Void TComSlice::setARPStepNum()                                  
-{
+#endif
+{
+#if SHARP_ARP_REF_CHECK_F0105
+  Bool tempRefPicInListsFlag = false;
+#else
   Bool bAllIvRef = true;
-
+#endif
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+  if(!getVPS()->getUseAdvRP(getLayerId()) || this->isIRAP())
+#else
   if(!getVPS()->getUseAdvRP(getLayerId()))
+#endif
   {
     m_nARPStepNum = 0;
@@ -2844,4 +2867,21 @@
   else
   {
+#if SHARP_ARP_REF_CHECK_F0105
+    setFirstTRefIdx (REF_PIC_LIST_0, -1);
+    setFirstTRefIdx (REF_PIC_LIST_1, -1);
+    for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ )
+    {
+      for(Int i = 0; i < getNumRefIdx(RefPicList(refListIdx)); i++ )
+      {
+        if ( getRefPic(RefPicList(refListIdx), i)->getPOC() != getPOC() )
+        {
+          setFirstTRefIdx (RefPicList(refListIdx), i);
+          break;
+        }
+      }
+    }
+    tempRefPicInListsFlag = getFirstTRefIdx(REF_PIC_LIST_0) >= 0 || getFirstTRefIdx(REF_PIC_LIST_1) >= 0;
+    m_nARPStepNum = tempRefPicInListsFlag ? getVPS()->getARPStepNum(getLayerId()) : 0;
+#else
     for( Int iRefListId = 0; iRefListId < 2; iRefListId++ )
     {
@@ -2866,5 +2906,30 @@
     }
     m_nARPStepNum = !bAllIvRef ? getVPS()->getARPStepNum(getLayerId()) : 0;
-  }
+#endif
+  }
+#if SHARP_ARP_REF_CHECK_F0105
+  if (tempRefPicInListsFlag)
+  {
+    for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ )
+    {
+      RefPicList eRefPicList = RefPicList( refListIdx );
+      Int prevPOC = getRefPic(eRefPicList, getFirstTRefIdx(eRefPicList) )->getPOC();
+      for( Int i = 0; i < getNumActiveRefLayerPics(); i++ )
+      {
+        Int layerIdInNuh = getRefPicLayerId( i );
+        Int viewIdx = getVPS()->getViewId( layerIdInNuh );
+        TComPic*pcPicPrev = ivPicLists->getPic(viewIdx, 0, prevPOC);
+        if (getFirstTRefIdx(eRefPicList) >= 0 && pcPicPrev && pcPicPrev->getSlice( 0 )->isReferenced())
+        {
+          m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = true;
+        }
+        else
+        {
+          m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = false;
+        }
+      }
+  }
+}
+#endif
 }
 #endif
Index: branches/HTM-8.2-dev0/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-8.2-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 709)
+++ branches/HTM-8.2-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 710)
@@ -1739,6 +1739,12 @@
 #endif
 #if H_3D_ARP
+#if SHARP_ARP_REF_CHECK_F0105
+  Bool m_arpRefPicAvailable[2][MAX_NUM_LAYERS];
+#endif
   TComList<TComPic*> * m_pBaseViewRefPicList[MAX_NUM_LAYERS];
   UInt                 m_nARPStepNum; 
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+  Int         m_aiFirstTRefIdx    [2]; 
+#endif
 #endif
 #if H_3D_IC
@@ -1827,5 +1833,9 @@
 #if H_3D_ARP
   Void      setBaseViewRefPicList( TComList<TComPic*> *pListPic, Int iViewIdx )      { m_pBaseViewRefPicList[iViewIdx] = pListPic;                   }
+#if SHARP_ARP_REF_CHECK_F0105
+  Void      setARPStepNum( TComPicLists*ivPicLists );
+#else
   Void      setARPStepNum();                                 
+#endif
   TComPic*  getBaseViewRefPic    ( UInt uiPOC , Int iViewIdx )                       { return xGetRefPic( *m_pBaseViewRefPicList[iViewIdx], uiPOC ); }
   UInt      getARPStepNum( )                                                         { return m_nARPStepNum;                                         }  
@@ -2028,4 +2038,11 @@
   Int       getAlterRefIdx          ( RefPicList e )        { return  m_aiAlterRefIdx[e];     }
 #endif
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+  Int       getFirstTRefIdx        ( RefPicList e )                { return  m_aiFirstTRefIdx[e];     }
+  Void      setFirstTRefIdx        ( RefPicList e, Int i )         { m_aiFirstTRefIdx[e]    = i;      }
+#endif
+#if SHARP_ARP_REF_CHECK_F0105
+  Bool      getArpRefPicAvailable( RefPicList e, Int viewIdx) {return m_arpRefPicAvailable[e][getVPS()->getLayerIdInNuh(viewIdx, 0)]; }
+#endif
   Void      setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
   Bool      getIsDepth            ()                 { return m_isDepth; }
Index: branches/HTM-8.2-dev0/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-8.2-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 709)
+++ branches/HTM-8.2-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 710)
@@ -212,4 +212,8 @@
 #if H_3D_ARP
 #define H_3D_ARP_WFNR                     3
+#define QC_MTK_INTERVIEW_ARP_F0123_F0108  1 //JCT3V-F0123; JCT3V-F0108
+#define QC_MTK_INTERVIEW_ARP_F0123_F0108  1 //JCT3V-F0123; JCT3V-F0108
+#define SHARP_ARP_REF_CHECK_F0105         1 // ARP reference picture selection and DPB check
+#define LGE_ARP_CTX_F0161 1 //JCT3V-F0161
 #endif
 
@@ -231,4 +235,6 @@
 ///// ***** VIEW SYNTHESIS PREDICTION *********
 #if H_3D_VSP
+#define MTK_F0109_LG_F0120_VSP_BLOCK      1   // MTK_LG_SIMPLIFY_VSP_BLOCK_PARTITION_F0109_F0120  
+#define SHARP_VSP_BLOCK_IN_AMP_F0102      1   // VSP partitioning for AMP
 #define H_3D_VSP_BLOCKSIZE                4   // Supported values: 1, 2, and 4
 #if H_3D_VSP_BLOCKSIZE == 1
Index: branches/HTM-8.2-dev0/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-8.2-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 709)
+++ branches/HTM-8.2-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 710)
@@ -966,5 +966,9 @@
     pcSlice->setRefPicList     ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true ); 
 #if H_3D_ARP
+#if SHARP_ARP_REF_CHECK_F0105
+    pcSlice->setARPStepNum(m_ivPicLists);
+#else
     pcSlice->setARPStepNum();
+#endif
     if( pcSlice->getARPStepNum() > 1 )
     {
Index: branches/HTM-8.2-dev0/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-8.2-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 709)
+++ branches/HTM-8.2-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 710)
@@ -1905,5 +1905,5 @@
           rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
           rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-#if H_3D_ARP
+#if H_3D_ARP && !QC_MTK_INTERVIEW_ARP_F0123_F0108
           if( nARPW )
           {
@@ -2115,4 +2115,5 @@
     m_pcPredSearch->motionCompensation( rpcTempCU , m_ppcPredYuvTemp[uhDepth] );
 
+#if !QC_MTK_INTERVIEW_ARP_F0123_F0108
     if(rpcTempCU->getPartitionSize(0)==SIZE_2Nx2N)
     {
@@ -2132,4 +2133,5 @@
       }
     }
+#endif
   }
   else
@@ -2152,4 +2154,5 @@
      m_ppcWeightedTempCU[uhDepth]->copyPartFrom( rpcTempCU , 0 , uhDepth );
 
+#if !QC_MTK_INTERVIEW_ARP_F0123_F0108
      Bool bSignalflag[2] = { true, true };
      for(UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx ++ )
@@ -2166,4 +2169,5 @@
        rpcTempCU->setARPWSubParts( 0 , 0 , uhDepth );
      }
+#endif
    }
   }
Index: branches/HTM-8.2-dev0/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-8.2-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 709)
+++ branches/HTM-8.2-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 710)
@@ -724,5 +724,9 @@
 #if H_3D_ARP
     //GT: This seems to be broken when layerId in vps is not equal to layerId in nuh
+#if SHARP_ARP_REF_CHECK_F0105
+    pcSlice->setARPStepNum(m_ivPicLists);
+#else
     pcSlice->setARPStepNum();
+#endif
     if(pcSlice->getARPStepNum() > 1)
     {
