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


Ignore:
Timestamp:
26 May 2013, 15:41:34 (11 years ago)
Author:
tech
Message:
  • Reintegrated branch 6.2-dev0 rev. 442.
  • Changed version number.
  • Added coding results.
File:
1 edited

Legend:

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

    r332 r443  
    5050#endif
    5151
     52#if HHI_DELTADC_DLT_D0035
     53#define GetDepthValue2Idx(val)     (pcCU->getSlice()->getSPS()->depthValue2idx(val))
     54#define GetIdx2DepthValue(val)     (pcCU->getSlice()->getSPS()->idx2DepthValue(val))
     55#endif
     56
     57#if MERL_General_Fix
     58#if MERL_VSP_C0152
     59#if MERL_CVSP_D0165
     60Int TComPrediction::m_iRangeLuma[12]   = {14, 34, 21, 15, 36, 26, 21, 49, 41, 36, 80, 72};
     61Int TComPrediction::m_iRangeChroma[12] = { 2,  8,  5,  4, 11,  9,  8, 19, 17, 15, 34, 32};
     62#endif
     63#endif
     64#endif
     65
    5266TComPrediction::TComPrediction()
    5367: m_pLumaRecBuffer(0)
     
    7892
    7993  m_cYuvPredTemp.destroy();
    80 
     94#if QC_ARP_D0177
     95  m_acYuvPredBase[0].destroy();
     96  m_acYuvPredBase[1].destroy();
     97  m_acYuvDiff[0].destroy();
     98  m_acYuvDiff[1].destroy();
     99#endif
    81100  if( m_pLumaRecBuffer )
    82101  {
     
    119138
    120139    m_cYuvPredTemp.create( g_uiMaxCUWidth, g_uiMaxCUHeight );
     140#if QC_ARP_D0177
     141    m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
     142    m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
     143    m_acYuvDiff    [0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
     144    m_acYuvDiff    [1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
     145#endif
    121146  }
    122147
     
    535560  // Do prediction
    536561  {
     562#if QC_DC_PREDICTOR_D0183
     563    Int iMean0, iMean1;
     564    getPredDCs( pbRegion, iWidth, pSrc+srcStride+1, srcStride, iMean0, iMean1 );
     565#else
    537566    //UInt uiSum0 = 0, uiSum1 = 0;
    538567    Int iSum0 = 0, iSum1 = 0;
     
    573602    iMean0 = iSum0 / iCount0; // TODO : integer op.
    574603    iMean1 = iSum1 / iCount1;
     604#endif
    575605#if LGE_EDGE_INTRA_DELTA_DC
    576606    if( bDelta )
     
    751781}
    752782
    753 #if H3D_IVRP
     783#if H3D_IVRP & !QC_ARP_D0177
    754784Void TComPrediction::residualPrediction(TComDataCU* pcCU, TComYuv* pcYuvPred, TComYuv* pcYuvResPred)
    755785{
     
    768798  pcYuvPred->add(pcYuvResPred, iWidth, iHeight);
    769799}
     800#endif
     801
     802#if MERL_General_Fix
     803#if MERL_VSP_C0152
     804// Function to perform VSP block compensation
     805Void  TComPrediction::xPredInterVSPBlk(TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, TComMv cMv, RefPicList eRefPicList, TComYuv*& rpcYuvPred
     806                                     , Bool bi
     807#if !MERL_Bi_VSP_D0166
     808                                     , Int vspIdx
     809#endif
     810                                       )
     811{
     812  TComPic*    pRefPicBaseTxt        = NULL;
     813  TComPicYuv* pcBaseViewTxtPicYuv   = NULL;
     814  TComPicYuv* pcBaseViewDepthPicYuv = NULL;
     815  Int iBlkX = 0;
     816  Int iBlkY = 0;
     817  Int* pShiftLUT;
     818  Int  iShiftPrec;
     819
     820#if !MERL_VSP_NBDV_RefVId_Fix_D0166
     821  pRefPicBaseTxt        = pcCU->getSlice()->getRefPicBaseTxt();
     822  pcBaseViewTxtPicYuv   = pRefPicBaseTxt->getPicYuvRec();
     823  TComPic* pRefPicBaseDepth = pcCU->getSlice()->getRefPicBaseDepth();
     824  pcBaseViewDepthPicYuv     = pRefPicBaseDepth->getPicYuvRec();
     825
     826  Int iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     827  Int iBlkY = ( pcCU->getAddr() / pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     828  pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec);
     829  xPredInterLumaBlkFromDM  ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX,    iBlkY,    iWidth,    iHeight,    pcCU->getSlice()->getSPS()->isDepth(), rpcYuvPred );
     830  xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getSPS()->isDepth(), rpcYuvPred );
     831
     832#else // MERL_VSP_NBDV_RefVId_Fix_D0166
     833   // Step 1: get depth reference
     834#if QC_BVSP_CleanUP_D0191
     835  RefPicList privateRefPicList = REF_PIC_LIST_0;
     836  Int refIdxList0 = pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr );
     837  Int refIdxList1 = pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr );
     838  privateRefPicList = refIdxList0 != NOT_VALID ? REF_PIC_LIST_0 : REF_PIC_LIST_1;
     839  if(privateRefPicList == REF_PIC_LIST_1 && refIdxList1== NOT_VALID )
     840  {
     841    assert(0);
     842  }
     843  Int privateRefIdx = privateRefPicList == REF_PIC_LIST_0 ? refIdxList0 : refIdxList1;
     844  Int viewId = pcCU->getSlice()->getRefViewId(privateRefPicList, privateRefIdx);
     845  Int refPoc = pcCU->getSlice()->getRefPOC(privateRefPicList, privateRefIdx);
     846#else
     847  //recover VSP reference frame according to negative refIdx number
     848  RefPicList privateRefPicList = (RefPicList) pcCU->getVSPDir( uiPartAddr );
     849  assert(privateRefPicList == REF_PIC_LIST_0 || privateRefPicList == REF_PIC_LIST_1);
     850  Int  refIdx = -1-pcCU->getCUMvField( privateRefPicList )->getRefIdx( uiPartAddr ); // texture ref index, a trick when storing refIdx
     851  Int  viewId = pcCU->getSlice()->getRefViewId(privateRefPicList, refIdx);  // texture view id
     852  Int  refPoc = pcCU->getSlice()->getRefPOC(privateRefPicList, refIdx);     // texture POC
     853#endif
     854  TComPic* pRefPicBaseDepth = pcCU->getSlice()->getDepthRefPic(viewId, refPoc);
     855
     856  pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec();
     857  assert(refPoc == pcCU->getSlice()->getPOC());
     858  assert(pRefPicBaseDepth != NULL);
     859  assert(pcBaseViewDepthPicYuv != NULL);
     860
     861  iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     862  iBlkY = ( pcCU->getAddr() / pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     863#if MERL_Bi_VSP_D0166
     864  // Step 2: get texture reference
     865  pRefPicBaseTxt = xGetVspRefTxt( pcCU, uiPartAddr, eRefPicList);
     866  pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec();
     867  assert(pcBaseViewTxtPicYuv != NULL);
     868
     869  // initialize the LUT according to the reference view idx
     870  pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec, pRefPicBaseTxt->getViewId());
     871
     872  // Step 3: Do compensation
     873  xPredInterLumaBlkFromDM  ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX,    iBlkY,    iWidth,    iHeight,    pcCU->getSlice()->getSPS()->isDepth(), rpcYuvPred, bi );
     874  xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getSPS()->isDepth(), rpcYuvPred, bi );
     875#else
     876  // Step 2: get texture reference
     877  pRefPicBaseTxt = pcCU->getSlice()->getRefPic(privateRefPicList, refIdx);
     878  pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec();
     879  assert(pcBaseViewTxtPicYuv != NULL);
     880
     881  //initialize the LUT according to the reference view idx
     882  pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec, pRefPicBaseTxt->getViewId());
     883
     884  // Step 3: Do compensation
     885  xPredInterLumaBlkFromDM  ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX,    iBlkY,    iWidth,    iHeight,    pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     886  xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     887#endif
     888
     889#endif
     890}
     891
     892#endif
     893
     894#if MERL_Bi_VSP_D0166
     895TComPic*  TComPrediction::xGetVspRefTxt(TComDataCU* pcCU, UInt uiPartAddr, RefPicList eRefPicList)
     896{
     897#if QC_BVSP_CleanUP_D0191
     898  RefPicList privateRefPicList = REF_PIC_LIST_0;
     899  Int refIdxList0 = pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr );
     900  Int refIdxList1 = pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr );
     901  privateRefPicList = refIdxList0 != NOT_VALID ? REF_PIC_LIST_0 : REF_PIC_LIST_1;
     902  if(privateRefPicList == REF_PIC_LIST_1 && refIdxList1==NOT_VALID )
     903  {
     904    assert(0);
     905  }
     906  Int privateRefIdx = privateRefPicList == REF_PIC_LIST_0 ? refIdxList0 : refIdxList1;
     907  Int viewId = pcCU->getSlice()->getRefViewId(privateRefPicList, privateRefIdx);
     908#else
     909  RefPicList  privateRefPicList = (RefPicList) pcCU->getVSPDir( uiPartAddr );
     910  Int         refIdx = -1-pcCU->getCUMvField( privateRefPicList )->getRefIdx( uiPartAddr ); // texture ref index, a trick when storing refIdx
     911  Int         viewId = pcCU->getSlice()->getRefViewId(privateRefPicList, refIdx);  // texture view id
     912#endif
     913  TComPic*    refPic = NULL;
     914
     915  assert(privateRefPicList == REF_PIC_LIST_0 || privateRefPicList == REF_PIC_LIST_1);
     916
     917  if (privateRefPicList == eRefPicList)
     918  {
     919#if QC_BVSP_CleanUP_D0191
     920    Int  refIdxt = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );
     921#else
     922    Int  refIdxt = -1-pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );
     923#endif
     924    assert(refIdxt>= 0);
     925    refPic = pcCU->getSlice()->getRefPic(eRefPicList, refIdxt);
     926  }
     927  else
     928  {
     929    // Find the other interview reference in order to do VSP
     930    RefPicList otherRefPicList = privateRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
     931    Bool isFound = false;
     932    for (Int iRefIdx = 0; iRefIdx <pcCU->getSlice()->getNumRefIdx(otherRefPicList); iRefIdx ++ )
     933    {
     934      Int refViewIdx  = pcCU->getSlice()->getRefViewId( otherRefPicList, iRefIdx);
     935      if ( (refViewIdx != pcCU->getSlice()->getViewId()) && (refViewIdx != viewId ) )
     936      {
     937        refPic = pcCU->getSlice()->getRefPic(otherRefPicList, iRefIdx);
     938        isFound = true;
     939        break;
     940      }
     941    }
     942
     943    if (isFound == false)
     944    {
     945#if QC_BVSP_CleanUP_D0191
     946      Int  refIdxTxt = pcCU->getCUMvField( privateRefPicList )->getRefIdx( uiPartAddr );
     947#else
     948      Int  refIdxTxt = -1-pcCU->getCUMvField( privateRefPicList )->getRefIdx( uiPartAddr );
     949#endif
     950      assert(refIdxTxt >= 0);
     951      refPic = pcCU->getSlice()->getRefPic(privateRefPicList, refIdxTxt);
     952    }
     953    assert(isFound);
     954  }
     955  assert(refPic != NULL);
     956  return refPic;
     957}
     958#endif
    770959#endif
    771960
     
    781970  if (vspIdx != 0)
    782971  {
     972#if !QC_BVSP_CleanUP_D0191
    783973    if (iRefIdx >= 0)
    784974    {
     
    786976    }
    787977    assert (iRefIdx < 0); // assert (iRefIdx == NOT_VALID);
     978#endif
    788979  }
    789980  else
     
    8101001  }
    8111002#endif
    812 
     1003#if QC_ARP_D0177
     1004  if(
     1005#if MERL_General_Fix // TODO: Maybe logically redundant, but easier to read. Need verification before being removed
     1006#if MERL_VSP_C0152
     1007       vspIdx == 0 &&
     1008#endif
     1009#endif
     1010       pcCU->getSlice()->getSPS()->isDepth() == false
     1011    && pcCU->getSlice()->getSPS()->getViewId() > 0
     1012    && pcCU->getSlice()->getSPS()->getUseAdvRP() > 0
     1013    && pcCU->getARPW( uiPartAddr ) > 0
     1014    && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC()
     1015    && (pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N || pcCU->isSkipped(uiPartAddr))
     1016    )
     1017  {
     1018    xPredInterUniARP( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , iPartIdx , bi );
     1019  }
     1020  else
     1021  {
     1022#endif
    8131023#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
    8141024  if( pcCU->getSlice()->getSPS()->isDepth() )
     
    8161026#if MERL_VSP_C0152
    8171027    if (vspIdx != 0)
    818     { // depth, vsp
     1028    { // depth, vsp compensation
     1029#if !MERL_General_Fix
    8191030      // get depth estimator here
    8201031      TComPic* pRefPicBaseDepth = pcCU->getSlice()->getRefPicBaseDepth();
     
    8331044      xPredInterLumaBlkFromDM  ( pcBaseViewDepthPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX,    iBlkY,    iWidth,    iHeight,     pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
    8341045      xPredInterChromaBlkFromDM( pcBaseViewDepthPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1,  pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     1046#else
     1047#if MERL_Bi_VSP_D0166
     1048      xPredInterVSPBlk(pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, cMv, eRefPicList, rpcYuvPred, bi );
     1049#else
     1050      xPredInterVSPBlk(pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, cMv, eRefPicList, rpcYuvPred, bi, vspIdx );
     1051#endif
     1052#endif
    8351053    }
    8361054    else
     
    8551073#endif// MERL_VSP_C0152 //else
    8561074  }
    857   else
     1075  else  // texture
    8581076  {
    8591077#endif
    8601078#if MERL_VSP_C0152
    8611079    if ( vspIdx != 0 )
    862     { // texture, vsp
     1080    { // texture, vsp compensation
     1081#if !MERL_General_Fix
    8631082      TComPic*    pRefPicBaseTxt        = pcCU->getSlice()->getRefPicBaseTxt();
    8641083      TComPicYuv* pcBaseViewTxtPicYuv   = pRefPicBaseTxt->getPicYuvRec();
     
    8791098      xPredInterLumaBlkFromDM  ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX,    iBlkY,    iWidth,    iHeight,    pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
    8801099      xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     1100#else
     1101#if MERL_Bi_VSP_D0166
     1102      xPredInterVSPBlk(pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, cMv, eRefPicList, rpcYuvPred, bi );
     1103#else
     1104      xPredInterVSPBlk(pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, cMv, eRefPicList, rpcYuvPred, bi, vspIdx );
     1105#endif
     1106#endif
    8811107    }
    8821108    else//texture not VSP
     
    9111137   }
    9121138#endif
    913 }
    914 
     1139#if QC_ARP_D0177
     1140  }
     1141#endif
     1142}
     1143
     1144#if QC_ARP_D0177
     1145Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi, TComMvField * pNewMvFiled )
     1146{
     1147  Int         iRefIdx     = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
     1148  TComMv      cMv         = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
     1149  Bool        bTobeScaled = false;
     1150  UChar dW = pcCU->getARPW ( uiPartAddr );
     1151  TComPic* pcPicYuvBaseCol =  NULL;
     1152  TComPic* pcPicYuvBaseRef =  NULL;
     1153  DisInfo cDistparity;
     1154
     1155  if( pNewMvFiled )
     1156  {
     1157    iRefIdx = pNewMvFiled->getRefIdx();
     1158    cMv = pNewMvFiled->getMv();
     1159  }
     1160
     1161#if QC_CU_NBDV_D0181
     1162  cDistparity.bDV           = pcCU->getDvInfo(uiPartAddr).bDV;
     1163  if( cDistparity.bDV )
     1164  {
     1165#if MERL_VSP_C0152
     1166    cDistparity.m_acMvCand[0] = pcCU->getDvInfo(0).m_acMvCandNoRef[0];
     1167#else
     1168    cDistparity.m_acMvCand[0] = pcCU->getDvInfo(0).m_acMvCand[0];
     1169#endif
     1170    assert(pcCU->getDvInfo(uiPartAddr).bDV ==  pcCU->getDvInfo(0).bDV);
     1171    cDistparity.m_aVIdxCan[0] = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan[0];
     1172    cDistparity.iN            = pcCU->getDvInfo(uiPartAddr).iN;
     1173  }
     1174  else
     1175    cDistparity.iN    =  0;
     1176#else
     1177  pcCU->getDisMvpCandNBDV( iPartIdx, uiPartAddr,  &cDistparity, false );
     1178#endif
     1179
     1180  dW = !cDistparity.iN ? 0: dW;
     1181  if( cDistparity.iN )
     1182  {
     1183    if(dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC()!= pcCU->getSlice()->getPOC())
     1184      bTobeScaled = true;
     1185    pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan[0] );
     1186    pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC(), cDistparity.m_aVIdxCan[0] );
     1187    if( (!pcPicYuvBaseCol || pcPicYuvBaseCol->getPOC() != pcCU->getSlice()->getPOC()) || (!pcPicYuvBaseRef || pcPicYuvBaseRef->getPOC() != pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ))
     1188    {
     1189      dW = 0;
     1190      bTobeScaled = false;
     1191    }
     1192    else
     1193      assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() );
     1194    if(bTobeScaled)
     1195    {     
     1196      Int iCurrPOC = pcCU->getSlice()->getPOC();
     1197      Int iColRefPOC  = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx );
     1198      Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList,  0);
     1199      Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC);
     1200      if ( iScale != 4096 )
     1201        cMv = cMv.scaleMv( iScale );
     1202      iRefIdx = 0;
     1203    }
     1204  }
     1205  pcCU->clipMv(cMv);
     1206  TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec();
     1207  xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
     1208#if LGE_ILLUCOMP_B0045
     1209    , false
     1210#endif
     1211    , true
     1212    );
     1213  xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
     1214#if LGE_ILLUCOMP_B0045
     1215    , false
     1216#endif
     1217    , true
     1218    );
     1219  if( dW > 0 )
     1220  {
     1221    TComYuv * pYuvmB0 = &m_acYuvPredBase[0];
     1222    TComYuv * pYuvB1  = &m_acYuvPredBase[1];
     1223    assert ( cDistparity.iN == 1 );
     1224    pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec();
     1225    xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acMvCand[0], iWidth, iHeight, pYuvB1, bi
     1226#if LGE_ILLUCOMP_B0045
     1227      , false
     1228#endif
     1229      ,  true
     1230      );
     1231    xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acMvCand[0], iWidth, iHeight, pYuvB1, bi
     1232#if LGE_ILLUCOMP_B0045
     1233      , false
     1234#endif
     1235      , true
     1236      );
     1237    pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec();
     1238    TComMv cMVwithDisparity = cMv + cDistparity.m_acMvCand[0];
     1239    pcCU->clipMv(cMVwithDisparity);
     1240    xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvmB0, bi
     1241#if LGE_ILLUCOMP_B0045
     1242      , false
     1243#endif
     1244      , true
     1245      );
     1246    xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvmB0, bi
     1247#if LGE_ILLUCOMP_B0045
     1248      , false
     1249#endif
     1250      , true
     1251      );
     1252    pYuvB1->subtractARP( pYuvB1 , pYuvmB0 , uiPartAddr , iWidth , iHeight );
     1253    if(dW == 2)
     1254      pYuvB1->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
     1255    rpcYuvPred->addARP( rpcYuvPred , pYuvB1 , uiPartAddr , iWidth , iHeight , !bi );
     1256  }
     1257}
     1258#endif
    9151259
    9161260#if MERL_VSP_C0152
     
    9231267  Int      iRefIdx[2] = {-1, -1};
    9241268
     1269#if MERL_Bi_VSP_D0166
     1270  Bool biDecision = 0;
     1271  Int  predDirVSP = 0;
     1272#if QC_BVSP_CleanUP_D0191
     1273  RefPicList privateRefPicList = REF_PIC_LIST_0;
     1274#endif
     1275  if (pcCU->getVSPIndex(uiPartAddr) != 0) // is VSP
     1276  {
     1277    Int biVSPAvail = 0;
     1278    //test whether VSP is Bi or Uni
     1279    //Step1. Get derived DV view id
     1280#if QC_BVSP_CleanUP_D0191
     1281    RefPicList otherRefPicList = REF_PIC_LIST_1;
     1282    Int refIdxList0 = pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr );
     1283    Int refIdxList1 = pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr );
     1284    privateRefPicList = refIdxList0 != NOT_VALID ? REF_PIC_LIST_0 : REF_PIC_LIST_1;
     1285    if(privateRefPicList == REF_PIC_LIST_1 && refIdxList1==NOT_VALID )
     1286    {
     1287      assert(0);
     1288    }
     1289    Int privateRefIdx = privateRefPicList == REF_PIC_LIST_0 ? refIdxList0 : refIdxList1;
     1290    Int viewId = pcCU->getSlice()->getRefViewId(privateRefPicList, privateRefIdx);
     1291    Int refPoc = pcCU->getSlice()->getRefPOC(privateRefPicList, privateRefIdx);
     1292#else
     1293    Int  refIdx = pcCU->getCUMvField( privateRefPicList )->getRefIdx( uiPartAddr );
     1294    RefPicList privateRefPicList = (RefPicList) pcCU->getVSPDir( uiPartAddr );
     1295    RefPicList otherRefPicList = privateRefPicList == REF_PIC_LIST_0 ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
     1296    assert(privateRefPicList == REF_PIC_LIST_0 || privateRefPicList == REF_PIC_LIST_1);
     1297    Int  refIdx = -1-pcCU->getCUMvField( privateRefPicList )->getRefIdx( uiPartAddr );
     1298    assert(refIdx >= 0);
     1299    Int  viewId = pcCU->getSlice()->getRefViewId(privateRefPicList, refIdx);
     1300    Int  refPoc = pcCU->getSlice()->getRefPOC(privateRefPicList, refIdx);
     1301#endif
     1302    assert(refPoc == pcCU->getSlice()->getPOC());
     1303//    if(refPoc != pcCU->getSlice()->getPOC() )
     1304//    {
     1305//      printf("refPOC= %d, and current POC=%d\n", refPoc, pcCU->getSlice()->getPOC() );
     1306//    }
     1307    //Step 2. Get initial prediction direction value according to reference picture list availability
     1308    Int iInterDir = ((pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0) > 0 && pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1) > 0) ? 3 :
     1309      (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0) > 0 ? 1 : 2));
     1310    //Step 3.  Check the availability of Bi VSP by checking the interview reference availability in the other reference list
     1311    if(iInterDir == 3)
     1312    {
     1313      for (Int jRefIdx = 0; jRefIdx <pcCU->getSlice()->getNumRefIdx(otherRefPicList); jRefIdx++ )
     1314      {
     1315        Int refViewIdx  = pcCU->getSlice()->getRefViewId( otherRefPicList, jRefIdx);
     1316        if ( (refViewIdx != pcCU->getSlice()->getViewId()) && (refViewIdx != viewId ) )
     1317        {
     1318          biVSPAvail = 1;
     1319          break;
     1320        }
     1321      }
     1322    }
     1323    //Step 4. Update the Bi VSP prediction direction
     1324    if ( iInterDir == 3 && biVSPAvail == 1)
     1325    {
     1326      biDecision   = 1;
     1327      predDirVSP = 3;
     1328    }
     1329    else
     1330    {
     1331      biDecision = 0;
     1332      if ( privateRefPicList == REF_PIC_LIST_0 )
     1333        predDirVSP = 1;
     1334      else
     1335        predDirVSP = 2;
     1336    }
     1337  }
     1338  else
     1339  {//not VSP
     1340    if( ( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 ) )
     1341      biDecision = 1;
     1342    else
     1343      biDecision = 0;
     1344  }
     1345#endif
     1346
    9251347  for ( Int iRefList = 0; iRefList < 2; iRefList++ )
    9261348  {
     
    9381360    else
    9391361    {
    940       if ( iRefList== REF_PIC_LIST_1 && iRefIdx[iRefList] < 0 ) // iRefIdx[iRefList] ==NOT_VALID
     1362
     1363#if !MERL_Bi_VSP_D0166 //both lists should go
     1364      if ( iRefList == REF_PIC_LIST_1 && iRefIdx[iRefList] < 0 ) // iRefIdx[iRefList] ==NOT_VALID
    9411365      {
    9421366        continue;
    9431367      }
     1368#else
     1369      //Reference list loop termination
     1370#if QC_BVSP_CleanUP_D0191
     1371      RefPicList privateVSPRefPicList = privateRefPicList;
     1372#else
     1373      RefPicList privateVSPRefPicList = (RefPicList) pcCU->getVSPDir( uiPartAddr );
     1374#endif
     1375      if( (pcCU->getVSPIndex(uiPartAddr)!=0) &&  iRefList != privateVSPRefPicList && !biDecision  )
     1376      {//when VSP mode, if it is uni prediction, the other reference list should skip
     1377        continue;
     1378      }
     1379#endif
     1380
    9441381    }
    9451382#else
     
    9531390
    9541391    pcMbYuv = &m_acYuvPred[iRefList];
     1392
     1393#if MERL_Bi_VSP_D0166
     1394    if(biDecision == 1)
     1395#else
    9551396    if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 )
     1397#endif
    9561398    {
    9571399#if MERL_VSP_C0152
     
    9931435  {
    9941436#if MERL_VSP_C0152
     1437#if !MERL_Bi_VSP_D0166
    9951438    if(pcCU->getVSPIndex(uiPartAddr))
    9961439      m_acYuvPred[0].copyPartToPartYuv( rpcYuvPred, uiPartAddr, iWidth, iHeight );
    9971440    else
    9981441#endif
     1442#endif
    9991443    xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
    10001444  }
     
    10041448  {
    10051449#if MERL_VSP_C0152
     1450#if !MERL_Bi_VSP_D0166
    10061451    if(pcCU->getVSPIndex(uiPartAddr))
    10071452      m_acYuvPred[0].copyPartToPartYuv( rpcYuvPred, uiPartAddr, iWidth, iHeight );
    10081453    else
    10091454#endif
     1455#endif
    10101456      xWeightedPredictionUni( pcCU, &m_acYuvPred[0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred, iPartIdx );
    10111457  }
     
    10201466    {
    10211467#if MERL_VSP_C0152
     1468#if !MERL_Bi_VSP_D0166
    10221469      if(pcCU->getVSPIndex(uiPartAddr))
    10231470        m_acYuvPred[0].copyPartToPartYuv( rpcYuvPred, uiPartAddr, iWidth, iHeight );
    10241471      else
    1025 #endif
     1472        xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
     1473#else
     1474      xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, predDirVSP );
     1475#endif
     1476#else
    10261477      xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
     1478#endif
    10271479    }
    10281480  }
     
    11081560 */
    11091561#if LGE_ILLUCOMP_B0045
    1110 Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag)
    1111 #else
    1112 Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi )
     1562Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag
     1563#if QC_ARP_D0177
     1564    ,
     1565    Int filterType
     1566#endif
     1567    )
     1568#else
     1569Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
     1570#if QC_ARP_D0177
     1571    ,
     1572    Int filterType
     1573#endif
     1574    )
    11131575#endif
    11141576{
     
    11291591  if ( yFrac == 0 )
    11301592  {
    1131     m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi );
     1593    m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi
     1594#if QC_ARP_D0177
     1595    ,
     1596    filterType
     1597#endif
     1598    );
    11321599  }
    11331600  else if ( xFrac == 0 )
    11341601  {
    1135     m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi );
     1602    m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi
     1603#if QC_ARP_D0177
     1604    ,
     1605    filterType
     1606#endif
     1607    );
    11361608  }
    11371609  else
     
    11431615    Int halfFilterSize = ( filterSize >> 1 );
    11441616
    1145     m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false     );
    1146     m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi);   
     1617    m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false     
     1618 #if QC_ARP_D0177
     1619    ,
     1620    filterType
     1621#endif
     1622    );
     1623    m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi
     1624 #if QC_ARP_D0177
     1625    ,
     1626    filterType
     1627#endif
     1628    );   
    11471629  }
    11481630
     
    11851667 */
    11861668#if LGE_ILLUCOMP_B0045
    1187 Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag )
    1188 #else
    1189 Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi )
     1669Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag
     1670#if QC_ARP_D0177
     1671    ,
     1672    Int filterType
     1673#endif   
     1674    )
     1675#else
     1676Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
     1677#if QC_ARP_D0177
     1678  , Int filterType
     1679#endif
     1680  )
    11901681#endif
    11911682{
     
    12151706  if ( yFrac == 0 )
    12161707  {
    1217     m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi);   
    1218     m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi);   
     1708    m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi
     1709#if QC_ARP_D0177
     1710    ,
     1711    filterType
     1712#endif   
     1713    );   
     1714    m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi
     1715#if QC_ARP_D0177
     1716    ,
     1717    filterType
     1718#endif   
     1719    );   
    12191720  }
    12201721  else if ( xFrac == 0 )
    12211722  {
    1222     m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi);   
    1223     m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi);   
     1723    m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi
     1724 #if QC_ARP_D0177
     1725    ,
     1726    filterType
     1727#endif   
     1728    );   
     1729    m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi
     1730 #if QC_ARP_D0177
     1731    ,
     1732    filterType
     1733#endif   
     1734    );   
    12241735  }
    12251736  else
    12261737  {
    1227     m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false);
    1228     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi);
     1738    m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false
     1739#if QC_ARP_D0177
     1740    ,
     1741    filterType
     1742#endif   
     1743    );
     1744    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi
     1745#if QC_ARP_D0177
     1746    ,
     1747    filterType
     1748#endif   
     1749    );
    12291750   
    1230     m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false);
    1231     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi);   
     1751    m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false
     1752#if QC_ARP_D0177
     1753    ,
     1754    filterType
     1755#endif   
     1756    );
     1757    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi
     1758#if QC_ARP_D0177
     1759    ,
     1760    filterType
     1761#endif   
     1762    );   
    12321763  }
    12331764#if LGE_ILLUCOMP_B0045
     
    12741805// refPic: Ref picture. Full picture, with padding
    12751806// posX, posY:     PU position, texture
    1276 // size_x, size_y: PU size
     1807// sizeX, sizeY: PU size
    12771808// partAddr: z-order index
    12781809// mv: disparity vector. derived from neighboring blocks
    12791810//
    12801811// Output: dstPic, PU predictor 64x64
    1281 Void TComPrediction::xPredInterLumaBlkFromDM( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, Int iShiftPrec, TComMv* mv, UInt partAddr,Int posX, Int posY, Int size_x, Int size_y, Bool isDepth, Int vspIdx
    1282                                             , TComYuv *&dstPic )
     1812Void TComPrediction::xPredInterLumaBlkFromDM( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, Int iShiftPrec, TComMv* mv, UInt partAddr,Int posX, Int posY, Int sizeX, Int sizeY, Bool isDepth
     1813#if !MERL_Bi_VSP_D0166
     1814                                            , Int vspIdx
     1815#endif
     1816                                            , TComYuv *&dstPic
     1817#if MERL_Bi_VSP_D0166
     1818                                            , Bool bi
     1819#endif         
     1820                                            )
    12831821{
    12841822  Int widthLuma;
     
    13011839#endif
    13021840
     1841#if MERL_CVSP_D0165
     1842  Int widthDepth  = pPicBaseDepth->getWidth();
     1843  Int heightDepth = pPicBaseDepth->getHeight();
     1844#endif
     1845
    13031846  Int nTxtPerDepthX = widthLuma  / ( pPicBaseDepth->getWidth() );  // texture pixel # per depth pixel
    13041847  Int nTxtPerDepthY = heightLuma / ( pPicBaseDepth->getHeight() );
     
    13071850  Int dstStride = dstPic->getStride();
    13081851  Int depStride =  pPicBaseDepth->getStride();
    1309   Int depthPosX = Clip3(0,   widthLuma - size_x,  (posX/nTxtPerDepthX) + (mv->getHor()>>2));
    1310   Int depthPosY = Clip3(0,   heightLuma- size_y,  (posY/nTxtPerDepthY) + (mv->getVer()>>2));
     1852#if LGE_ROUND_OFFSET_D0135
     1853  Int depthPosX = Clip3(0,   widthLuma - sizeX,  (posX/nTxtPerDepthX) + ((mv->getHor()+2)>>2));
     1854  Int depthPosY = Clip3(0,   heightLuma- sizeY,  (posY/nTxtPerDepthY) + ((mv->getVer()+2)>>2));
     1855#else
     1856  Int depthPosX = Clip3(0,   widthLuma - sizeX,  (posX/nTxtPerDepthX) + (mv->getHor()>>2));
     1857  Int depthPosY = Clip3(0,   heightLuma- sizeY,  (posY/nTxtPerDepthY) + (mv->getVer()>>2));
     1858#endif
    13111859  Pel *ref    = refPic->getLumaAddr() + posX + posY * refStride;
    13121860  Pel *dst    = dstPic->getLumaAddr(partAddr);
     
    13151863#if MERL_VSP_BLOCKSIZE_C0152 != 1
    13161864#if MERL_VSP_BLOCKSIZE_C0152 == 2
    1317   Int  dW = size_x>>1;
    1318   Int  dH = size_y>>1;
     1865  Int  dW = sizeX>>1;
     1866  Int  dH = sizeY>>1;
    13191867#endif
    13201868#if MERL_VSP_BLOCKSIZE_C0152 == 4
    1321   Int  dW = size_x>>2;
    1322   Int  dH = size_y>>2;
     1869  Int  dW = sizeX>>2;
     1870  Int  dH = sizeY>>2;
    13231871#endif
    13241872  {
     
    13421890#endif
    13431891        Int maxV = 0;
     1892#if MTK_DEPTH_TO_DISP_D0138
     1893        for (Int blockj = 0; blockj < MERL_VSP_BLOCKSIZE_C0152; blockj+=(MERL_VSP_BLOCKSIZE_C0152-1))
     1894#else
    13441895        for (Int blockj = 0; blockj < MERL_VSP_BLOCKSIZE_C0152; blockj++)
     1896#endif
    13451897        {
    13461898          Int iX = 0;
     1899#if MTK_DEPTH_TO_DISP_D0138
     1900          for (Int blocki = 0; blocki < MERL_VSP_BLOCKSIZE_C0152; blocki+=(MERL_VSP_BLOCKSIZE_C0152-1))
     1901#else
    13471902          for (Int blocki = 0; blocki < MERL_VSP_BLOCKSIZE_C0152; blocki++)
     1903#endif
    13481904          {
    13491905            if (maxV < depthTmp[iX])
     
    13811937#endif
    13821938 
     1939#if MERL_General_Fix
     1940#if MERL_VSP_BLOCKSIZE_C0152 == 1
     1941#if MERL_CVSP_D0165
     1942  //get LUT based horizontal reference range
     1943  Int range = 0;
     1944  if( sizeX == 4 && sizeY == 8 )
     1945    range = m_iRangeLuma[0];
     1946  else if( sizeX == 8 && sizeY == 4 )
     1947    range = m_iRangeLuma[1];
     1948  else if( sizeX == 8 && sizeY == 8 )
     1949    range = m_iRangeLuma[2];
     1950  else if( sizeX == 8 && sizeY == 16 )
     1951    range = m_iRangeLuma[3];
     1952  else if( sizeX == 16 && sizeY == 8 )
     1953    range = m_iRangeLuma[4];
     1954  else if( sizeX == 16 && sizeY == 16 )
     1955    range = m_iRangeLuma[5];
     1956  else if( sizeX == 16 && sizeY == 32 )
     1957    range = m_iRangeLuma[6];
     1958  else if( sizeX == 32 && sizeY == 16 )
     1959    range = m_iRangeLuma[7];
     1960  else if( sizeX == 32 && sizeY == 32 )
     1961    range = m_iRangeLuma[8];
     1962  else if( sizeX == 32 && sizeY == 64 )
     1963    range = m_iRangeLuma[9];
     1964  else if( sizeX == 64 && sizeY == 32 )
     1965    range = m_iRangeLuma[10];
     1966  else if( sizeX == 64 && sizeY == 64 )
     1967    range = m_iRangeLuma[11];
     1968  else
     1969    assert(0);
     1970
     1971  // The minimum depth value
     1972  Int minRelativePos = 5000;
     1973  Int maxRelativePos = -5000;
     1974
     1975  Pel* depthTemp, *depthInitial=depth;
     1976  for (Int yTxt =0; yTxt<sizeY; yTxt++)
     1977  {
     1978    for (Int xTxt =0; xTxt<sizeX; xTxt++)
     1979    {
     1980      if (depthPosX+xTxt < widthDepth)
     1981        depthTemp = depthInitial + xTxt;
     1982      else
     1983        depthTemp = depthInitial + (widthDepth - depthPosX - 1);
     1984
     1985      Int disparity = pShiftLUT[ *depthTemp ] << iShiftPrec;
     1986      Int disparityInt = disparity >> 2;
     1987
     1988      if( disparity <= 0)
     1989      {
     1990        if (minRelativePos > disparityInt+xTxt)
     1991            minRelativePos = disparityInt+xTxt;
     1992      }
     1993      else
     1994      {
     1995        if (maxRelativePos < disparityInt+xTxt)
     1996            maxRelativePos = disparityInt+xTxt;
     1997      }
     1998    }
     1999    if (depthPosY+yTxt < heightDepth)
     2000      depthInitial = depthInitial + depStride;
     2001  }
     2002
     2003  Int disparity_tmp = pShiftLUT[ *depth ] << iShiftPrec;
     2004  if (disparity_tmp <= 0)
     2005    maxRelativePos = minRelativePos + range -1 ;
     2006  else
     2007    minRelativePos = maxRelativePos - range +1 ;
     2008#endif
     2009#endif
     2010#endif
     2011
    13832012#if MERL_VSP_BLOCKSIZE_C0152 != 1
    13842013  Int yDepth = 0;
    13852014#endif
    1386   for ( Int yTxt = 0; yTxt < size_y; yTxt += nTxtPerDepthY )
    1387   {
    1388     for ( Int xTxt = 0, xDepth = 0; xTxt < size_x; xTxt += nTxtPerDepthX, xDepth++ )
    1389     {
    1390       Pel rep_depth = 0; // to store the depth value used for warping
     2015  for ( Int yTxt = 0; yTxt < sizeY; yTxt += nTxtPerDepthY )
     2016  {
     2017    for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth++ )
     2018    {
     2019      Pel repDepth = 0; // to store the depth value used for warping
    13912020#if MERL_VSP_BLOCKSIZE_C0152 == 1
    1392       rep_depth = depth[xDepth];
     2021      repDepth = depth[xDepth];
    13932022#endif
    13942023#if MERL_VSP_BLOCKSIZE_C0152 == 2
    1395       rep_depth = m_pDepth[(xTxt>>1) + (yTxt>>1)*dW];
     2024      repDepth = m_pDepth[(xTxt>>1) + (yTxt>>1)*dW];
    13962025#endif
    13972026#if MERL_VSP_BLOCKSIZE_C0152 == 4
    1398       rep_depth = m_pDepth[(xTxt>>2) + (yTxt>>2)*dW];
    1399 #endif
    1400 
    1401       assert( rep_depth >= 0 && rep_depth <= 255 );
    1402       Int disparity = pShiftLUT[ rep_depth ] << iShiftPrec;
     2027      repDepth = m_pDepth[(xTxt>>2) + (yTxt>>2)*dW];
     2028#endif
     2029
     2030      assert( repDepth >= 0 && repDepth <= 255 );
     2031      Int disparity = pShiftLUT[ repDepth ] << iShiftPrec;
    14032032      Int refOffset = xTxt + (disparity >> 2);
    14042033      Int xFrac = disparity & 0x3;
     2034#if MERL_CVSP_D0165
     2035      if(refOffset<minRelativePos || refOffset>maxRelativePos)
     2036        xFrac = 0;
     2037      refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);
     2038#endif
    14052039      Int absX  = posX + refOffset;
    14062040
     
    14132047
    14142048      assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 );
     2049#if MERL_Bi_VSP_D0166
     2050      m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi );
     2051#else
    14152052      m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true );
     2053#endif
     2054
    14162055    }
    14172056    ref   += refStride*nTxtPerDepthY;
     
    14212060    yDepth++;
    14222061#endif
    1423   }
    1424 }
    1425 
    1426 Void TComPrediction::xPredInterChromaBlkFromDM ( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, Int iShiftPrec, TComMv*mv, UInt partAddr, Int posX, Int posY, Int size_x, Int size_y, Bool isDepth, Int vspIdx
    1427                                                , TComYuv *&dstPic )
     2062
     2063  }
     2064}
     2065
     2066Void TComPrediction::xPredInterChromaBlkFromDM ( TComPicYuv *refPic, TComPicYuv *pPicBaseDepth, Int* pShiftLUT, Int iShiftPrec, TComMv*mv, UInt partAddr, Int posX, Int posY, Int sizeX, Int sizeY, Bool isDepth
     2067#if !MERL_Bi_VSP_D0166
     2068                                               , Int vspIdx
     2069#endif
     2070                                               , TComYuv *&dstPic
     2071#if MERL_Bi_VSP_D0166
     2072                                               , Bool bi
     2073#endif
     2074                                               )
    14282075{
    14292076  Int refStride = refPic->getCStride();
     
    14582105    nTxtPerDepthX = widthChroma / widthDepth;
    14592106    nDepthPerTxtX = 1;
     2107#if LGE_ROUND_OFFSET_D0135
     2108    depthPosX = posX / nTxtPerDepthX + ((mv->getHor()+2)>>2);        //mv denotes the disparity for VSP
     2109#else
    14602110    depthPosX = posX / nTxtPerDepthX + (mv->getHor()>>2);        //mv denotes the disparity for VSP
     2111#endif
    14612112  }
    14622113  else
     
    14642115    nTxtPerDepthX = 1;
    14652116    nDepthPerTxtX = widthDepth / widthChroma;
     2117#if LGE_ROUND_OFFSET_D0135
     2118    depthPosX = posX * nDepthPerTxtX + ((mv->getHor()+2)>>2);        //mv denotes the disparity for VSP
     2119#else
    14662120    depthPosX = posX * nDepthPerTxtX + (mv->getHor()>>2);        //mv denotes the disparity for VSP
    1467   }
    1468   depthPosX = Clip3(0, widthDepth - (size_x<<1), depthPosX);
     2121#endif
     2122  }
     2123  depthPosX = Clip3(0, widthDepth - (sizeX<<1), depthPosX);
    14692124  if ( heightChroma > heightDepth )
    14702125  {
    14712126    nTxtPerDepthY = heightChroma / heightDepth;
    14722127    nDepthPerTxtY = 1;
     2128#if LGE_ROUND_OFFSET_D0135
     2129    depthPosY = posY / nTxtPerDepthY + ((mv->getVer()+2)>>2);     //mv denotes the disparity for VSP
     2130#else
    14732131    depthPosY = posY / nTxtPerDepthY + (mv->getVer()>>2);     //mv denotes the disparity for VSP
     2132#endif
    14742133  }
    14752134  else
     
    14772136    nTxtPerDepthY = 1;
    14782137    nDepthPerTxtY = heightDepth / heightChroma;
     2138#if LGE_ROUND_OFFSET_D0135
     2139    depthPosY = posY * nDepthPerTxtY + ((mv->getVer()+2)>>2);     //mv denotes the disparity for VSP
     2140#else
    14792141    depthPosY = posY * nDepthPerTxtY + (mv->getVer()>>2);     //mv denotes the disparity for VSP
    1480   }
    1481   depthPosY = Clip3(0, heightDepth - (size_y<<1), depthPosY);
     2142#endif
     2143  }
     2144  depthPosY = Clip3(0, heightDepth - (sizeY<<1), depthPosY);
    14822145
    14832146  Pel *refCb  = refPic->getCbAddr() + posX + posY * refStride;
     
    14912154  Int depStrideBlock = depStride * nDepthPerTxtY;
    14922155
     2156#if !MERL_Bi_VSP_D0166
    14932157  if (isDepth)
    14942158  {
    14952159     // DT: Since the call for this function is redundant, ..
    1496      for (Int y = 0; y < size_y; y++)
     2160     for (Int y = 0; y < sizeY; y++)
    14972161     {
    1498        for (Int x = 0; x < size_x; x++)
     2162       for (Int x = 0; x < sizeX; x++)
    14992163       {
    15002164         dstCb[x] = 128;
     
    15062170     return;
    15072171  }
    1508  
     2172#endif
     2173
    15092174  if ( widthChroma > widthDepth ) // We assume
    15102175  {
     
    15162181  {
    15172182#if MERL_VSP_BLOCKSIZE_C0152 == 1
    1518   Int  dW = size_x;
    1519   Int  dH = size_y;
     2183  Int  dW = sizeX;
     2184  Int  dH = sizeY;
    15202185  Int  sW = 2; // search window size
    15212186  Int  sH = 2;
    15222187#endif
    15232188#if MERL_VSP_BLOCKSIZE_C0152 == 2
    1524   Int  dW = size_x;
    1525   Int  dH = size_y;
     2189  Int  dW = sizeX;
     2190  Int  dH = sizeY;
    15262191  Int  sW = 2; // search window size
    15272192  Int  sH = 2;
    15282193#endif
    15292194#if MERL_VSP_BLOCKSIZE_C0152 == 4
    1530   Int  dW = size_x>>1;
    1531   Int  dH = size_y>>1;
     2195  Int  dW = sizeX>>1;
     2196  Int  dH = sizeY>>1;
    15322197  Int  sW = 4; // search window size
    15332198  Int  sH = 4;
     
    15942259
    15952260
    1596     // (size_x, size_y) is Chroma block size
    1597     for ( Int yTxt = 0, yDepth = 0; yTxt < size_y; yTxt += nTxtPerDepthY, yDepth += nDepthPerTxtY )
    1598     {
    1599       for ( Int xTxt = 0, xDepth = 0; xTxt < size_x; xTxt += nTxtPerDepthX, xDepth += nDepthPerTxtX )
    1600       {
    1601         Pel rep_depth = 0; // to store the depth value used for warping
     2261#if MERL_General_Fix
    16022262#if MERL_VSP_BLOCKSIZE_C0152 == 1
    1603         rep_depth = m_pDepth[(xTxt) + (yTxt)*dW];
     2263#if MERL_CVSP_D0165
     2264  //get LUT based horizontal reference range
     2265  Int range=0;
     2266  if( sizeX == 2 && sizeY == 4 )
     2267    range = m_iRangeChroma[0];
     2268  else if( sizeX == 4 && sizeY == 2 )
     2269    range = m_iRangeChroma[1];
     2270  else if( sizeX == 4 && sizeY == 4 )
     2271    range = m_iRangeChroma[2];
     2272  else if( sizeX == 4 && sizeY == 8 )
     2273    range = m_iRangeChroma[3];
     2274  else if( sizeX == 8 && sizeY == 4 )
     2275    range = m_iRangeChroma[4];
     2276  else if( sizeX == 8 && sizeY == 8 )
     2277    range = m_iRangeChroma[5];
     2278  else if( sizeX == 8 && sizeY == 16 )
     2279    range = m_iRangeChroma[6];
     2280  else if( sizeX == 16 && sizeY == 8 )
     2281    range = m_iRangeChroma[7];
     2282  else if( sizeX == 16 && sizeY == 16 )
     2283    range = m_iRangeChroma[8];
     2284  else if( sizeX == 16 && sizeY == 32 )
     2285    range = m_iRangeChroma[9];
     2286  else if( sizeX == 32 && sizeY == 16 )
     2287    range = m_iRangeChroma[10];
     2288  else if( sizeX == 32 && sizeY == 32 )
     2289    range = m_iRangeChroma[11];
     2290  else
     2291    assert(0);
     2292 
     2293  // The minimum depth value
     2294  Int minRelativePos = 5000;
     2295  Int maxRelativePos = -5000;
     2296
     2297  Int depthTmp;
     2298  for (Int yTxt=0; yTxt<sizeY; yTxt++)
     2299  {
     2300    for (Int xTxt=0; xTxt<sizeX; xTxt++)
     2301    {
     2302      depthTmp = m_pDepth[xTxt+yTxt*dW];
     2303      Int disparity = pShiftLUT[ depthTmp ] << iShiftPrec;
     2304      Int disparityInt = disparity >> 3;//in chroma resolution
     2305
     2306      if (disparityInt < 0)
     2307      {
     2308        if (minRelativePos > disparityInt+xTxt)
     2309            minRelativePos = disparityInt+xTxt;
     2310      }
     2311      else
     2312      {
     2313        if (maxRelativePos < disparityInt+xTxt)
     2314            maxRelativePos = disparityInt+xTxt;
     2315      }
     2316    }
     2317  }
     2318
     2319  depthTmp = m_pDepth[0];
     2320  Int disparity_tmp = pShiftLUT[ depthTmp ] << iShiftPrec;
     2321  if ( disparity_tmp < 0 )
     2322    maxRelativePos = minRelativePos + range - 1;
     2323  else
     2324    minRelativePos = maxRelativePos - range + 1;
     2325
     2326#endif
     2327#endif
     2328#endif
     2329
     2330    // (sizeX, sizeY) is Chroma block size
     2331    for ( Int yTxt = 0, yDepth = 0; yTxt < sizeY; yTxt += nTxtPerDepthY, yDepth += nDepthPerTxtY )
     2332    {
     2333      for ( Int xTxt = 0, xDepth = 0; xTxt < sizeX; xTxt += nTxtPerDepthX, xDepth += nDepthPerTxtX )
     2334      {
     2335        Pel repDepth = 0; // to store the depth value used for warping
     2336#if MERL_VSP_BLOCKSIZE_C0152 == 1
     2337        repDepth = m_pDepth[(xTxt) + (yTxt)*dW];
    16042338#endif
    16052339#if MERL_VSP_BLOCKSIZE_C0152 == 2
    1606         rep_depth = m_pDepth[(xTxt) + (yTxt)*dW];
     2340        repDepth = m_pDepth[(xTxt) + (yTxt)*dW];
    16072341#endif
    16082342#if MERL_VSP_BLOCKSIZE_C0152 == 4
    1609         rep_depth = m_pDepth[(xTxt>>1) + (yTxt>>1)*dW];
     2343        repDepth = m_pDepth[(xTxt>>1) + (yTxt>>1)*dW];
    16102344#endif
    16112345
    16122346      // calculate the offset in the reference picture
    1613         Int disparity = pShiftLUT[ rep_depth ] << iShiftPrec;
     2347        Int disparity = pShiftLUT[ repDepth ] << iShiftPrec;
    16142348        Int refOffset = xTxt + (disparity >> 3); // in integer pixel in chroma image
    16152349        Int xFrac = disparity & 0x7;
     2350#if MERL_CVSP_D0165
     2351        if(refOffset < minRelativePos || refOffset > maxRelativePos)
     2352          xFrac = 0;
     2353        refOffset = Clip3(minRelativePos, maxRelativePos, refOffset);
     2354#endif
    16162355        Int absX  = posX + refOffset;
    16172356
     
    16252364        assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 );
    16262365        assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 );
     2366#if MERL_Bi_VSP_D0166
     2367        m_if.filterHorChroma(&refCb[refOffset], refStride, &dstCb[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi);
     2368        m_if.filterHorChroma(&refCr[refOffset], refStride, &dstCr[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, !bi);
     2369#else
    16272370        m_if.filterHorChroma(&refCb[refOffset], refStride, &dstCb[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true);
    16282371        m_if.filterHorChroma(&refCr[refOffset], refStride, &dstCr[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true);
     2372#endif
     2373
    16292374      }
    16302375      refCb += refStrideBlock;
     
    16352380    }
    16362381  }
     2382
    16372383}
    16382384
     
    16422388Void TComPrediction::xWeightedAveragePdm( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst, UInt uiSubSampExpX, UInt uiSubSampExpY )
    16432389{
     2390
    16442391  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
    16452392  {
     
    16612408#endif
    16622409
    1663 Void TComPrediction::xWeightedAverage( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst )
    1664 {
     2410Void TComPrediction::xWeightedAverage( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst
     2411#if MERL_Bi_VSP_D0166
     2412                                 , Int predDirVSP
     2413#endif
     2414  )
     2415{
     2416#if MERL_Bi_VSP_D0166
     2417  Bool isVSP = 0;
     2418  if (pcCU->getVSPIndex(uiPartIdx)!=0)//is VSP
     2419  {
     2420    isVSP = 1;
     2421  }
     2422
     2423  if(( !isVSP && iRefIdx0 >= 0 && iRefIdx1 >= 0 ) || ( isVSP && predDirVSP == 3 ))
     2424#else
    16652425  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
     2426#endif
    16662427  {
    16672428    rpcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight );
    16682429  }
     2430#if MERL_Bi_VSP_D0166
     2431  else if ( ( !isVSP && iRefIdx0 >= 0 && iRefIdx1 <  0 ) || ( isVSP && predDirVSP == 1))
     2432#else
    16692433  else if ( iRefIdx0 >= 0 && iRefIdx1 <  0 )
     2434#endif
    16702435  {
    16712436    pcYuvSrc0->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight );
    16722437  }
     2438#if MERL_Bi_VSP_D0166
     2439  else if (( !isVSP && iRefIdx0 <  0 && iRefIdx1 >= 0 ) || ( isVSP && predDirVSP == 2))
     2440#else
    16732441  else if ( iRefIdx0 <  0 && iRefIdx1 >= 0 )
     2442#endif
    16742443  {
    16752444    pcYuvSrc1->copyPartToPartYuv( rpcYuvDst, uiPartIdx, iWidth, iHeight );
    16762445  }
     2446#if MERL_Bi_VSP_D0166
     2447  else
     2448  {//for debug test only
     2449    assert(0);
     2450  }
     2451#endif
    16772452}
    16782453
     
    20762851  iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]];
    20772852  iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]];
     2853#if LGE_ROUND_OFFSET_D0135
     2854  iRefX   = iCUPelX + ((pMv->getHor()+2) >> 2);
     2855  iRefY   = iCUPelY + ((pMv->getVer()+2) >> 2);
     2856#else
    20782857  iRefX   = iCUPelX + (pMv->getHor() >> 2);
    20792858  iRefY   = iCUPelY + (pMv->getVer() >> 2);
     2859#endif
    20802860  uiWidth = pcCU->getWidth(0);
    20812861  uiHeight = pcCU->getHeight(0);
     
    20892869  if(pcCU->getPUAbove(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelY > 0 && iRefY > 0)
    20902870  {
     2871#if LGE_ROUND_OFFSET_D0135
     2872    iRefOffset = ( (pMv->getHor()+2) >> 2 ) + ( (pMv->getVer()+2) >> 2 ) * iRefStride - iRefStride;
     2873#else
    20912874    iRefOffset = ( pMv->getHor() >> 2 ) + ( pMv->getVer() >> 2 ) * iRefStride - iRefStride;
     2875#endif
    20922876    pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    20932877    pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride;
     
    21062890  if(pcCU->getPULeft(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelX > 0 && iRefX > 0)
    21072891  {
     2892#if LGE_ROUND_OFFSET_D0135
     2893    iRefOffset = ( (pMv->getHor()+2) >> 2 ) + ( (pMv->getVer()+2) >> 2 ) * iRefStride - 1;
     2894#else
    21082895    iRefOffset = ( pMv->getHor() >> 2 ) + ( pMv->getVer() >> 2 ) * iRefStride - 1;
     2896#endif
    21092897    pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    21102898    pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1;
     
    22243012  iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]];
    22253013  iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]];
     3014#if LGE_ROUND_OFFSET_D0135
     3015  iRefX   = iCUPelX + ((pMv->getHor()+2) >> 2);
     3016  iRefY   = iCUPelY + ((pMv->getVer()+2) >> 2);
     3017#else
    22263018  iRefX   = iCUPelX + (pMv->getHor() >> 2);
    22273019  iRefY   = iCUPelY + (pMv->getVer() >> 2);
     3020#endif
    22283021  uiWidth = pcCU->getWidth(0) >> 1;
    22293022  uiHeight = pcCU->getHeight(0) >> 1;
     
    22373030  if(pcCU->getPUAbove(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelY > 0 && iRefY > 0)
    22383031  {
     3032#if LGE_ROUND_OFFSET_D0135
     3033    iRefOffset = ( (pMv->getHor()+4) >> 3 ) + ( (pMv->getVer()+4) >> 3 ) * iRefStride - iRefStride;
     3034#else
    22393035    iRefOffset = ( pMv->getHor() >> 3 ) + ( pMv->getVer() >> 3 ) * iRefStride - iRefStride;
     3036#endif
    22403037    if (iChromaId == 0) // Cb
    22413038    {
     
    22623059  if(pcCU->getPULeft(uiTmpPartIdx, pcCU->getZorderIdxInCU()) && iCUPelX > 0 && iRefX > 0)
    22633060  {
     3061#if LGE_ROUND_OFFSET_D0135
     3062    iRefOffset = ( (pMv->getHor()+4) >> 3 ) + ( (pMv->getVer()+4) >> 3 ) * iRefStride - 1;
     3063#else
    22643064    iRefOffset = ( pMv->getHor() >> 3 ) + ( pMv->getVer() >> 3 ) * iRefStride - 1;
     3065#endif
    22653066    if (iChromaId == 0) // Cb
    22663067    {
     
    24263227}
    24273228
     3229#if QC_DC_PREDICTOR_D0183
     3230Void TComPrediction::getPredDCs( Bool* pbPattern, Int iStride, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2 )
     3231{
     3232  Int  iDC1, iDC2;
     3233  const Int  iTR = (   iStride - 1        ) - iMaskStride;
     3234  const Int  iTM = ( ( iStride - 1 ) >> 1 ) - iMaskStride;
     3235  const Int  iLB = (   iStride - 1        ) * iMaskStride - 1;
     3236  const Int  iLM = ( ( iStride - 1 ) >> 1 ) * iMaskStride - 1;
     3237  const UInt uiBitDepth = g_uiBitDepth + g_uiBitIncrement;
     3238
     3239  Bool bL = ( pbPattern[0] != pbPattern[(iStride-1)*iStride] );
     3240  Bool bT = ( pbPattern[0] != pbPattern[(iStride-1)]         );
     3241
     3242  if( bL == bT )
     3243  {
     3244    iDC1 = bL ? ( piMask[iTR] + piMask[iLB] )>>1 : 1<<( uiBitDepth - 1 );
     3245    iDC2 =      ( piMask[ -1] + piMask[-iMaskStride] )>>1;
     3246  }
     3247  else
     3248  {
     3249    iDC1 = bL ? piMask[iLB] : piMask[iTR];
     3250    iDC2 = bL ? piMask[iTM] : piMask[iLM];
     3251  }
     3252
     3253  riPredDC1 = pbPattern[0] ? iDC1 : iDC2;
     3254  riPredDC2 = pbPattern[0] ? iDC2 : iDC1;
     3255}
     3256#else
    24283257Void TComPrediction::getWedgePredDCs( TComWedgelet* pcWedgelet, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2, Bool bAbove, Bool bLeft )
    24293258{
     
    25033332  }
    25043333}
     3334#endif
    25053335
    25063336Void TComPrediction::calcWedgeDCs( TComWedgelet* pcWedgelet, Pel* piOrig, UInt uiStride, Int& riDC1, Int& riDC2 )
     
    28703700  Int iMaskStride = ( iWidth<<1 ) + 1;
    28713701  piMask += iMaskStride+1;
     3702#if QC_DC_PREDICTOR_D0183
     3703  getPredDCs( pcWedgelet->getPattern(), pcWedgelet->getStride(), piMask, iMaskStride, iPredDC1, iPredDC2 );
     3704#else
    28723705  getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
     3706#endif
    28733707
    28743708  // assign wedge pred DCs to prediction
    2875   if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
    2876   else         { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride,        iPredDC1,                   iPredDC2           ); }
     3709  if( bDelta )
     3710  {
     3711#if HHI_DELTADC_DLT_D0035
     3712    assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, GetIdx2DepthValue( GetDepthValue2Idx(iPredDC1) + iDeltaDC1 ), GetIdx2DepthValue( GetDepthValue2Idx(iPredDC2) + iDeltaDC2 ) );
     3713#else
     3714    assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) );
     3715#endif
     3716  }
     3717  else
     3718  {
     3719    assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 );
     3720  }
    28773721}
    28783722
     
    28893733  Int iMaskStride = ( iWidth<<1 ) + 1;
    28903734  piMask += iMaskStride+1;
     3735#if QC_DC_PREDICTOR_D0183
     3736  getPredDCs( pcContourWedge->getPattern(), pcContourWedge->getStride(), piMask, iMaskStride, iPredDC1, iPredDC2 );
     3737#else
    28913738  getWedgePredDCs( pcContourWedge, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
     3739#endif
    28923740
    28933741  // assign wedge pred DCs to prediction
    2894   if( bDelta ) { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
    2895   else         { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride,        iPredDC1,                   iPredDC2           ); }
     3742  if( bDelta )
     3743  {
     3744#if HHI_DELTADC_DLT_D0035
     3745    assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, GetIdx2DepthValue( GetDepthValue2Idx(iPredDC1) + iDeltaDC1 ), GetIdx2DepthValue( GetDepthValue2Idx(iPredDC2) + iDeltaDC2 ) );
     3746#else
     3747    assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) );
     3748#endif
     3749  }
     3750  else
     3751  {
     3752    assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, iPredDC1, iPredDC2 );
     3753  }
    28963754
    28973755  pcContourWedge->destroy();
     
    30643922  Int iMaskStride = ( iWidth<<1 ) + 1;
    30653923  piMask += iMaskStride+1;
     3924#if QC_DC_PREDICTOR_D0183
     3925  getPredDCs( pcWedgelet->getPattern(), pcWedgelet->getStride(), piMask, iMaskStride, iPredDC1, iPredDC2 );
     3926#else
    30663927  getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
     3928#endif
    30673929
    30683930  // assign wedge pred DCs to prediction
    3069   if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
    3070   else         { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1,           iPredDC2           ); }
     3931  if( bDelta )
     3932  {
     3933#if HHI_DELTADC_DLT_D0035
     3934    assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, GetIdx2DepthValue( GetDepthValue2Idx(iPredDC1) + iDeltaDC1 ), GetIdx2DepthValue( GetDepthValue2Idx(iPredDC2) + iDeltaDC2 ) );
     3935#else
     3936    assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) );
     3937#endif
     3938  }
     3939  else
     3940  {
     3941    assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 );
     3942  }
    30713943}
    30723944
     
    30993971  Int iMaskStride = ( iWidth<<1 ) + 1;
    31003972  piMask += iMaskStride+1;
     3973#if QC_DC_PREDICTOR_D0183
     3974  getPredDCs( pcWedgelet->getPattern(), pcWedgelet->getStride(), piMask, iMaskStride, iPredDC1, iPredDC2 );
     3975#else
    31013976  getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
     3977#endif
    31023978
    31033979  // assign wedge pred DCs to prediction
    3104   if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
    3105   else         { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride,       iPredDC1,                   iPredDC2             ); }
     3980  if( bDelta )
     3981  {
     3982#if HHI_DELTADC_DLT_D0035
     3983    assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, GetIdx2DepthValue( GetDepthValue2Idx(iPredDC1) + iDeltaDC1 ), GetIdx2DepthValue( GetDepthValue2Idx(iPredDC2) + iDeltaDC2 ) );
     3984#else
     3985    assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) );
     3986#endif
     3987  }
     3988  else
     3989  {
     3990    assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1, iPredDC2 );
     3991  }
    31063992}
    31073993
Note: See TracChangeset for help on using the changeset viewer.