Changeset 655 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPrediction.cpp


Ignore:
Timestamp:
23 Oct 2013, 23:01:30 (12 years ago)
Author:
tech
Message:

Merged 8.1-Cleanup@654

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibCommon/TComPrediction.cpp

    r622 r655  
    3939#include "TComPrediction.h"
    4040
    41 #if SHARP_ILLUCOMP_REFINE_E0046
    42 #define IC_REG_COST_SHIFT 7
    43 #define IC_CONST_SHIFT 5
    44 #define IC_SHIFT_DIFF 12
    45 #endif
    46 
    4741//! \ingroup TLibCommon
    4842//! \{
     
    6963  if (m_pDepthBlock != NULL)
    7064      free(m_pDepthBlock);
    71 #if NTT_VSP_COMMON_E0207_E0208
    7265  m_cYuvDepthOnVsp.destroy();
    73 #endif
    7466#endif
    7567
     
    129121    m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    130122#endif
    131 #if NTT_VSP_COMMON_E0207_E0208
     123#if H_3D_VSP
    132124    m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    133125#endif
     
    143135  }
    144136#if H_3D_IC
    145 #if SHARP_ILLUCOMP_REFINE_E0046
    146137  m_uiaShift[0] = 0;
    147138  for( Int i = 1; i < 64; i++ )
     
    149140    m_uiaShift[i] = ( (1 << 15) + i/2 ) / i;
    150141  }
    151 #else
    152   for( Int i = 1; i < 64; i++ )
    153   {
    154     m_uiaShift[i-1] = ( (1 << 15) + i/2 ) / i;
    155   }
    156 #endif
    157142#endif
    158143}
     
    456441        dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]);
    457442      } break;
    458 #if !SEC_DMM2_E0146_HHIFIX
    459     case( DMM2_IDX ):
    460       {
    461         UInt uiTabIdx = 0;
    462         if( bFastEnc ) { uiTabIdx = pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ); }
    463         else
    464         {
    465           uiTabIdx = xPredWedgeFromIntra( pcCU, uiAbsPartIdx, iWidth, iHeight, pcCU->getDmm2DeltaEnd( uiAbsPartIdx ) );
    466           pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, uiAbsPartIdx, (pcCU->getDepth(0) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1)) );
    467         }
    468         dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ uiTabIdx ]);
    469       } break;
    470 #endif
    471443    case( DMM3_IDX ):
    472444      {
     
    709681#endif
    710682      , bICFlag );
    711 #if SHARP_ILLUCOMP_REFINE_E0046
    712683    bICFlag = bICFlag && (iWidth > 8);
    713 #endif
    714684    xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
    715685#if H_3D_ARP
     
    731701  // Get depth reference
    732702  Int       depthRefViewIdx = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan;
     703#if H_3D_FCO_VSP_DONBDV_E0163
     704  TComPic* pRefPicBaseDepth = 0;
     705  Bool     bIsCurrDepthCoded = false;
     706  pRefPicBaseDepth  = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() );
     707  if ( pRefPicBaseDepth->getPicYuvRec() != NULL  )
     708  {
     709    bIsCurrDepthCoded = true;
     710  }
     711  else
     712  {
     713    pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx );
     714  }
     715#else
    733716  TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx );
     717#endif
    734718  assert(pRefPicBaseDepth != NULL);
    735719  TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec();
     
    752736  pcCU->clipMv(cDv);
    753737
    754 #if NTT_VSP_COMMON_E0207_E0208
     738#if H_3D_FCO_VSP_DONBDV_E0163
     739  if ( bIsCurrDepthCoded )
     740  {
     741      cDv.setZero();
     742  }
     743#endif
    755744  // fetch virtual depth map
    756 #if NTT_VSP_VECTOR_CLIP_E0208
    757745  pcBaseViewDepthPicYuv->extendPicBorder();
    758 #endif
    759746  xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp );
    760747  // sub-PU based compensation
    761748  xPredInterLumaBlkFromDM   ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
    762749  xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
    763 #else
    764   UInt uiAbsPartIdx = pcCU->getZorderIdxInCU();
    765   Int iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
    766   Int iBlkY = ( pcCU->getAddr() / pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
    767   xPredInterLumaBlkFromDM  ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, &cDv, uiPartAddr, iBlkX,    iBlkY,    iWidth,    iHeight,    pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
    768   xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, &cDv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
    769 #endif
    770 
    771750}
    772751#endif
     
    984963  if ( yFrac == 0 )
    985964  {
    986 #if MTK_CLIPPING_ALIGN_IC_E0168
     965#if H_3D_IC
    987966    m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi || bICFlag
    988967#else
     
    996975  else if ( xFrac == 0 )
    997976  {
    998 #if MTK_CLIPPING_ALIGN_IC_E0168
     977#if H_3D_IC
    999978    m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag
    1000979#else
     
    1019998#endif
    1020999      );
    1021 #if MTK_CLIPPING_ALIGN_IC_E0168
     1000#if H_3D_IC
    10221001    m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi || bICFlag
    10231002#else
     
    10331012  if( bICFlag )
    10341013  {
    1035 #if SHARP_ILLUCOMP_REFINE_E0046
    10361014    Int a, b, i, j;
    10371015    const Int iShift = IC_CONST_SHIFT;
    10381016
    10391017    xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA );
    1040 #else
    1041     Int a, b, iShift, i, j;
    1042 
    1043     xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_LUMA );
    1044 #endif
    10451018
    10461019
     
    10491022      for ( j = 0; j < width; j++ )
    10501023      {
    1051 #if !MTK_CLIPPING_ALIGN_IC_E0168
    1052         if( bi )
    1053         {
    1054           Int iIFshift = IF_INTERNAL_PREC - g_bitDepthY;
    1055           dst[j] = ( ( a*dst[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1 << iIFshift ) - IF_INTERNAL_OFFS;
    1056         }
    1057         else
    1058 #endif
    10591024          dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b );
    10601025      }
    10611026      dst += dstStride;
    10621027    }
    1063 #if MTK_CLIPPING_ALIGN_IC_E0168
     1028
    10641029    if(bi)
    10651030    {
     
    10761041      }
    10771042    }
    1078 #endif
    10791043  }
    10801044#endif
     
    11271091  if ( yFrac == 0 )
    11281092  {
    1129 #if MTK_CLIPPING_ALIGN_IC_E0168
     1093#if H_3D_IC
    11301094    m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag
    11311095#else
     
    11361100#endif
    11371101    );   
    1138 #if MTK_CLIPPING_ALIGN_IC_E0168
     1102#if H_3D_IC
    11391103    m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag
    11401104#else
     
    11481112  else if ( xFrac == 0 )
    11491113  {
    1150 #if MTK_CLIPPING_ALIGN_IC_E0168
     1114#if H_3D_IC
    11511115    m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
    11521116#else
     
    11571121#endif
    11581122    );
    1159 #if MTK_CLIPPING_ALIGN_IC_E0168
     1123#if H_3D_IC
    11601124    m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
    11611125#else
     
    11741138#endif 
    11751139      );
    1176 #if MTK_CLIPPING_ALIGN_IC_E0168
     1140#if H_3D_IC
    11771141    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
    11781142#else
     
    11891153#endif
    11901154      );
    1191 #if MTK_CLIPPING_ALIGN_IC_E0168
     1155#if H_3D_IC
    11921156    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
    11931157#else
     
    12031167  if( bICFlag )
    12041168  {
    1205 #if SHARP_ILLUCOMP_REFINE_E0046
    12061169    Int a, b, i, j;
    12071170    const Int iShift = IC_CONST_SHIFT;
    12081171    xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb
    1209 #else
    1210     Int a, b, iShift, i, j;
    1211     xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_CHROMA_U ); // Cb
    1212 #endif
    12131172    for ( i = 0; i < cxHeight; i++ )
    12141173    {
    12151174      for ( j = 0; j < cxWidth; j++ )
    12161175      {
    1217 #if !MTK_CLIPPING_ALIGN_IC_E0168
    1218         if( bi )
    1219         {
    1220           Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC;
    1221           dstCb[j] = ( ( a*dstCb[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1<<iIFshift ) - IF_INTERNAL_OFFS;
    1222         }
    1223         else
    1224 #endif
    12251176          dstCb[j] = Clip3(  0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b );
    12261177      }
    12271178      dstCb += dstStride;
    12281179    }
    1229 #if SHARP_ILLUCOMP_REFINE_E0046
    12301180    xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_V ); // Cr
    1231 #else
    1232     xGetLLSICPrediction( cu, mv, refPic, a, b, iShift, TEXT_CHROMA_V ); // Cr
    1233 #endif
    12341181    for ( i = 0; i < cxHeight; i++ )
    12351182    {
    12361183      for ( j = 0; j < cxWidth; j++ )
    12371184      {
    1238 #if !MTK_CLIPPING_ALIGN_IC_E0168
    1239         if( bi )
    1240         {
    1241           Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC;
    1242           dstCr[j] = ( ( a*dstCr[j] + a*IF_INTERNAL_OFFS ) >> iShift ) + b*( 1<<iIFshift ) - IF_INTERNAL_OFFS;
    1243         }
    1244         else
    1245 #endif
    12461185          dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b );
    12471186      }
    12481187      dstCr += dstStride;
    12491188    }
    1250 #if MTK_CLIPPING_ALIGN_IC_E0168
     1189
    12511190    if(bi)
    12521191    {
     
    12681207      }
    12691208    }
    1270 #endif
    12711209  }
    12721210#endif
     
    13231261  Int k, l, bottomLeft, topRight;
    13241262  Int horPred;
    1325   Int leftColumn[MAX_CU_SIZE], topRow[MAX_CU_SIZE], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];
     1263  Int leftColumn[MAX_CU_SIZE+1], topRow[MAX_CU_SIZE+1], bottomRow[MAX_CU_SIZE], rightColumn[MAX_CU_SIZE];
    13261264  UInt blkSize = width;
    13271265  UInt offset2D = width;
     
    14171355}
    14181356
    1419 #if !SHARP_ILLUCOMP_REFINE_E0046
    1420 /** Function for counting leading number of zeros/ones
    1421  * \param x input value
    1422  \ This function counts leading number of zeros for positive numbers and
    1423  \ leading number of ones for negative numbers. This can be implemented in
    1424  \ single instructure cycle on many processors.
    1425  */
    1426 
    1427 Short CountLeadingZerosOnes (Short x)
    1428 {
    1429   Short clz;
    1430   Short i;
    1431 
    1432   if(x == 0)
    1433   {
    1434     clz = 0;
    1435   }
    1436   else
    1437   {
    1438     if (x == -1)
    1439     {
    1440       clz = 15;
    1441     }
    1442     else
    1443     {
    1444       if(x < 0)
    1445       {
    1446         x = ~x;
    1447       }
    1448       clz = 15;
    1449       for(i = 0;i < 15;++i)
    1450       {
    1451         if(x)
    1452         {
    1453           clz --;
    1454         }
    1455         x = x >> 1;
    1456       }
    1457     }
    1458   }
    1459   return clz;
    1460 }
    1461 #endif
    14621357
    14631358/** Function for deriving LM illumination compensation.
    14641359 */
    1465 #if SHARP_ILLUCOMP_REFINE_E0046
    14661360Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType )
    1467 #else
    1468 Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, Int &iShift, TextType eType )
    1469 #endif
    14701361{
    14711362  TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec();
     
    14951386
    14961387  Int x = 0, y = 0, xx = 0, xy = 0;
    1497 #if SHARP_ILLUCOMP_REFINE_E0046
    14981388  Int precShift = std::max(0, (( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC) - 12);
    1499 #endif
    15001389
    15011390  if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) && iCUPelY > 0 && iRefY > 0 )
     
    15191408    }
    15201409
    1521 #if SHARP_ILLUCOMP_REFINE_E0046
    15221410    for( j = 0; j < uiWidth; j+=2 )
    1523 #else
    1524     for( j = 0; j < uiWidth; j++ )
    1525 #endif
    15261411    {
    15271412      x += pRef[j];
    15281413      y += pRec[j];
    1529 #if SHARP_ILLUCOMP_REFINE_E0046
    15301414      xx += (pRef[j] * pRef[j])>>precShift;
    15311415      xy += (pRef[j] * pRec[j])>>precShift;
    1532 #else
    1533       xx += pRef[j] * pRef[j];
    1534       xy += pRef[j] * pRec[j];
    1535 #endif
    1536     }
    1537 #if SHARP_ILLUCOMP_REFINE_E0046
     1416    }
    15381417    iCountShift += g_aucConvertToBit[ uiWidth ] + 1;
    1539 #else
    1540     iCountShift += g_aucConvertToBit[ uiWidth ] + 2;
    1541 #endif
    15421418  }
    15431419
     
    15631439    }
    15641440
    1565 #if SHARP_ILLUCOMP_REFINE_E0046
    15661441    for( i = 0; i < uiHeight; i+=2 )
    1567 #else
    1568     for( i = 0; i < uiHeight; i++ )
    1569 #endif
    15701442    {
    15711443      x += pRef[0];
    15721444      y += pRec[0];
    1573 #if SHARP_ILLUCOMP_REFINE_E0046
     1445
    15741446      xx += (pRef[0] * pRef[0])>>precShift;
    15751447      xy += (pRef[0] * pRec[0])>>precShift;
     
    15771449      pRef += iRefStride*2;
    15781450      pRec += iRecStride*2;
    1579 #else
    1580       xx += pRef[0] * pRef[0];
    1581       xy += pRef[0] * pRec[0];
    1582 
    1583       pRef += iRefStride;
    1584       pRec += iRecStride;
    1585 #endif
    1586     }
    1587 #if SHARP_ILLUCOMP_REFINE_E0046
     1451    }
    15881452    iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 1 );
    1589 #else
    1590     iCountShift += iCountShift > 0 ? 1 : ( g_aucConvertToBit[ uiWidth ] + 2 );
    1591 #endif
    1592   }
    1593 
    1594 #if SHARP_ILLUCOMP_REFINE_E0046
     1453  }
     1454
    15951455  xy += xx >> IC_REG_COST_SHIFT;
    15961456  xx += xx >> IC_REG_COST_SHIFT;
     
    15991459  const Int iShift = IC_CONST_SHIFT;
    16001460  {
    1601 #else
    1602   Int iTempShift = ( ( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC ) + g_aucConvertToBit[ uiWidth ] + 3 - 15;
    1603 
    1604   if( iTempShift > 0 )
    1605   {
    1606     x  = ( x +  ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift;
    1607     y  = ( y +  ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift;
    1608     xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift;
    1609     xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift;
    1610     iCountShift -= iTempShift;
    1611   }
    1612 
    1613   iShift = 13;
    1614 
    1615   if( iCountShift == 0 )
    1616   {
    1617     a = 1;
    1618     b = 0;
    1619     iShift = 0;
    1620   }
    1621   else
    1622   {
    1623     Int a1 = ( xy << iCountShift ) - y * x;
    1624     Int a2 = ( xx << iCountShift ) - x * x;             
    1625 #endif
    16261461    {
    16271462      const Int iShiftA2 = 6;
    1628 #if !SHARP_ILLUCOMP_REFINE_E0046
    1629       const Int iShiftA1 = 15;
    1630 #endif
    16311463      const Int iAccuracyShift = 15;
    16321464
     
    16361468      Int a2s = a2;
    16371469
    1638 #if SHARP_ILLUCOMP_REFINE_E0046
    16391470      a1 = Clip3(0, 2*a2, a1);
    16401471      iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2;
    16411472      iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF;
    1642 #else
    1643       iScaleShiftA1 = GetMSB( abs( a1 ) ) - iShiftA1;
    1644       iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2; 
    1645 #endif
    16461473
    16471474      if( iScaleShiftA1 < 0 )
     
    16621489      a1s = a1 >> iScaleShiftA1;
    16631490
    1664 #if SHARP_ILLUCOMP_REFINE_E0046
    16651491      a = a1s * m_uiaShift[ a2s ];
    16661492      a = a >> iScaleShiftA;
    1667 #else
    1668       if (a2s >= 1)
    1669       {
    1670         a = a1s * m_uiaShift[ a2s - 1];
    1671       }
    1672       else
    1673       {
    1674         a = 0;
    1675       }
    1676 
    1677       if( iScaleShiftA < 0 )
    1678       {
    1679         a = a << -iScaleShiftA;
    1680       }
    1681       else
    1682       {
    1683         a = a >> iScaleShiftA;
    1684       }
    1685 
    1686       a = Clip3( -( 1 << 15 ), ( 1 << 15 ) - 1, a );
    1687 
    1688       Int minA = -(1 << (6));
    1689       Int maxA = (1 << 6) - 1;
    1690       if( a <= maxA && a >= minA )
    1691       {
    1692         // do nothing
    1693       }
    1694       else
    1695       {
    1696         Short n = CountLeadingZerosOnes( a );
    1697         a = a >> (9-n);
    1698         iShift -= (9-n);
    1699       }
    1700 #endif
    17011493      b = (  y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift;
    17021494    }
     
    17061498
    17071499#if H_3D_VSP
    1708 
    1709 #if NTT_VSP_COMMON_E0207_E0208
    17101500// not fully support iRatioTxtPerDepth* != 1
    17111501Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY )
     
    17151505
    17161506  Int refDepStride = picRefDepth->getStride();
    1717 
    1718 #if NTT_VSP_VECTOR_CLIP_E0208
    17191507
    17201508  Int refDepOffset  = ( (mv->getHor()+2) >> 2 ) + ( (mv->getVer()+2) >> 2 ) * refDepStride;
     
    17361524  refDepth += refDepOffset;
    17371525
    1738 #else // NTT_VSP_VECTOR_CLIP_E0208
    1739 
    1740   Int widthDepth = picRefDepth->getWidth();
    1741   Int heightDepth = picRefDepth->getHeight();
    1742   Int posX, posY;
    1743   cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture
    1744   posX /= ratioTxtPerDepthX; // texture position -> depth postion
    1745   posY /= ratioTxtPerDepthY;
    1746  
    1747   posX = Clip3(0, widthDepth-width,   posX + ((mv->getHor()+2)>>2));
    1748   posY = Clip3(0, heightDepth-height, posY + ((mv->getVer()+2)>>2));
    1749  
    1750   Pel *refDepth  = picRefDepth->getLumaAddr() + posX + posY * refDepStride;
    1751 
    1752 #endif // NTT_VSP_VECTOR_CLIP_E0208
    1753 
    17541526  Int depStride = yuvDepth->getStride();
    17551527  Pel *depth = yuvDepth->getLumaAddr();
    1756 
    1757 #if NTT_VSP_ADAPTIVE_SPLIT_E0207
    17581528
    17591529  if( width<8 || height<8 )
     
    18941664  }
    18951665
    1896 #else // NTT_VSP_ADAPTIVE_SPLIT_E0207
    1897 
    1898   Int rightOffset = nTxtPerDepthX - 1;
    1899   Int depStrideBlock = depStride * nTxtPerDepthY;
    1900   Int refDepStrideBlock = refDepStride * nTxtPerDepthY;
    1901   Pel *refDepthTop = refDepth;
    1902   Pel *refDepthBot = refDepthTop + (nTxtPerDepthY-1)*refDepStride;
    1903 
    1904   for( Int y=0; y<height; y+= nTxtPerDepthY )
    1905   {
    1906     for( Int x=0; x<width; x+=nTxtPerDepthX )
    1907     {
    1908       Pel maxDepth = refDepthTop[x] > refDepthBot[x] ? refDepthTop[x] : refDepthBot[x];
    1909 
    1910       if( maxDepth < refDepthTop[x+rightOffset] )
    1911       {
    1912         maxDepth = refDepthTop[x+rightOffset];
    1913       }
    1914       if( maxDepth < refDepthBot[x+rightOffset] )
    1915       {
    1916         maxDepth = refDepthBot[x+rightOffset];
    1917       }
    1918 
    1919       depth[x] = maxDepth;
    1920 
    1921     }
    1922     refDepthTop += refDepStrideBlock;
    1923     refDepthBot += refDepStrideBlock;
    1924     depth       += depStrideBlock;
    1925   }
    1926 
    1927 #endif // NTT_VSP_ADAPTIVE_SPLIT_E0207
     1666
    19281667}
    19291668
     
    19431682  Pel *dst    = yuvDst->getLumaAddr(partAddr);
    19441683  Pel *depth  = yuvDepth->getLumaAddr();
    1945  
    1946 #if !(NTT_VSP_DC_BUGFIX_E0208)
    1947   Int widthLuma = picRef->getWidth();
    1948   Int posX, posY;
    1949   cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture
    1950 #endif
    19511684
    19521685#if H_3D_VSP_BLOCKSIZE == 1
     
    20211754      Int xFrac = disparity & 0x3;
    20221755
    2023 #if NTT_VSP_DC_BUGFIX_E0208
    2024 
    20251756      dv.setHor( disparity );
    20261757      cu->clipMv( dv );
     
    20381769      assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 );
    20391770      m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi );
    2040 
    2041 #else // NTT_VSP_DC_BUGFIX_E0208
    2042 
    2043       for( Int j=0; j < nTxtPerDepthX; j++ )
    2044       {
    2045         Int refOffset = xTxt+j + (disparity >> 2);
    2046 #if H_3D_VSP_CONSTRAINED
    2047         if(refOffset<minRelativePos || refOffset>maxRelativePos)
    2048         {
    2049           xFrac = 0;
    2050         }
    2051         refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);
    2052 #endif
    2053         Int absX  = posX + refOffset;
    2054 
    2055         if (xFrac == 0)
    2056         {
    2057           absX = Clip3(0, widthLuma-1, absX);
    2058         }
    2059         else
    2060         {
    2061           absX = Clip3(4, widthLuma-5, absX);
    2062         }
    2063 
    2064         refOffset = absX - posX;
    2065         assert( ref[refOffset] >= 0 && ref[refOffset] <= 255 );
    2066        
    2067         m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi );
    2068       }
    2069 
    2070 #endif // NTT_VSP_DC_BUGFIX_E0208
    2071 
    20721771    }
    20731772    ref   += refStrideBlock;
     
    21011800  Pel *depth  = yuvDepth->getLumaAddr();
    21021801
    2103 #if !(NTT_VSP_DC_BUGFIX_E0208)
    2104   Int widthChroma = picRef->getWidth() >> 1;
    2105   Int posX, posY;
    2106   cu->getPic()->getPicYuvRec()->getTopLeftSamplePos( cu->getAddr(), cu->getZorderIdxInCU() + partAddr, posX, posY ); // top-left position in texture
    2107   posX >>= 1;
    2108   posY >>= 1;
    2109 #endif
    2110  
    21111802#if H_3D_VSP_BLOCKSIZE == 1
    21121803#if H_3D_VSP_CONSTRAINED
     
    21731864      Int xFrac = disparity & 0x7;
    21741865     
    2175 #if NTT_VSP_DC_BUGFIX_E0208
    2176 
    21771866      dv.setHor( disparity );
    21781867      cu->clipMv( dv );
     
    21931882      m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi );
    21941883      m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !isBi );
    2195 
    2196 #else // NTT_VSP_DC_BUGFIX_E0208
    2197      
    2198       for( Int j=0; j < nTxtPerDepthX; j++ )
    2199       {
    2200         Int refOffset = xTxt+j + (disparity >> 3);
    2201 #if H_3D_VSP_CONSTRAINED
    2202         if(refOffset<minRelativePos || refOffset>maxRelativePos)
    2203         {
    2204           xFrac = 0;
    2205         }
    2206         refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);
    2207 #endif
    2208         Int absX  = posX + refOffset;
    2209 
    2210         if (xFrac == 0)
    2211         {
    2212           absX = Clip3(0, widthChroma-1, absX);
    2213         }
    2214         else
    2215         {
    2216           absX = Clip3(4, widthChroma-5, absX);
    2217         }
    2218 
    2219         refOffset = absX - posX;
    2220         assert( refCb[refOffset] >= 0 && refCb[refOffset] <= 255 );
    2221         assert( refCr[refOffset] >= 0 && refCr[refOffset] <= 255 );
    2222 
    2223         m_if.filterHorChroma( &refCb[refOffset], refStride, &dstCb[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi );
    2224         m_if.filterHorChroma( &refCr[refOffset], refStride, &dstCr[xTxt+j], dstStride, 1, nTxtPerDepthY, xFrac, !isBi );
    2225       }
    2226 
    2227 #endif // NTT_VSP_DC_BUGFIX_E0208
    22281884    }
    22291885    refCb += refStrideBlock;
     
    22331889    depth += depStrideBlock;
    22341890  }
    2235 
    2236 }
    2237 #else // NTT_VSP_COMMON_E0207_E0208
    2238 
    2239 // Input:
    2240 // refPic: Ref picture. Full picture, with padding
    2241 // posX, posY:     PU position, texture
    2242 // sizeX, sizeY: PU size
    2243 // partAddr: z-order index
    2244 // dv: disparity vector. derived from neighboring blocks
    2245 //
    2246 // Output: dstPic, PU predictor 64x64
    2247 Void TComPrediction::xPredInterLumaBlkFromDM( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, TComMv* dv, UInt partAddr,Int posX, Int posY
    2248                                             , Int sizeX, Int sizeY, Bool isDepth, TComYuv *&dstPic, Bool bi )
    2249 {
    2250   Int widthLuma;
    2251   Int heightLuma;
    2252 
    2253   if (isDepth)
    2254   {
    2255     widthLuma   =  pPicBaseDepth->getWidth();
    2256     heightLuma  =  pPicBaseDepth->getHeight();
    2257   }
    2258   else
    2259   {
    2260     widthLuma   =  refPic->getWidth();
    2261     heightLuma  =  refPic->getHeight();
    2262   }
    2263 
    2264 #if H_3D_VSP_BLOCKSIZE != 1
    2265   Int widthDepth  = pPicBaseDepth->getWidth();
    2266   Int heightDepth = pPicBaseDepth->getHeight();
    2267 #endif
    2268 
    2269 #if H_3D_VSP_CONSTRAINED
    2270   Int widthDepth  = pPicBaseDepth->getWidth();
    2271   Int heightDepth = pPicBaseDepth->getHeight();
    2272 #endif
    2273 
    2274   Int nTxtPerDepthX = widthLuma  / ( pPicBaseDepth->getWidth() );  // texture pixel # per depth pixel
    2275   Int nTxtPerDepthY = heightLuma / ( pPicBaseDepth->getHeight() );
    2276 
    2277   Int refStride = refPic->getStride();
    2278   Int dstStride = dstPic->getStride();
    2279   Int depStride =  pPicBaseDepth->getStride();
    2280   Int depthPosX = Clip3(0,   widthLuma - sizeX,  (posX/nTxtPerDepthX) + ((dv->getHor()+2)>>2));
    2281   Int depthPosY = Clip3(0,   heightLuma- sizeY,  (posY/nTxtPerDepthY) + ((dv->getVer()+2)>>2));
    2282   Pel *ref    = refPic->getLumaAddr() + posX + posY * refStride;
    2283   Pel *dst    = dstPic->getLumaAddr(partAddr);
    2284   Pel *depth  = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride;
    2285 
    2286 #if H_3D_VSP_BLOCKSIZE != 1
    2287 #if H_3D_VSP_BLOCKSIZE == 2
    2288   Int  dW = sizeX>>1;
    2289   Int  dH = sizeY>>1;
    2290 #endif
    2291 #if H_3D_VSP_BLOCKSIZE == 4
    2292   Int  dW = sizeX>>2;
    2293   Int  dH = sizeY>>2;
    2294 #endif
    2295   {
    2296     Pel* depthi = depth;
    2297     for (Int j = 0; j < dH; j++)
    2298     {
    2299       for (Int i = 0; i < dW; i++)
    2300       {
    2301         Pel* depthTmp;
    2302 #if H_3D_VSP_BLOCKSIZE == 2
    2303         if (depthPosX + (i<<1) < widthDepth)
    2304           depthTmp = depthi + (i << 1);
    2305         else
    2306           depthTmp = depthi + (widthDepth - depthPosX - 1);
    2307 #endif
    2308 #if H_3D_VSP_BLOCKSIZE == 4
    2309         if (depthPosX + (i<<2) < widthDepth)
    2310           depthTmp = depthi + (i << 2);
    2311         else
    2312           depthTmp = depthi + (widthDepth - depthPosX - 1);
    2313 #endif
    2314         Int maxV = 0;
    2315         for (Int blockj = 0; blockj < H_3D_VSP_BLOCKSIZE; blockj+=(H_3D_VSP_BLOCKSIZE-1))
    2316         {
    2317           Int iX = 0;
    2318           for (Int blocki = 0; blocki < H_3D_VSP_BLOCKSIZE; blocki+=(H_3D_VSP_BLOCKSIZE-1))
    2319           {
    2320             if (maxV < depthTmp[iX])
    2321               maxV = depthTmp[iX];
    2322 #if H_3D_VSP_BLOCKSIZE == 2
    2323             if (depthPosX + (i<<1) + blocki < widthDepth - 1)
    2324 #else // H_3D_VSP_BLOCKSIZE == 4
    2325             if (depthPosX + (i<<2) + blocki < widthDepth - 1)
    2326 #endif
    2327               iX = (H_3D_VSP_BLOCKSIZE-1);
    2328           }
    2329 #if H_3D_VSP_BLOCKSIZE == 2
    2330           if (depthPosY + (j<<1) + blockj < heightDepth - 1)
    2331 #else // H_3D_VSP_BLOCKSIZE == 4
    2332           if (depthPosY + (j<<2) + blockj < heightDepth - 1)
    2333 #endif
    2334             depthTmp += depStride * (H_3D_VSP_BLOCKSIZE-1);
    2335         }
    2336         m_pDepthBlock[i+j*dW] = maxV;
    2337       } // end of i < dW
    2338 #if H_3D_VSP_BLOCKSIZE == 2
    2339       if (depthPosY + ((j+1)<<1) < heightDepth)
    2340         depthi += (depStride << 1);
    2341       else
    2342         depthi  = depth + (heightDepth-depthPosY-1)*depStride;
    2343 #endif
    2344 #if H_3D_VSP_BLOCKSIZE == 4
    2345       if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1
    2346         depthi += (depStride << 2);
    2347       else
    2348         depthi  = depth + (heightDepth-depthPosY-1)*depStride; // the last line
    2349 #endif
    2350     }
    2351   }
    2352 #endif // H_3D_VSP_BLOCKSIZE != 1
    2353 
    2354 #if H_3D_VSP_BLOCKSIZE == 1
    2355 #if H_3D_VSP_CONSTRAINED
    2356   //get LUT based horizontal reference range
    2357   Int range = xGetConstrainedSize(sizeX, sizeY);
    2358 
    2359   // The minimum depth value
    2360   Int minRelativePos = MAX_INT;
    2361   Int maxRelativePos = MIN_INT;
    2362 
    2363   Pel* depthTemp, *depthInitial=depth;
    2364   for (Int yTxt = 0; yTxt < sizeY; yTxt++)
    2365   {
    2366     for (Int xTxt = 0; xTxt < sizeX; xTxt++)
    2367     {
    2368       if (depthPosX+xTxt < widthDepth)
    2369         depthTemp = depthInitial + xTxt;
    2370       else
    2371         depthTemp = depthInitial + (widthDepth - depthPosX - 1);
    2372 
    2373       Int disparity = pShiftLUT[ *depthTemp ]; // << iShiftPrec;
    2374       Int disparityInt = disparity >> 2;
    2375 
    2376       if( disparity <= 0)
    2377       {
    2378         if (minRelativePos > disparityInt+xTxt)
    2379             minRelativePos = disparityInt+xTxt;
    2380       }
    2381       else
    2382       {
    2383         if (maxRelativePos < disparityInt+xTxt)
    2384             maxRelativePos = disparityInt+xTxt;
    2385       }
    2386     }
    2387     if (depthPosY+yTxt < heightDepth)
    2388       depthInitial = depthInitial + depStride;
    2389   }
    2390 
    2391   Int disparity_tmp = pShiftLUT[ *depth ]; // << iShiftPrec;
    2392   if (disparity_tmp <= 0)
    2393     maxRelativePos = minRelativePos + range -1 ;
    2394   else
    2395     minRelativePos = maxRelativePos - range +1 ;
    2396 #endif
    2397 #endif // H_3D_VSP_BLOCKSIZE == 1
    2398 
    2399 #if H_3D_VSP_BLOCKSIZE != 1
    2400   Int yDepth = 0;
    2401 #endif
    2402   for ( Int yTxt = 0; yTxt < sizeY; yTxt += nTxtPerDepthY )
    2403   {
    2404     for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth++ )
    2405     {
    2406       Pel repDepth = 0; // to store the depth value used for warping
    2407 #if H_3D_VSP_BLOCKSIZE == 1
    2408       repDepth = depth[xDepth];
    2409 #endif
    2410 #if H_3D_VSP_BLOCKSIZE == 2
    2411       repDepth = m_pDepthBlock[(xTxt>>1) + (yTxt>>1)*dW];
    2412 #endif
    2413 #if H_3D_VSP_BLOCKSIZE == 4
    2414       repDepth = m_pDepthBlock[(xTxt>>2) + (yTxt>>2)*dW];
    2415 #endif
    2416 
    2417       assert( repDepth >= 0 && repDepth <= 255 );
    2418       Int disparity = pShiftLUT[ repDepth ]; // remove << iShiftPrec ??
    2419       Int refOffset = xTxt + (disparity >> 2);
    2420       Int xFrac = disparity & 0x3;
    2421 #if H_3D_VSP_CONSTRAINED
    2422       if(refOffset<minRelativePos || refOffset>maxRelativePos)
    2423         xFrac = 0;
    2424       refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);
    2425 #endif
    2426       Int absX  = posX + refOffset;
    2427 
    2428       if (xFrac == 0)
    2429         absX = Clip3(0, widthLuma-1, absX);
    2430       else
    2431         absX = Clip3(4, widthLuma-5, absX);
    2432 
    2433       refOffset = absX - posX;
    2434 
    2435       assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 );
    2436       m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi );
    2437     }
    2438     ref   += refStride*nTxtPerDepthY;
    2439     dst   += dstStride*nTxtPerDepthY;
    2440     depth += depStride;
    2441 #if H_3D_VSP_BLOCKSIZE != 1
    2442     yDepth++;
    2443 #endif
    2444 
    2445   }
    2446 }
    2447 
    2448 Void TComPrediction::xPredInterChromaBlkFromDM ( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, TComMv*dv, UInt partAddr, Int posX, Int posY
    2449                                                , Int sizeX, Int sizeY, Bool isDepth, TComYuv *&dstPic, Bool bi)
    2450 {
    2451   Int refStride = refPic->getCStride();
    2452   Int dstStride = dstPic->getCStride();
    2453   Int depStride = pPicBaseDepth->getStride();
    2454 
    2455   Int widthChroma, heightChroma;
    2456   if( isDepth)
    2457   {
    2458      widthChroma   = pPicBaseDepth->getWidth()>>1;
    2459      heightChroma  = pPicBaseDepth->getHeight()>>1;
    2460   }
    2461   else
    2462   {
    2463      widthChroma   = refPic->getWidth()>>1;
    2464      heightChroma  = refPic->getHeight()>>1;
    2465   }
    2466 
    2467   // Below is only for Texture chroma component
    2468 
    2469   Int widthDepth  = pPicBaseDepth->getWidth();
    2470   Int heightDepth = pPicBaseDepth->getHeight();
    2471 
    2472   Int nTxtPerDepthX, nTxtPerDepthY;  // Number of texture samples per one depth sample
    2473   Int nDepthPerTxtX, nDepthPerTxtY;  // Number of depth samples per one texture sample
    2474 
    2475   Int depthPosX;  // Starting position in depth image
    2476   Int depthPosY;
    2477 
    2478   if ( widthChroma > widthDepth )
    2479   {
    2480     nTxtPerDepthX = widthChroma / widthDepth;
    2481     nDepthPerTxtX = 1;
    2482     depthPosX = posX / nTxtPerDepthX + ((dv->getHor()+2)>>2);
    2483   }
    2484   else
    2485   {
    2486     nTxtPerDepthX = 1;
    2487     nDepthPerTxtX = widthDepth / widthChroma;
    2488     depthPosX = posX * nDepthPerTxtX + ((dv->getHor()+2)>>2);
    2489   }
    2490   depthPosX = Clip3(0, widthDepth - (sizeX<<1), depthPosX);
    2491   if ( heightChroma > heightDepth )
    2492   {
    2493     nTxtPerDepthY = heightChroma / heightDepth;
    2494     nDepthPerTxtY = 1;
    2495     depthPosY = posY / nTxtPerDepthY + ((dv->getVer()+2)>>2);
    2496   }
    2497   else
    2498   {
    2499     nTxtPerDepthY = 1;
    2500     nDepthPerTxtY = heightDepth / heightChroma;
    2501     depthPosY = posY * nDepthPerTxtY + ((dv->getVer()+2)>>2);
    2502   }
    2503   depthPosY = Clip3(0, heightDepth - (sizeY<<1), depthPosY);
    2504 
    2505   Pel *refCb  = refPic->getCbAddr() + posX + posY * refStride;
    2506   Pel *refCr  = refPic->getCrAddr() + posX + posY * refStride;
    2507   Pel *dstCb  = dstPic->getCbAddr(partAddr);
    2508   Pel *dstCr  = dstPic->getCrAddr(partAddr);
    2509   Pel *depth  = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride;  // move the pointer to the current depth pixel position
    2510 
    2511   Int refStrideBlock = refStride * nTxtPerDepthY;
    2512   Int dstStrideBlock = dstStride * nTxtPerDepthY;
    2513   Int depStrideBlock = depStride * nDepthPerTxtY;
    2514 
    2515   if ( widthChroma > widthDepth ) // We assume
    2516   {
    2517     assert( heightChroma > heightDepth );
    2518     printf("This branch should never been reached.\n");
    2519     exit(0);
    2520   }
    2521   else
    2522   {
    2523 #if H_3D_VSP_BLOCKSIZE == 1
    2524   Int  dW = sizeX;
    2525   Int  dH = sizeY;
    2526   Int  sW = 2; // search window size
    2527   Int  sH = 2;
    2528 #endif
    2529 #if H_3D_VSP_BLOCKSIZE == 2
    2530   Int  dW = sizeX;
    2531   Int  dH = sizeY;
    2532   Int  sW = 2; // search window size
    2533   Int  sH = 2;
    2534 #endif
    2535 #if H_3D_VSP_BLOCKSIZE == 4
    2536   Int  dW = sizeX>>1;
    2537   Int  dH = sizeY>>1;
    2538   Int  sW = 4; // search window size
    2539   Int  sH = 4;
    2540 #endif
    2541 
    2542   {
    2543     Pel* depthi = depth;
    2544     for (Int j = 0; j < dH; j++)
    2545     {
    2546       for (Int i = 0; i < dW; i++)
    2547       {
    2548         Pel* depthTmp;
    2549 #if H_3D_VSP_BLOCKSIZE == 1
    2550         depthTmp = depthi + (i << 1);
    2551 #endif
    2552 #if H_3D_VSP_BLOCKSIZE == 2
    2553         if (depthPosX + (i<<1) < widthDepth)
    2554           depthTmp = depthi + (i << 1);
    2555         else
    2556           depthTmp = depthi + (widthDepth - depthPosX - 1);
    2557 #endif
    2558 #if H_3D_VSP_BLOCKSIZE == 4
    2559         if (depthPosX + (i<<2) < widthDepth)
    2560           depthTmp = depthi + (i << 2);
    2561         else
    2562           depthTmp = depthi + (widthDepth - depthPosX - 1);
    2563 #endif
    2564         Int maxV = 0;
    2565         for (Int blockj = 0; blockj < sH; blockj+=(sH-1))
    2566         {
    2567           Int iX = 0;
    2568           for (Int blocki = 0; blocki < sW; blocki+=(sW-1))
    2569           {
    2570             if (maxV < depthTmp[iX])
    2571               maxV = depthTmp[iX];
    2572             if (depthPosX + i*sW + blocki < widthDepth - 1)
    2573                 iX = (sW-1);
    2574           }
    2575           if (depthPosY + j*sH + blockj < heightDepth - 1)
    2576                 depthTmp += depStride * (sH-1);
    2577         }
    2578         m_pDepthBlock[i+j*dW] = maxV;
    2579       } // end of i < dW
    2580 #if H_3D_VSP_BLOCKSIZE == 1
    2581       if (depthPosY + ((j+1)<<1) < heightDepth)
    2582         depthi += (depStride << 1);
    2583       else
    2584         depthi  = depth + (heightDepth-1)*depStride;
    2585 #endif
    2586 #if H_3D_VSP_BLOCKSIZE == 2
    2587       if (depthPosY + ((j+1)<<1) < heightDepth)
    2588         depthi += (depStride << 1);
    2589       else
    2590         depthi  = depth + (heightDepth-depthPosY-1)*depStride;
    2591 #endif
    2592 #if H_3D_VSP_BLOCKSIZE == 4
    2593       if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1
    2594         depthi += (depStride << 2);
    2595       else
    2596         depthi  = depth + (heightDepth-depthPosY-1)*depStride; // the last line
    2597 #endif
    2598     }
    2599   }
    2600 
    2601 
    2602 #if H_3D_VSP_BLOCKSIZE == 1
    2603 #if H_3D_VSP_CONSTRAINED
    2604   //get LUT based horizontal reference range
    2605   Int range = xGetConstrainedSize(sizeX, sizeY, false);
    2606 
    2607   // The minimum depth value
    2608   Int minRelativePos = MAX_INT;
    2609   Int maxRelativePos = MIN_INT;
    2610 
    2611   Int depthTmp;
    2612   for (Int yTxt=0; yTxt<sizeY; yTxt++)
    2613   {
    2614     for (Int xTxt=0; xTxt<sizeX; xTxt++)
    2615     {
    2616       depthTmp = m_pDepthBlock[xTxt+yTxt*dW];
    2617       Int disparity = pShiftLUT[ depthTmp ]; // << iShiftPrec;
    2618       Int disparityInt = disparity >> 3;//in chroma resolution
    2619 
    2620       if (disparityInt < 0)
    2621       {
    2622         if (minRelativePos > disparityInt+xTxt)
    2623             minRelativePos = disparityInt+xTxt;
    2624       }
    2625       else
    2626       {
    2627         if (maxRelativePos < disparityInt+xTxt)
    2628             maxRelativePos = disparityInt+xTxt;
    2629       }
    2630     }
    2631   }
    2632 
    2633   depthTmp = m_pDepthBlock[0];
    2634   Int disparity_tmp = pShiftLUT[ depthTmp ]; // << iShiftPrec;
    2635   if ( disparity_tmp < 0 )
    2636     maxRelativePos = minRelativePos + range - 1;
    2637   else
    2638     minRelativePos = maxRelativePos - range + 1;
    2639 
    2640 #endif // H_3D_VSP_CONSTRAINED
    2641 #endif // H_3D_VSP_BLOCKSIZE == 1
    2642 
    2643     // (sizeX, sizeY) is Chroma block size
    2644     for ( Int yTxt = 0, yDepth = 0; yTxt < sizeY; yTxt += nTxtPerDepthY, yDepth += nDepthPerTxtY )
    2645     {
    2646       for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth += nDepthPerTxtX )
    2647       {
    2648         Pel repDepth = 0; // to store the depth value used for warping
    2649 #if H_3D_VSP_BLOCKSIZE == 1
    2650         repDepth = m_pDepthBlock[(xTxt) + (yTxt)*dW];
    2651 #endif
    2652 #if H_3D_VSP_BLOCKSIZE == 2
    2653         repDepth = m_pDepthBlock[(xTxt) + (yTxt)*dW];
    2654 #endif
    2655 #if H_3D_VSP_BLOCKSIZE == 4
    2656         repDepth = m_pDepthBlock[(xTxt>>1) + (yTxt>>1)*dW];
    2657 #endif
    2658 
    2659       // calculate the offset in the reference picture
    2660         Int disparity = pShiftLUT[ repDepth ]; // Remove << iShiftPrec;
    2661         Int refOffset = xTxt + (disparity >> 3); // in integer pixel in chroma image
    2662         Int xFrac = disparity & 0x7;
    2663 #if H_3D_VSP_CONSTRAINED
    2664         if(refOffset < minRelativePos || refOffset > maxRelativePos)
    2665           xFrac = 0;
    2666         refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);
    2667 #endif
    2668         Int absX  = posX + refOffset;
    2669 
    2670         if (xFrac == 0)
    2671           absX = Clip3(0, widthChroma-1, absX);
    2672         else
    2673           absX = Clip3(4, widthChroma-5, absX);
    2674 
    2675         refOffset = absX - posX;
    2676 
    2677         assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 );
    2678         assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 );
    2679         m_if.filterHorChroma(&refCb[refOffset], refStride, &dstCb[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi);
    2680         m_if.filterHorChroma(&refCr[refOffset], refStride, &dstCr[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi);
    2681       }
    2682       refCb += refStrideBlock;
    2683       refCr += refStrideBlock;
    2684       dstCb += dstStrideBlock;
    2685       dstCr += dstStrideBlock;
    2686       depth += depStrideBlock;
    2687     }
    2688   }
    2689 
    2690 }
    2691 
    2692 #endif // NTT_VSP_COMMON_E0207_E0208
     1891}
     1892
    26931893
    26941894#if H_3D_VSP_CONSTRAINED
     
    27681968
    27691969#if H_3D_DIM_DMM
    2770 #if !SEC_DMM2_E0146_HHIFIX
    2771 UInt TComPrediction::xPredWedgeFromIntra( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd )
    2772 {
    2773   UInt uiThisBlockSize = uiWidth;
    2774 
    2775   TComDataCU* pcTempCU;
    2776   UInt        uiTempPartIdx;
    2777   // 1st: try continue above wedgelet
    2778   pcTempCU = pcCU->getPUAbove( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx );
    2779   if( pcTempCU && isDimMode( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ) )
    2780   {
    2781     UInt dimType =  getDimType( pcTempCU->getLumaIntraDir( uiTempPartIdx ) );
    2782     if( DMM1_IDX == dimType || DMM2_IDX == dimType || DMM3_IDX == dimType )
    2783     {
    2784       // get offset between current and reference block
    2785       UInt uiOffsetX = 0, uiOffsetY = 0;
    2786       xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY );
    2787 
    2788       // get reference wedgelet
    2789       WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[(pcTempCU->getWidth( uiTempPartIdx )>>((pcTempCU->getPartitionSize( uiTempPartIdx ) == SIZE_NxN) ? 1 : 0))])];
    2790       TComWedgelet* pcRefWedgelet = &(pacWedgeList->at( pcTempCU->getDmmWedgeTabIdx( dimType, uiTempPartIdx ) ) );
    2791 
    2792       // find wedgelet, if direction is suitable for continue wedge
    2793       if( pcRefWedgelet->checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) )
    2794       {
    2795         UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
    2796         pcRefWedgelet->getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd );
    2797         return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
    2798       }
    2799     }
    2800   }
    2801 
    2802   // 2nd: try continue left wedglelet
    2803   pcTempCU = pcCU->getPULeft( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx );
    2804   if( pcTempCU && isDimMode( pcTempCU->getLumaIntraDir( uiTempPartIdx ) ) )
    2805   {
    2806     UInt dimType = getDimType( pcTempCU->getLumaIntraDir( uiTempPartIdx ) );
    2807     if( DMM1_IDX == dimType || DMM2_IDX == dimType || DMM3_IDX == dimType )
    2808     {
    2809       // get offset between current and reference block
    2810       UInt uiOffsetX = 0, uiOffsetY = 0;
    2811       xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY );
    2812 
    2813       // get reference wedgelet
    2814       WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[(pcTempCU->getWidth( uiTempPartIdx )>>((pcTempCU->getPartitionSize( uiTempPartIdx ) == SIZE_NxN) ? 1 : 0))])];
    2815       TComWedgelet* pcRefWedgelet = &(pacWedgeList->at( pcTempCU->getDmmWedgeTabIdx( dimType, uiTempPartIdx ) ) );
    2816 
    2817       // find wedgelet, if direction is suitable for continue wedge
    2818       if( pcRefWedgelet->checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) )
    2819       {
    2820         UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
    2821         pcRefWedgelet->getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd );
    2822         return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
    2823       }
    2824     }
    2825   }
    2826 
    2827   // 3rd: (default) make wedglet from intra dir and max slope point
    2828   Int iSlopeX = 0, iSlopeY = 0;
    2829   UInt uiStartPosX = 0, uiStartPosY = 0;
    2830   if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) )
    2831   {
    2832     UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
    2833     xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd );
    2834     return xGetWedgePatternIdx( uiThisBlockSize, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
    2835   }
    2836 
    2837   return 0;
    2838 }
    2839 #endif
    2840 
    28411970UInt TComPrediction::xPredWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx )
    28421971{
     
    28471976  Int           uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255;
    28481977
    2849 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX
    28501978  assert( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 );
    28511979  return g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]][uiColTexIntraDir-2].at(intraTabIdx);
    2852 #else
    2853   if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) { return g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]][uiColTexIntraDir-2].at(intraTabIdx); }
    2854   else                                                     { return g_dmmWedgeNodeLists[(g_aucConvertToBit[uiWidth])].at(intraTabIdx).getPatternIdx(); }
    2855 #endif
    28561980}
    28571981
     
    28751999  }
    28762000
    2877 #if SCU_HS_DMM4_REMOVE_DIV_E0242
    2878   Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2;
    2879   iDC = iDC >> (cuMaxLog2Size - pcCU->getDepth(0))*2;
    2880 #else
    2881   iDC /= (uiWidth*uiHeight);
    2882 #endif
     2001  Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2;   //
     2002  iDC = iDC >> (cuMaxLog2Size - pcCU->getDepth(0))*2;        //  iDC /= (uiWidth*uiHeight);
     2003
    28832004  piRefBlkY = cTempYuv.getLumaAddr();
    28842005
     
    29072028  }
    29082029}
    2909 
    2910 #if !SEC_DMM2_E0146_HHIFIX
    2911 Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY )
    2912 {
    2913   ruiOffsetX = 0;
    2914   ruiOffsetY = 0;
    2915 
    2916   // get offset between current and above/left block
    2917   UInt uiThisOriginX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
    2918   UInt uiThisOriginY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
    2919 
    2920   UInt uiNumPartInRefCU = pcRefCU->getTotalNumPart();
    2921   UInt uiMaxDepthRefCU = 0;
    2922   while( uiNumPartInRefCU > 1 )
    2923   {
    2924     uiNumPartInRefCU >>= 2;
    2925     uiMaxDepthRefCU++;
    2926   }
    2927 
    2928   UInt uiDepthRefPU = (pcRefCU->getDepth(uiRefAbsPartIdx)) + (pcRefCU->getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1);
    2929   UInt uiShifts = (uiMaxDepthRefCU - uiDepthRefPU)*2;
    2930   UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts;
    2931 
    2932   UInt uiRefOriginX = pcRefCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ];
    2933   UInt uiRefOriginY = pcRefCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ];
    2934 
    2935   if( (uiThisOriginX - uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX - uiRefOriginX); }
    2936   if( (uiThisOriginY - uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY - uiRefOriginY); }
    2937 }
    2938 
    2939 Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY )
    2940 {
    2941   riSlopeX = 0, riSlopeY = 0, ruiStartPosX = 0, ruiStartPosY = 0;
    2942 
    2943   // 1st step: get wedge start point (max. slope)
    2944   Int* piSource = pcCU->getPattern()->getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt );
    2945   Int iSourceStride = ( uiBlockSize<<1 ) + 1;
    2946 
    2947   UInt uiSlopeMaxAbove = 0, uiPosSlopeMaxAbove = 0;
    2948   for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize-1); uiPosHor++ )
    2949   {
    2950     if( abs( piSource[uiPosHor+1] - piSource[uiPosHor] ) > uiSlopeMaxAbove )
    2951     {
    2952       uiSlopeMaxAbove = abs( piSource[uiPosHor+1] - piSource[uiPosHor] );
    2953       uiPosSlopeMaxAbove = uiPosHor;
    2954     }
    2955   }
    2956 
    2957   UInt uiSlopeMaxLeft = 0, uiPosSlopeMaxLeft = 0;
    2958   for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize-1); uiPosVer++ )
    2959   {
    2960     if( abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft )
    2961     {
    2962       uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] );
    2963       uiPosSlopeMaxLeft = uiPosVer;
    2964     }
    2965   }
    2966 
    2967   if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 )
    2968   {
    2969     return false;
    2970   }
    2971 
    2972   ruiStartPosX = ( uiSlopeMaxAbove >  uiSlopeMaxLeft  ) ? uiPosSlopeMaxAbove : 0;
    2973   ruiStartPosY = ( uiSlopeMaxLeft  >= uiSlopeMaxAbove ) ? uiPosSlopeMaxLeft  : 0;
    2974 
    2975   // 2nd step: derive wedge direction
    2976   Int uiPreds[3] = {-1, -1, -1};
    2977   Int iMode = -1;
    2978   Int iPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds, &iMode ); 
    2979 
    2980   UInt uiDirMode = 0;
    2981   if( iMode >= 0 ) { iPredNum = iMode; }
    2982   if( iPredNum == 1 ) { uiDirMode = uiPreds[0]; }
    2983   if( iPredNum == 2 ) { uiDirMode = uiPreds[1]; }
    2984 
    2985   if( uiDirMode < 2 ) { return false; } // no planar & DC
    2986 
    2987   Bool modeHor       = (uiDirMode < 18);
    2988   Bool modeVer       = !modeHor;
    2989   Int intraPredAngle = modeVer ? (Int)uiDirMode - VER_IDX : modeHor ? -((Int)uiDirMode - HOR_IDX) : 0;
    2990   Int absAng         = abs(intraPredAngle);
    2991   Int signAng        = intraPredAngle < 0 ? -1 : 1;
    2992   Int angTable[9]    = {0,2,5,9,13,17,21,26,32};
    2993   absAng             = angTable[absAng];
    2994   intraPredAngle     = signAng * absAng;
    2995 
    2996   // 3rd step: set slope for direction
    2997   if( modeHor )
    2998   {
    2999     riSlopeX = ( intraPredAngle > 0 ) ?            -32 :              32;
    3000     riSlopeY = ( intraPredAngle > 0 ) ? intraPredAngle : -intraPredAngle;
    3001   }
    3002   else if( modeVer )
    3003   {
    3004     riSlopeX = ( intraPredAngle > 0 ) ? intraPredAngle : -intraPredAngle;
    3005     riSlopeY = ( intraPredAngle > 0 ) ?            -32 :              32;
    3006   }
    3007 
    3008   return true;
    3009 }
    3010 
    3011 Void TComPrediction::xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd )
    3012 {
    3013   ruhXs = 0;
    3014   ruhYs = 0;
    3015   ruhXe = 0;
    3016   ruhYe = 0;
    3017 
    3018   // scaling of start pos and block size to wedge resolution
    3019   UInt uiScaledStartPosX = 0;
    3020   UInt uiScaledStartPosY = 0;
    3021   UInt uiScaledBlockSize = 0;
    3022   WedgeResolution eWedgeRes = g_dmmWedgeResolution[(UInt)g_aucConvertToBit[uiBlockSize]];
    3023   switch( eWedgeRes )
    3024   {
    3025   case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; }
    3026   case(   FULL_PEL ): { uiScaledStartPosX =  uiPMSPosX;     uiScaledStartPosY =  uiPMSPosY;     uiScaledBlockSize =  uiBlockSize;     break; }
    3027   case(   HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; }
    3028   }
    3029   Int iMaxPos = (Int)uiScaledBlockSize - 1;
    3030 
    3031   // case above
    3032   if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 )
    3033   {
    3034     ruhXs = (UChar)uiScaledStartPosX;
    3035     ruhYs = 0;
    3036 
    3037     if( iDeltaY == 0 )
    3038     {
    3039       if( iDeltaX < 0 )
    3040       {
    3041         ruhXe = 0;
    3042         ruhYe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos );
    3043         return;
    3044       }
    3045       else
    3046       {
    3047         ruhXe = (UChar)iMaxPos;
    3048         ruhYe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos );
    3049         std::swap( ruhXs, ruhXe );
    3050         std::swap( ruhYs, ruhYe );
    3051         return;
    3052       }
    3053     }
    3054 
    3055     // regular case
    3056     Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) );
    3057 
    3058     if( iVirtualEndX < 0 )
    3059     {
    3060       Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd;
    3061       if( iYe < (Int)uiScaledBlockSize )
    3062       {
    3063         ruhXe = 0;
    3064         ruhYe = (UChar)std::max( iYe, 0 );
    3065         return;
    3066       }
    3067       else
    3068       {
    3069         ruhXe = (UChar)std::min( (iYe - iMaxPos), iMaxPos );
    3070         ruhYe = (UChar)iMaxPos;
    3071         return;
    3072       }
    3073     }
    3074     else if( iVirtualEndX > iMaxPos )
    3075     {
    3076       Int iYe = roftoi( (Double)(iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd;
    3077       if( iYe < (Int)uiScaledBlockSize )
    3078       {
    3079         ruhXe = (UChar)iMaxPos;
    3080         ruhYe = (UChar)std::max( iYe, 0 );
    3081         std::swap( ruhXs, ruhXe );
    3082         std::swap( ruhYs, ruhYe );
    3083         return;
    3084       }
    3085       else
    3086       {
    3087         ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 );
    3088         ruhYe = (UChar)iMaxPos;
    3089         return;
    3090       }
    3091     }
    3092     else
    3093     {
    3094       Int iXe = iVirtualEndX + iDeltaEnd;
    3095       if( iXe < 0 )
    3096       {
    3097         ruhXe = 0;
    3098         ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 );
    3099         return;
    3100       }
    3101       else if( iXe > iMaxPos )
    3102       {
    3103         ruhXe = (UChar)iMaxPos;
    3104         ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 );
    3105         std::swap( ruhXs, ruhXe );
    3106         std::swap( ruhYs, ruhYe );
    3107         return;
    3108       }
    3109       else
    3110       {
    3111         ruhXe = (UChar)iXe;
    3112         ruhYe = (UChar)iMaxPos;
    3113         return;
    3114       }
    3115     }
    3116   }
    3117 
    3118   // case left
    3119   if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 )
    3120   {
    3121     ruhXs = 0;
    3122     ruhYs = (UChar)uiScaledStartPosY;
    3123 
    3124     if( iDeltaX == 0 )
    3125     {
    3126       if( iDeltaY < 0 )
    3127       {
    3128         ruhXe = (UChar)std::min( std::max( -iDeltaEnd, 0 ), iMaxPos );
    3129         ruhYe = 0;
    3130         std::swap( ruhXs, ruhXe );
    3131         std::swap( ruhYs, ruhYe );
    3132         return;
    3133       }
    3134       else
    3135       {
    3136         ruhXe = (UChar)std::min( std::max( iDeltaEnd, 0 ), iMaxPos );
    3137         ruhYe = (UChar)iMaxPos;
    3138         return;
    3139       }
    3140     }
    3141 
    3142     // regular case
    3143     Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)iMaxPos * ((Double)iDeltaY / (Double)iDeltaX) );
    3144 
    3145     if( iVirtualEndY < 0 )
    3146     {
    3147       Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) - iDeltaEnd;
    3148       if( iXe < (Int)uiScaledBlockSize )
    3149       {
    3150         ruhXe = (UChar)std::max( iXe, 0 );
    3151         ruhYe = 0;
    3152         std::swap( ruhXs, ruhXe );
    3153         std::swap( ruhYs, ruhYe );
    3154         return;
    3155       }
    3156       else
    3157       {
    3158         ruhXe = (UChar)iMaxPos;
    3159         ruhYe = (UChar)std::min( (iXe - iMaxPos), iMaxPos );
    3160         std::swap( ruhXs, ruhXe );
    3161         std::swap( ruhYs, ruhYe );
    3162         return;
    3163       }
    3164     }
    3165     else if( iVirtualEndY > (uiScaledBlockSize-1) )
    3166     {
    3167       Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd;
    3168       if( iXe < (Int)uiScaledBlockSize )
    3169       {
    3170         ruhXe = (UChar)std::max( iXe, 0 );
    3171         ruhYe = (UChar)(uiScaledBlockSize-1);
    3172         return;
    3173       }
    3174       else
    3175       {
    3176         ruhXe = (UChar)iMaxPos;
    3177         ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 );
    3178         std::swap( ruhXs, ruhXe );
    3179         std::swap( ruhYs, ruhYe );
    3180         return;
    3181       }
    3182     }
    3183     else
    3184     {
    3185       Int iYe = iVirtualEndY - iDeltaEnd;
    3186       if( iYe < 0 )
    3187       {
    3188         ruhXe = (UChar)std::max( (iMaxPos + iYe), 0 );
    3189         ruhYe = 0;
    3190         std::swap( ruhXs, ruhXe );
    3191         std::swap( ruhYs, ruhYe );
    3192         return;
    3193       }
    3194       else if( iYe > iMaxPos )
    3195       {
    3196         ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 );
    3197         ruhYe = (UChar)iMaxPos;
    3198         return;
    3199       }
    3200       else
    3201       {
    3202         ruhXe = (UChar)iMaxPos;
    3203         ruhYe = (UChar)iYe;
    3204         std::swap( ruhXs, ruhXe );
    3205         std::swap( ruhYs, ruhYe );
    3206         return;
    3207       }
    3208     }
    3209   }
    3210 
    3211   // case origin
    3212   if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 )
    3213   {
    3214     if( iDeltaX*iDeltaY < 0 )
    3215     {
    3216       return;
    3217     }
    3218 
    3219     ruhXs = 0;
    3220     ruhYs = 0;
    3221 
    3222     if( iDeltaY == 0 )
    3223     {
    3224       ruhXe = (UChar)iMaxPos;
    3225       ruhYe = 0;
    3226       std::swap( ruhXs, ruhXe );
    3227       std::swap( ruhYs, ruhYe );
    3228       return;
    3229     }
    3230 
    3231     if( iDeltaX == 0 )
    3232     {
    3233       ruhXe = 0;
    3234       ruhYe = (UChar)iMaxPos;
    3235       return;
    3236     }
    3237 
    3238     Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)iMaxPos * ((Double)iDeltaX / (Double)iDeltaY) );
    3239 
    3240     if( iVirtualEndX > iMaxPos )
    3241     {
    3242       Int iYe = roftoi( (Double)((Int)iMaxPos - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd;
    3243       if( iYe < (Int)uiScaledBlockSize )
    3244       {
    3245         ruhXe = (UChar)(uiScaledBlockSize-1);
    3246         ruhYe = (UChar)std::max( iYe, 0 );
    3247         std::swap( ruhXs, ruhXe );
    3248         std::swap( ruhYs, ruhYe );
    3249         return;
    3250       }
    3251       else
    3252       {
    3253         ruhXe = (UChar)std::max( (iMaxPos - (iYe - iMaxPos)), 0 );
    3254         ruhYe = (UChar)(uiScaledBlockSize-1);
    3255         return;
    3256       }
    3257     }
    3258     else
    3259     {
    3260       Int iXe = iVirtualEndX + iDeltaEnd;
    3261       if( iXe < 0 )
    3262       {
    3263         ruhXe = 0;
    3264         ruhYe = (UChar)std::max( (iMaxPos + iXe), 0 );
    3265         return;
    3266       }
    3267       else if( iXe > iMaxPos )
    3268       {
    3269         ruhXe = (UChar)(uiScaledBlockSize-1);
    3270         ruhYe = (UChar)std::max( (iMaxPos - (iXe - iMaxPos)), 0 );
    3271         std::swap( ruhXs, ruhXe );
    3272         std::swap( ruhYs, ruhYe );
    3273         return;
    3274       }
    3275       else
    3276       {
    3277         ruhXe = (UChar)iXe;
    3278         ruhYe = (UChar)(uiScaledBlockSize-1);
    3279         return;
    3280       }
    3281     }
    3282   }
    3283 }
    3284 
    3285 UInt TComPrediction::xGetWedgePatternIdx( UInt uiBlockSize, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe )
    3286 {
    3287   WedgeRefList* pcWedgeRefList = &g_dmmWedgeRefLists[(g_aucConvertToBit[uiBlockSize])];
    3288   for( UInt uiIdx = 0; uiIdx < pcWedgeRefList->size(); uiIdx++ )
    3289   {
    3290     TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList->at(uiIdx));
    3291     if( pcTestWedgeRef->getStartX() == uhXs && pcTestWedgeRef->getStartY() == uhYs && pcTestWedgeRef->getEndX() == uhXe && pcTestWedgeRef->getEndY() == uhYe )
    3292     {
    3293       return pcTestWedgeRef->getRefIdx();
    3294     }
    3295   }
    3296   return 0;
    3297 }
    3298 #endif
    3299 #endif
     2030#endif
     2031
    33002032#if H_3D_DIM_RBC
    33012033Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Pel& rDeltaDC )
     
    33272059#if H_3D_DIM_SDC
    33282060Void TComPrediction::analyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride
    3329 #if KWU_SDC_SIMPLE_DC_E0117
    33302061                                         ,UInt uiIntraMode
    33312062                                         ,Bool orgDC
    3332 #endif
    33332063                                        )
    33342064{
     
    33382068  memset(iSumPix, 0, sizeof(Int)*2);
    33392069 
    3340 #if KWU_SDC_SIMPLE_DC_E0117
    33412070  if (orgDC == false)
    33422071  {
     
    33642093    return;
    33652094  }
    3366 #endif
    33672095
    33682096  Int subSamplePix;
Note: See TracChangeset for help on using the changeset viewer.