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


Ignore:
Timestamp:
20 Feb 2013, 22:07:43 (11 years ago)
Author:
tech
Message:

Reintegrated branch 5.1-dev0 rev. 295.

File:
1 edited

Legend:

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

    r210 r296  
    5454{
    5555  m_piYuvExt = NULL;
     56#if MERL_VSP_C0152
     57  m_pDepth = (Int*) malloc(64*64*sizeof(Int)); // TODO: Use a smart way to determine the size of the array
     58  if (m_pDepth == NULL)
     59  {
     60      printf("ERROR: UKTGHU, No memory allocated.\n");
     61  }
     62#endif
    5663}
    5764
     
    5966{
    6067 
     68#if MERL_VSP_C0152
     69  if (m_pDepth != NULL)
     70  {
     71      free(m_pDepth);
     72  }
     73#endif
    6174  delete[] m_piYuvExt;
    6275
     
    190203
    191204  // Map the mode index to main prediction direction and angle
    192 #if LOGI_INTRA_NAME_3MPM
    193205  assert( dirMode > 0 ); //no planar
    194206  Bool modeDC        = dirMode < 2;
     
    196208  Bool modeVer       = !modeDC && !modeHor;
    197209  Int intraPredAngle = modeVer ? (Int)dirMode - VER_IDX : modeHor ? -((Int)dirMode - HOR_IDX) : 0;
    198 #else
    199   Bool modeDC        = dirMode == 0;
    200   Bool modeVer       = !modeDC && (dirMode < 18);
    201   Bool modeHor       = !modeDC && !modeVer;
    202   Int intraPredAngle = modeVer ? dirMode - 9 : modeHor ? dirMode - 25 : 0;
    203 #endif
    204210  Int absAng         = abs(intraPredAngle);
    205211  Int signAng        = intraPredAngle < 0 ? -1 : 1;
     
    284290        for (k=0;k<blkSize;k++)
    285291        {
    286 #if REMOVE_DIV_OPERATION
    287292          pDst[k*dstStride] = Clip ( pDst[k*dstStride] + (( refSide[k+1] - refSide[0] ) >> 1) );
    288 #else
    289           pDst[k*dstStride] = Clip ( pDst[k*dstStride] + ( refSide[k+1] - refSide[0] ) / 2 );
    290 #endif
    291293        }
    292294      }
     
    363365  else
    364366  {
    365 #if LOGI_INTRA_NAME_3MPM
    366367    xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, true );
    367 #else
    368     xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, g_aucAngIntraModeOrder[ uiDirMode ], bAbove, bLeft, true );
    369 #endif
    370368
    371369    if( (uiDirMode == DC_IDX ) && bAbove && bLeft )
     
    392390  {
    393391    // Create the prediction
    394 #if LOGI_INTRA_NAME_3MPM
    395392    xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode, bAbove, bLeft, false );
    396 #else
    397     xPredIntraAng( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, g_aucAngIntraModeOrder[ uiDirMode ], bAbove, bLeft, false );
    398 #endif
    399393  }
    400394}
     
    605599
    606600#if DEPTH_MAP_GENERATION
     601#if MERL_VSP_C0152
     602Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, UInt uiAbsPartIdx, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )
     603#else
    607604Void TComPrediction::motionCompensation( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY )
     605#endif
     606#else
     607#if MERL_VSP_C0152
     608Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, UInt uiAbsPartIdx, RefPicList eRefPicList, Int iPartIdx )
    608609#else
    609610Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
     611#endif
    610612#endif
    611613{
     
    635637      {
    636638#if DEPTH_MAP_GENERATION
     639#if MERL_VSP_C0152
     640        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     641#else
    637642        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     643#endif
     644#else
     645#if MERL_VSP_C0152
     646        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, true );
    638647#else
    639648        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, true );
    640649#endif
     650#endif
    641651      }
    642652      else
    643653      {
    644654#if DEPTH_MAP_GENERATION
     655#if MERL_VSP_C0152
     656        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     657#else       
    645658        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     659#endif
     660#else
     661#if MERL_VSP_C0152
     662        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false );
    646663#else
    647664        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false );
     665#endif
    648666#endif
    649667      }
     
    666684      {
    667685#if DEPTH_MAP_GENERATION
     686#if MERL_VSP_C0152
     687        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     688#else
    668689        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     690#endif
     691#else
     692#if MERL_VSP_C0152
     693        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, false );
    669694#else
    670695        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, false );
    671696#endif
     697#endif
    672698      }
    673699      else
    674700      {
    675701#if DEPTH_MAP_GENERATION
     702#if MERL_VSP_C0152
     703        xPredInterBi  (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
     704#else
    676705        xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
     706#endif
     707#else
     708#if MERL_VSP_C0152
     709        xPredInterBi  (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx );
    677710#else
    678711        xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx );
     712#endif
    679713#endif
    680714      }
     
    704738      {
    705739#if DEPTH_MAP_GENERATION
     740#if MERL_VSP_C0152
     741        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     742#else
    706743        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     744#endif
     745#else
     746#if MERL_VSP_C0152
     747        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, true );
    707748#else
    708749        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, true );
    709 #endif   
    710       }
    711       else
    712       {
     750#endif
     751#endif
     752  }
     753  else
     754  {
    713755#if DEPTH_MAP_GENERATION
     756#if MERL_VSP_C0152
     757        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     758#else
    714759        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     760#endif
     761#else
     762#if MERL_VSP_C0152
     763        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false );
    715764#else
    716765        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false );
    717 #endif   
     766#endif
     767#endif
    718768      }
    719769#if DEPTH_MAP_GENERATION
     770#if MERL_VSP_C0152
     771      xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     772#else
    720773      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     774#endif
     775#else
     776#if MERL_VSP_C0152
     777      xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false );
    721778#else
    722779      xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, iPartIdx, false );
    723 #endif 
     780#endif
     781#endif
    724782#if LGE_ILLUCOMP_B0045
    725783      if( pcCU->getSlice()->getPPS()->getUseWP() && !pcCU->getICFlag(uiPartAddr))
    726784#else
    727       if ( pcCU->getSlice()->getPPS()->getUseWP() )
     785      if( pcCU->getSlice()->getPPS()->getUseWP())
    728786#endif
    729787      {
     
    736794      {
    737795#if DEPTH_MAP_GENERATION
     796#if MERL_VSP_C0152
     797        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     798#else
    738799        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     800#endif
     801#else
     802#if MERL_VSP_C0152
     803        xPredInterUni (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, false );
    739804#else
    740805        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred, iPartIdx, false );
     806#endif
     807#endif   
     808      }
     809      else
     810      {
     811#if DEPTH_MAP_GENERATION
     812#if MERL_VSP_C0152
     813        xPredInterBi  (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
     814#else
     815        xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
     816#endif   
     817#else
     818#if MERL_VSP_C0152
     819        xPredInterBi  (pcCU, uiPartAddr, uiAbsPartIdx+uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx );
     820#else
     821        xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx );
    741822#endif
    742       }
    743       else
    744       {
     823#endif
     824      }
     825    }
     826  }
     827  return;
     828}
     829
     830#if MTK_MDIVRP_C0138
     831Void TComPrediction::residualPrediction(TComDataCU* pcCU, TComYuv* pcYuvPred, TComYuv* pcYuvResPred)
     832{
     833  Int         iWidth;
     834  Int         iHeight;
     835  UInt        uiPartAddr;
     836
     837  pcCU->getPartIndexAndSize( 0, uiPartAddr, iWidth, iHeight );
     838
     839  Bool bResAvail = false;
     840
     841  bResAvail = pcCU->getResidualSamples( 0, true, pcYuvResPred );
     842
     843  assert (bResAvail);
     844
     845  pcYuvPred->add(pcYuvResPred, iWidth, iHeight);
     846}
     847#endif
     848
    745849#if DEPTH_MAP_GENERATION
    746         xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, uiSubSampExpX, uiSubSampExpY, pcYuvPred, iPartIdx, bPrdDepthMap );
    747 #else
    748         xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred, iPartIdx );
    749 #endif
    750       }
    751     }
    752   }
    753   return;
    754 }
    755 
    756 
    757 
    758 #if DEPTH_MAP_GENERATION
     850#if MERL_VSP_C0152
     851Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi )
     852#else
    759853Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY, Bool bi )
     854#endif
     855#else
     856#if MERL_VSP_C0152
     857Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi )
    760858#else
    761859Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi )
    762860#endif
    763 {
     861#endif
     862{
     863#if MERL_VSP_C0152
     864  Int  iRefIdx = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );   
     865  Int  vspIdx  = pcCU->getVSPIndex(uiPartAddr);
     866  if (vspIdx != 0)
     867  {
     868    if (iRefIdx >= 0)
     869    {
     870      printf("vspIdx = %d, iRefIdx = %d\n", vspIdx, iRefIdx);
     871    }
     872    assert (iRefIdx < 0); // assert (iRefIdx == NOT_VALID);
     873  }
     874  else
     875  {
     876    assert (iRefIdx >= 0);
     877  }
     878#else
    764879  Int         iRefIdx     = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           assert (iRefIdx >= 0);
    765   TComMv      cMv         = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
     880#endif
     881
     882  TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
    766883  pcCU->clipMv(cMv);
    767884
     
    784901  if( pcCU->getSlice()->getSPS()->isDepth() )
    785902  {
    786     UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 );
    787     UInt uiOffset = bi ? IF_INTERNAL_OFFS : 0;
     903#if MERL_VSP_C0152
     904    if (vspIdx != 0)
     905    { // depth, vsp
     906      // get depth estimator here
     907      TComPic* pRefPicBaseDepth = pcCU->getSlice()->getRefPicBaseDepth();
     908      TComPicYuv* pcBaseViewDepthPicYuv = NULL;
     909      if (vspIdx < 4) // spatial
     910      {
     911        pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec();
     912      }
     913      Int iBlkX = ( pcCU->getAddr() % pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     914      Int iBlkY = ( pcCU->getAddr() / pRefPicBaseDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     915      Int* pShiftLUT;
     916      Int iShiftPrec;
     917      pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec);
     918      //using disparity to find the depth block of the base view as the depth block estimator of the current block
     919      //using depth block estimator and base view texture to get Backward warping
     920      xPredInterLumaBlkFromDM  ( pcBaseViewDepthPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX,    iBlkY,    iWidth,    iHeight,     pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     921      xPredInterChromaBlkFromDM( pcBaseViewDepthPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1,  pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     922    }
     923    else
     924    {
     925#endif
     926      UInt uiRShift = ( bi ? 14-g_uiBitDepth-g_uiBitIncrement : 0 );
     927      UInt uiOffset = bi ? IF_INTERNAL_OFFS : 0;
     928#if LGE_ILLUCOMP_DEPTH_C0046
     929    Bool bICFlag = pcCU->getICFlag(uiPartAddr) && (pcCU->getSlice()->getRefViewId( eRefPicList, iRefIdx ) != pcCU->getSlice()->getViewId());
     930#endif
    788931#if DEPTH_MAP_GENERATION
    789     xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, 0, 0, rpcYuvPred, uiRShift, uiOffset );
    790 #else
    791     xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, uiOffset );
    792 #endif
     932    xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, 0, 0, rpcYuvPred, uiRShift, uiOffset
     933#if LGE_ILLUCOMP_DEPTH_C0046
     934        , bICFlag
     935#endif
     936        );
     937#else
     938      xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, uiOffset );
     939#endif
     940#if MERL_VSP_C0152
     941    }
     942#endif// MERL_VSP_C0152 //else
    793943  }
    794944  else
    795945  {
    796946#endif
     947#if MERL_VSP_C0152
     948    if ( vspIdx != 0 )
     949    { // texture, vsp
     950      TComPic*    pRefPicBaseTxt        = pcCU->getSlice()->getRefPicBaseTxt();
     951      TComPicYuv* pcBaseViewTxtPicYuv   = pRefPicBaseTxt->getPicYuvRec();
     952      TComPicYuv* pcBaseViewDepthPicYuv = NULL;
     953      if (vspIdx < 4) // spatial
     954      {
     955        TComPic* pRefPicBaseDepth = pcCU->getSlice()->getRefPicBaseDepth();
     956        pcBaseViewDepthPicYuv     = pRefPicBaseDepth->getPicYuvRec();
     957      }
     958      Int iBlkX = ( pcCU->getAddr() % pRefPicBaseTxt->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     959      Int iBlkY = ( pcCU->getAddr() / pRefPicBaseTxt->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartIdx ] ];
     960      Int* pShiftLUT;
     961      Int iShiftPrec;
     962      pcCU->getSlice()->getBWVSPLUTParam(pShiftLUT, iShiftPrec);
     963
     964      //using disparity to find the depth block of the base view as the depth block estimator of the current block
     965      //using depth block estimator and base view texture to get Backward warping
     966      xPredInterLumaBlkFromDM  ( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX,    iBlkY,    iWidth,    iHeight,    pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     967      xPredInterChromaBlkFromDM( pcBaseViewTxtPicYuv, pcBaseViewDepthPicYuv, pShiftLUT, iShiftPrec, &cMv, uiPartAddr, iBlkX>>1, iBlkY>>1, iWidth>>1, iHeight>>1, pcCU->getSlice()->getSPS()->isDepth(), vspIdx, rpcYuvPred );
     968    }
     969    else//texture not VSP
     970    {
     971#endif //MERL_VSP_C0152
    797972#if LGE_ILLUCOMP_B0045
    798     Bool bICFlag = pcCU->getICFlag(uiPartAddr) && (pcCU->getSlice()->getRefViewId( eRefPicList, iRefIdx ) != pcCU->getSlice()->getViewId());
    799 
    800     xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, bICFlag);
    801 #else
    802   xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi );
    803 #endif
     973      Bool bICFlag = pcCU->getICFlag(uiPartAddr) && (pcCU->getSlice()->getRefViewId( eRefPicList, iRefIdx ) != pcCU->getSlice()->getViewId());
     974
     975      xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi, bICFlag);
     976#else
     977      xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi );
     978#endif
     979#if MERL_VSP_C0152
     980     } //texture not VSP
     981#endif
    804982#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
    805983  }
     984#endif
     985
     986#if MERL_VSP_C0152
     987  if ( vspIdx == 0 )//Not VSP
     988  {
    806989#endif
    807990#if LGE_ILLUCOMP_B0045
     
    812995  xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi );
    813996#endif
     997#if MERL_VSP_C0152
     998   }
     999#endif
    8141000}
    8151001
    8161002
    8171003#if DEPTH_MAP_GENERATION
     1004#if MERL_VSP_C0152
     1005Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
     1006#else
    8181007Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
     1008#endif
     1009#else
     1010#if MERL_VSP_C0152
     1011Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, UInt uiAbsPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx )
    8191012#else
    8201013Void TComPrediction::xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx )
     1014#endif
    8211015#endif
    8221016{
     
    8291023    iRefIdx[iRefList] = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );
    8301024
     1025#if MERL_VSP_C0152
     1026    if(!pcCU->getVSPIndex(uiPartAddr))
     1027    {
     1028      if ( iRefIdx[iRefList] < 0 )
     1029      {
     1030        continue;
     1031      }
     1032    }
     1033    else
     1034    {
     1035      if ( iRefList== REF_PIC_LIST_1 && iRefIdx[iRefList] < 0 ) // iRefIdx[iRefList] ==NOT_VALID
     1036      {
     1037        continue;
     1038      }
     1039    }
     1040#else
    8311041    if ( iRefIdx[iRefList] < 0 )
    8321042    {
    8331043      continue;
    8341044    }
     1045#endif
    8351046
    8361047    assert( iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList) );
     
    8401051    {
    8411052#if DEPTH_MAP_GENERATION
     1053#if MERL_VSP_C0152
     1054      xPredInterUni ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     1055#else
    8421056      xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     1057#endif
     1058#else
     1059#if MERL_VSP_C0152
     1060      xPredInterUni ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true );
    8431061#else
    8441062      xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true );
    8451063#endif
     1064#endif
    8461065    }
    8471066    else
     
    8501069      {
    8511070#if DEPTH_MAP_GENERATION
     1071#if MERL_VSP_C0152
     1072        xPredInterUni ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     1073#else
    8521074        xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, true );
     1075#endif
     1076#else
     1077#if MERL_VSP_C0152
     1078        xPredInterUni ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true );
    8531079#else
    8541080        xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true );
    8551081#endif
     1082#endif
    8561083      }
    8571084      else
    8581085      {
    8591086#if DEPTH_MAP_GENERATION
     1087#if MERL_VSP_C0152
     1088        xPredInterUni ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     1089#else
    8601090        xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, uiSubSampExpX, uiSubSampExpY, false );
     1091#endif
     1092#else
     1093#if MERL_VSP_C0152
     1094        xPredInterUni ( pcCU, uiPartAddr, uiAbsPartIdx, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, false );
    8611095#else
    8621096        xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, false );
    8631097#endif
     1098#endif
    8641099      }
    8651100    }
     
    8681103  if ( pcCU->getSlice()->getPPS()->getWPBiPredIdc() )
    8691104  {
     1105#if MERL_VSP_C0152
     1106    if(pcCU->getVSPIndex(uiPartAddr))
     1107      m_acYuvPred[0].copyPartToPartYuv( rpcYuvPred, uiPartAddr, iWidth, iHeight );
     1108    else
     1109#endif
    8701110    xWeightedPredictionBi( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
    8711111  }
     
    8791119    else
    8801120    {
     1121#if MERL_VSP_C0152
     1122      if(pcCU->getVSPIndex(uiPartAddr))
     1123        m_acYuvPred[0].copyPartToPartYuv( rpcYuvPred, uiPartAddr, iWidth, iHeight );
     1124      else
     1125#endif
     1126      xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
     1127    }
     1128#else
    8811129    xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
    882   }
    883 #else
    884     xWeightedAverage( pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
    885 #endif
    886   }
    887 }
     1130#endif
     1131  }
     1132}
     1133
     1134
    8881135
    8891136Void
    8901137#if DEPTH_MAP_GENERATION
    891 TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset )
     1138TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, UInt uiSubSampExpX, UInt uiSubSampExpY, TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset
     1139#if LGE_ILLUCOMP_DEPTH_C0046
     1140, Bool bICFlag
     1141#endif
     1142)
    8921143#else
    8931144TComPrediction::xPredInterPrdDepthMap( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset )
     
    9411192    }
    9421193  }
     1194
     1195#if LGE_ILLUCOMP_DEPTH_C0046
     1196  if(bICFlag)
     1197  {
     1198    Int a, b, iShift;
     1199    TComMv tTmpMV(pcMv->getHor()<<2, pcMv->getVer()<<2);
     1200
     1201    piRefY      = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr ) + iRefOffset;
     1202    piDstY      = rpcYuv->getLumaAddr( uiPartAddr );
     1203
     1204    xGetLLSICPrediction(pcCU, &tTmpMV, pcPicYuvRef, a, b, iShift);
     1205
     1206    for( Int y = 0; y < iHeight; y++, piDstY += iDstStride, piRefY += iRefStride )
     1207    {
     1208      for( Int x = 0; x < iWidth; x++ )
     1209      {
     1210        if(uiOffset)
     1211        {
     1212          Int iIFshift = IF_INTERNAL_PREC - ( g_uiBitDepth + g_uiBitIncrement );
     1213          piDstY[ x ] = ( (a*piDstY[ x ]+a*IF_INTERNAL_OFFS) >> iShift ) + b*(1<<iIFshift) - IF_INTERNAL_OFFS;
     1214        }
     1215        else
     1216          piDstY[ x ] = Clip( ( (a*piDstY[ x ]) >> iShift ) + b );
     1217      }
     1218    }
     1219  }
     1220#endif
    9431221}
    9441222
     
    11191397}
    11201398
     1399#if MERL_VSP_C0152
     1400// Input:
     1401// refPic: Ref picture. Full picture, with padding
     1402// posX, posY:     PU position, texture
     1403// size_x, size_y: PU size
     1404// partAddr: z-order index
     1405// mv: disparity vector. derived from neighboring blocks
     1406//
     1407// Output: dstPic, PU predictor 64x64
     1408Void 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
     1409                                            , TComYuv *&dstPic )
     1410{
     1411  Int widthLuma;
     1412  Int heightLuma;
     1413
     1414  if (isDepth)
     1415  {
     1416    widthLuma   =  pPicBaseDepth->getWidth();
     1417    heightLuma  =  pPicBaseDepth->getHeight();
     1418  }
     1419  else
     1420  {
     1421    widthLuma   =  refPic->getWidth();
     1422    heightLuma  =  refPic->getHeight();
     1423  }
     1424
     1425#if MERL_VSP_BLOCKSIZE_C0152 != 1
     1426  Int widthDepth  = pPicBaseDepth->getWidth();
     1427  Int heightDepth = pPicBaseDepth->getHeight();
     1428#endif
     1429
     1430  Int nTxtPerDepthX = widthLuma  / ( pPicBaseDepth->getWidth() );  // texture pixel # per depth pixel
     1431  Int nTxtPerDepthY = heightLuma / ( pPicBaseDepth->getHeight() );
     1432
     1433  Int refStride = refPic->getStride();
     1434  Int dstStride = dstPic->getStride();
     1435  Int depStride =  pPicBaseDepth->getStride();
     1436
     1437  Int depthPosX = Clip3(0,   widthLuma - size_x - 1,  (posX/nTxtPerDepthX) + (mv->getHor()>>2));
     1438  Int depthPosY = Clip3(0,   heightLuma- size_y - 1,  (posY/nTxtPerDepthY) + (mv->getVer()>>2));
     1439
     1440  Pel *ref    = refPic->getLumaAddr() + posX + posY * refStride;
     1441  Pel *dst    = dstPic->getLumaAddr(partAddr);
     1442  Pel *depth  = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride;
     1443
     1444#if MERL_VSP_BLOCKSIZE_C0152 != 1
     1445#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1446  Int  dW = size_x>>1;
     1447  Int  dH = size_y>>1;
     1448#endif
     1449#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1450  Int  dW = size_x>>2;
     1451  Int  dH = size_y>>2;
     1452#endif
     1453  {
     1454    Pel* depthi = depth;
     1455    for (Int j = 0; j < dH; j++)
     1456    {
     1457      for (Int i = 0; i < dW; i++)
     1458      {
     1459        Pel* depthTmp;
     1460#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1461        if (depthPosX + (i<<1) < widthDepth)
     1462          depthTmp = depthi + (i << 1);
     1463        else
     1464          depthTmp = depthi + (widthDepth - depthPosX - 1);
     1465#endif
     1466#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1467        if (depthPosX + (i<<2) < widthDepth)
     1468          depthTmp = depthi + (i << 2);
     1469        else
     1470          depthTmp = depthi + (widthDepth - depthPosX - 1);
     1471#endif
     1472        Int maxV = 0;
     1473        for (Int blockj = 0; blockj < MERL_VSP_BLOCKSIZE_C0152; blockj++)
     1474        {
     1475          Int iX = 0;
     1476          for (Int blocki = 0; blocki < MERL_VSP_BLOCKSIZE_C0152; blocki++)
     1477          {
     1478            if (maxV < depthTmp[iX])
     1479              maxV = depthTmp[iX];
     1480#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1481            if (depthPosX + (i<<1) + blocki < widthDepth - 1)
     1482#else // MERL_VSP_BLOCKSIZE_C0152 == 4
     1483            if (depthPosX + (i<<2) + blocki < widthDepth - 1)
     1484#endif
     1485              iX++;
     1486          }
     1487#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1488          if (depthPosY + (j<<1) + blockj < heightDepth - 1)
     1489#else // MERL_VSP_BLOCKSIZE_C0152 == 4
     1490          if (depthPosY + (j<<2) + blockj < heightDepth - 1)
     1491#endif
     1492            depthTmp += depStride;
     1493        }
     1494        m_pDepth[i+j*dW] = maxV;
     1495      } // end of i < dW
     1496#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1497      if (depthPosY + ((j+1)<<1) < heightDepth)
     1498        depthi += (depStride << 1);
     1499      else
     1500        depthi  = depth + (heightDepth-depthPosY-1)*depStride;
     1501#endif
     1502#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1503      if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1
     1504        depthi += (depStride << 2);
     1505      else
     1506        depthi  = depth + (heightDepth-depthPosY-1)*depStride; // the last line
     1507#endif
     1508    }
     1509  }
     1510#endif
     1511 
     1512#if MERL_VSP_BLOCKSIZE_C0152 != 1
     1513  Int yDepth = 0;
     1514#endif
     1515  for ( Int yTxt = 0; yTxt < size_y; yTxt += nTxtPerDepthY )
     1516  {
     1517    for ( Int xTxt = 0, xDepth = 0; xTxt < size_x; xTxt += nTxtPerDepthX, xDepth++ )
     1518    {
     1519      Pel rep_depth = 0; // to store the depth value used for warping
     1520#if MERL_VSP_BLOCKSIZE_C0152 == 1
     1521      rep_depth = depth[xDepth];
     1522#endif
     1523#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1524      rep_depth = m_pDepth[(xTxt>>1) + (yTxt>>1)*dW];
     1525#endif
     1526#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1527      rep_depth = m_pDepth[(xTxt>>2) + (yTxt>>2)*dW];
     1528#endif
     1529
     1530      assert( rep_depth >= 0 && rep_depth <= 255 );
     1531      Int disparity = pShiftLUT[ rep_depth ] << iShiftPrec;
     1532      Int refOffset = xTxt + (disparity >> 2);
     1533      Int xFrac = disparity & 0x3;
     1534      Int absX  = posX + refOffset;
     1535
     1536      if (xFrac == 0)
     1537        absX = Clip3(0, widthLuma-1, absX);
     1538      else
     1539        absX = Clip3(4, widthLuma-5, absX);
     1540
     1541      refOffset = absX - posX;
     1542
     1543      assert( ref[refOffset] >= 0 && ref[refOffset]<= 255 );
     1544      m_if.filterHorLuma( &ref[refOffset], refStride, &dst[xTxt], dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true );
     1545    }
     1546    ref   += refStride*nTxtPerDepthY;
     1547    dst   += dstStride*nTxtPerDepthY;
     1548    depth += depStride;
     1549#if MERL_VSP_BLOCKSIZE_C0152 != 1
     1550    yDepth++;
     1551#endif
     1552  }
     1553}
     1554
     1555Void 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
     1556                                               , TComYuv *&dstPic )
     1557{
     1558  Int refStride = refPic->getCStride();
     1559  Int dstStride = dstPic->getCStride();
     1560  Int depStride = pPicBaseDepth->getStride();
     1561
     1562  Int widthChroma, heightChroma;
     1563  if( isDepth)
     1564  {
     1565     widthChroma   = pPicBaseDepth->getWidth()>>1;
     1566     heightChroma  = pPicBaseDepth->getHeight()>>1;
     1567  }
     1568  else
     1569  {
     1570     widthChroma   = refPic->getWidth()>>1;
     1571     heightChroma  = refPic->getHeight()>>1;
     1572  }
     1573
     1574  // Below is only for Texture chroma component
     1575
     1576  Int widthDepth  = pPicBaseDepth->getWidth();
     1577  Int heightDepth = pPicBaseDepth->getHeight();
     1578
     1579  Int nTxtPerDepthX, nTxtPerDepthY;  // Number of texture samples per one depth sample
     1580  Int nDepthPerTxtX, nDepthPerTxtY;  // Number of depth samples per one texture sample
     1581
     1582  Int depthPosX;  // Starting position in depth image
     1583  Int depthPosY;
     1584
     1585  if ( widthChroma > widthDepth )
     1586  {
     1587    nTxtPerDepthX = widthChroma / widthDepth;
     1588    nDepthPerTxtX = 1;
     1589    depthPosX = posX / nTxtPerDepthX + (mv->getHor()>>2);        //mv denotes the disparity for VSP
     1590  }
     1591  else
     1592  {
     1593    nTxtPerDepthX = 1;
     1594    nDepthPerTxtX = widthDepth / widthChroma;
     1595    depthPosX = posX * nDepthPerTxtX + (mv->getHor()>>2);        //mv denotes the disparity for VSP
     1596  }
     1597  depthPosX = Clip3(0, widthDepth - (size_x<<1) - 1, depthPosX);
     1598 
     1599  if ( heightChroma > heightDepth )
     1600  {
     1601    nTxtPerDepthY = heightChroma / heightDepth;
     1602    nDepthPerTxtY = 1;
     1603    depthPosY = posY / nTxtPerDepthY + (mv->getVer()>>2);     //mv denotes the disparity for VSP
     1604  }
     1605  else
     1606  {
     1607    nTxtPerDepthY = 1;
     1608    nDepthPerTxtY = heightDepth / heightChroma;
     1609    depthPosY = posY * nDepthPerTxtY + (mv->getVer()>>2);     //mv denotes the disparity for VSP
     1610  }
     1611  depthPosY = Clip3(0, heightDepth - (size_y<<1) - 1, depthPosY);
     1612
     1613  Pel *refCb  = refPic->getCbAddr() + posX + posY * refStride;
     1614  Pel *refCr  = refPic->getCrAddr() + posX + posY * refStride;
     1615  Pel *dstCb  = dstPic->getCbAddr(partAddr);
     1616  Pel *dstCr  = dstPic->getCrAddr(partAddr);
     1617  Pel *depth  = pPicBaseDepth->getLumaAddr() + depthPosX + depthPosY * depStride;  // move the pointer to the current depth pixel position
     1618 
     1619  Int refStrideBlock = refStride * nTxtPerDepthY;
     1620  Int dstStrideBlock = dstStride * nTxtPerDepthY;
     1621  Int depStrideBlock = depStride * nDepthPerTxtY;
     1622
     1623  if (isDepth)
     1624  {
     1625     // DT: Since the call for this function is redundant, ..
     1626     for (Int y = 0; y < size_y; y++)
     1627     {
     1628       for (Int x = 0; x < size_x; x++)
     1629       {
     1630         dstCb[x] = 128;
     1631         dstCr[x] = 128;
     1632       }
     1633       dstCb += dstStride;
     1634       dstCr += dstStride;
     1635     }
     1636     return;
     1637  }
     1638 
     1639  if ( widthChroma > widthDepth ) // We assume
     1640  {
     1641    assert( heightChroma > heightDepth );
     1642    printf("This branch should never been reached.\n");
     1643    exit(0);
     1644  }
     1645  else
     1646  {
     1647#if MERL_VSP_BLOCKSIZE_C0152 == 1
     1648  Int  dW = size_x;
     1649  Int  dH = size_y;
     1650  Int  sW = 2; // search window size
     1651  Int  sH = 2;
     1652#endif
     1653#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1654  Int  dW = size_x;
     1655  Int  dH = size_y;
     1656  Int  sW = 2; // search window size
     1657  Int  sH = 2;
     1658#endif
     1659#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1660  Int  dW = size_x>>1;
     1661  Int  dH = size_y>>1;
     1662  Int  sW = 4; // search window size
     1663  Int  sH = 4;
     1664#endif
     1665
     1666  {
     1667    Pel* depthi = depth;
     1668    for (Int j = 0; j < dH; j++)
     1669    {
     1670      for (Int i = 0; i < dW; i++)
     1671      {
     1672        Pel* depthTmp;
     1673#if MERL_VSP_BLOCKSIZE_C0152 == 1
     1674        depthTmp = depthi + (i << 1);
     1675#endif
     1676#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1677        if (depthPosX + (i<<1) < widthDepth)
     1678          depthTmp = depthi + (i << 1);
     1679        else
     1680          depthTmp = depthi + (widthDepth - depthPosX - 1);
     1681#endif
     1682#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1683        if (depthPosX + (i<<2) < widthDepth)
     1684          depthTmp = depthi + (i << 2);
     1685        else
     1686          depthTmp = depthi + (widthDepth - depthPosX - 1);
     1687#endif
     1688        Int maxV = 0;
     1689        for (Int blockj = 0; blockj < sH; blockj++)
     1690        {
     1691          Int iX = 0;
     1692          for (Int blocki = 0; blocki < sW; blocki++)
     1693          {
     1694            if (maxV < depthTmp[iX])
     1695              maxV = depthTmp[iX];
     1696            if (depthPosX + i*sW + blocki < widthDepth - 1)
     1697              iX++;
     1698          }
     1699          if (depthPosY + j*sH + blockj < heightDepth - 1)
     1700            depthTmp += depStride;
     1701        }
     1702        m_pDepth[i+j*dW] = maxV;
     1703      } // end of i < dW
     1704#if MERL_VSP_BLOCKSIZE_C0152 == 1
     1705      if (depthPosY + ((j+1)<<1) < heightDepth)
     1706        depthi += (depStride << 1);
     1707      else
     1708        depthi  = depth + (heightDepth-1)*depStride;
     1709#endif
     1710#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1711      if (depthPosY + ((j+1)<<1) < heightDepth)
     1712        depthi += (depStride << 1);
     1713      else
     1714        depthi  = depth + (heightDepth-depthPosY-1)*depStride;
     1715#endif
     1716#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1717      if (depthPosY + ((j+1)<<2) < heightDepth) // heightDepth-1
     1718        depthi += (depStride << 2);
     1719      else
     1720        depthi  = depth + (heightDepth-depthPosY-1)*depStride; // the last line
     1721#endif
     1722    }
     1723  }
     1724
     1725
     1726    // (size_x, size_y) is Chroma block size
     1727    for ( Int yTxt = 0, yDepth = 0; yTxt < size_y; yTxt += nTxtPerDepthY, yDepth += nDepthPerTxtY )
     1728    {
     1729      for ( Int xTxt = 0, xDepth = 0; xTxt < size_x; xTxt += nTxtPerDepthX, xDepth += nDepthPerTxtX )
     1730      {
     1731        Pel rep_depth = 0; // to store the depth value used for warping
     1732#if MERL_VSP_BLOCKSIZE_C0152 == 1
     1733        rep_depth = m_pDepth[(xTxt) + (yTxt)*dW];
     1734#endif
     1735#if MERL_VSP_BLOCKSIZE_C0152 == 2
     1736        rep_depth = m_pDepth[(xTxt) + (yTxt)*dW];
     1737#endif
     1738#if MERL_VSP_BLOCKSIZE_C0152 == 4
     1739        rep_depth = m_pDepth[(xTxt>>1) + (yTxt>>1)*dW];
     1740#endif
     1741
     1742      // calculate the offset in the reference picture
     1743        Int disparity = pShiftLUT[ rep_depth ] << iShiftPrec;
     1744        Int refOffset = xTxt + (disparity >> 3); // in integer pixel in chroma image
     1745        Int xFrac = disparity & 0x7;
     1746        Int absX  = posX + refOffset;
     1747
     1748        if (xFrac == 0)
     1749          absX = Clip3(0, widthChroma-1, absX);
     1750        else
     1751          absX = Clip3(4, widthChroma-5, absX);
     1752
     1753        refOffset = absX - posX;
     1754
     1755        assert( refCb[refOffset] >= 0 && refCb[refOffset]<= 255 );
     1756        assert( refCr[refOffset] >= 0 && refCr[refOffset]<= 255 );
     1757        m_if.filterHorChroma(&refCb[refOffset], refStride, &dstCb[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true);
     1758        m_if.filterHorChroma(&refCr[refOffset], refStride, &dstCr[xTxt],  dstStride, nTxtPerDepthX, nTxtPerDepthY, xFrac, true);
     1759      }
     1760      refCb += refStrideBlock;
     1761      refCr += refStrideBlock;
     1762      dstCb += dstStrideBlock;
     1763      dstCr += dstStrideBlock;
     1764      depth += depStrideBlock;
     1765    }
     1766  }
     1767}
     1768
     1769#endif // MERL_VSP_C0152
     1770
    11211771#if DEPTH_MAP_GENERATION
    11221772Void TComPrediction::xWeightedAveragePdm( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst, UInt uiSubSampExpX, UInt uiSubSampExpY )
     
    17042354  iCUPelX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]];
    17052355  iCUPelY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[pcCU->getZorderIdxInCU()]];
     2356#if FIX_LGE_ILLUCOMP_B0045
     2357  iRefX   = iCUPelX + (pMv->getHor() >> 2);
     2358  iRefY   = iCUPelY + (pMv->getVer() >> 2);
     2359#else
    17062360  iRefX   = iCUPelX + (pMv->getHor() >> 3);
    17072361  iRefY   = iCUPelY + (pMv->getVer() >> 3);
     2362#endif
    17082363  uiWidth = pcCU->getWidth(0) >> 1;
    17092364  uiHeight = pcCU->getHeight(0) >> 1;
     
    19192574  UInt  uiWedgeStride   = pcWedgelet->getStride();
    19202575
     2576#if HS_REFERENCE_SUBSAMPLE_C0154
     2577  Int subSamplePix;
     2578  if ( pcWedgelet->getWidth() == 32 )
     2579  {
     2580    subSamplePix = 2;
     2581  }
     2582  else
     2583  {
     2584    subSamplePix = 1;
     2585  }
     2586#endif
     2587
    19212588  if( bAbove )
    19222589  {
     2590#if HS_REFERENCE_SUBSAMPLE_C0154
     2591    for( Int k = 0; k < pcWedgelet->getWidth(); k+=subSamplePix )
     2592#else
    19232593    for( Int k = 0; k < pcWedgelet->getWidth(); k++ )
     2594#endif
    19242595    {
    19252596      if( true == pabWedgePattern[k] )
     
    19372608  if( bLeft )
    19382609  {
     2610#if HS_REFERENCE_SUBSAMPLE_C0154
     2611    for( Int k = 0; k < pcWedgelet->getHeight(); k+=subSamplePix )
     2612#else
    19392613    for( Int k = 0; k < pcWedgelet->getHeight(); k++ )
     2614#endif
    19402615    {
    19412616      if( true == pabWedgePattern[k*uiWedgeStride] )
     
    21162791}
    21172792
     2793#if LGE_DMM3_SIMP_C0044
     2794/**
     2795 - fetch best Wedgelet pattern at decoder
     2796 */
     2797UInt TComPrediction::getBestWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt IntraTabIdx)
     2798{
     2799  assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE );
     2800
     2801  UInt          uiBestTabIdx = 0;
     2802  TComPic*      pcPicTex = pcCU->getSlice()->getTexturePic();
     2803  TComDataCU*   pcColTexCU = pcPicTex->getCU(pcCU->getAddr());
     2804  UInt          uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
     2805  Int           uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255;
     2806
     2807  std::vector< std::vector<UInt> > pauiWdgLstSz = g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]];
     2808
     2809  if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 )
     2810  {
     2811    std::vector<UInt>* pauiWdgLst = &pauiWdgLstSz[uiColTexIntraDir-2];
     2812    uiBestTabIdx    =   pauiWdgLst->at(IntraTabIdx);
     2813  }
     2814  else
     2815  {
     2816    WedgeNodeList* pacWedgeNodeList = &g_aacWedgeNodeLists[(g_aucConvertToBit[uiWidth])];
     2817    uiBestTabIdx = pacWedgeNodeList->at(IntraTabIdx).getPatternIdx();
     2818  }
     2819
     2820  return uiBestTabIdx;
     2821}
     2822#endif
     2823
     2824#if LGE_DMM3_SIMP_C0044
     2825/**
     2826 - calculate best Wedgelet pattern at encoder
     2827 */
     2828UInt TComPrediction::getBestWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Pel* piOrigi, UInt uiStride, UInt & ruiIntraTabIdx)
     2829#else
    21182830UInt TComPrediction::getBestWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight )
     2831#endif
    21192832{
    21202833  assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE );
     
    21442857  Int  iDC2 = 0;
    21452858  WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])];
    2146 
    2147 #if HHIQC_DMMFASTSEARCH_B0039
     2859#if LGE_DMM3_SIMP_C0044
     2860  ruiIntraTabIdx  = 0;
     2861#endif
    21482862  TComPic*      pcPicTex = pcCU->getSlice()->getTexturePic();
    21492863  TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr());
     
    21582872    {
    21592873      UInt uiIdx     =   pauiWdgLst->at(uiIdxW);
     2874#if LGE_DMM3_SIMP_C0044
     2875      calcWedgeDCs       ( &(pacWedgeList->at(uiIdx)), piOrigi,   uiWidth,      iDC1, iDC2 );
     2876#else
    21602877      calcWedgeDCs       ( &(pacWedgeList->at(uiIdx)), piRefBlkY, uiWidth,      iDC1, iDC2 );
     2878#endif
    21612879      assignWedgeDCs2Pred( &(pacWedgeList->at(uiIdx)), piPred,    uiPredStride, iDC1, iDC2 );
    21622880
     2881#if LGE_DMM3_SIMP_C0044
     2882      UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piOrigi, uiStride, uiWidth, uiHeight, WedgeDist_SAD );
     2883#else
    21632884      UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD );
     2885#endif
    21642886
    21652887      if( uiActDist < uiBestDist || uiBestDist == MAX_UINT )
     
    21672889        uiBestDist   = uiActDist;
    21682890        uiBestTabIdx = uiIdx;
     2891#if LGE_DMM3_SIMP_C0044
     2892        ruiIntraTabIdx = uiIdxW;
     2893#endif
    21692894      }
    21702895    }
     
    21772902    for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ )
    21782903    {
     2904#if LGE_DMM3_SIMP_C0044
     2905      calcWedgeDCs       ( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piOrigi, uiWidth,      iDC1, iDC2 );
     2906#else
    21792907      calcWedgeDCs       ( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piRefBlkY, uiWidth,      iDC1, iDC2 );
     2908#endif
    21802909      assignWedgeDCs2Pred( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piPred,    uiPredStride, iDC1, iDC2 );
    21812910
     2911#if LGE_DMM3_SIMP_C0044
     2912      UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piOrigi, uiStride, uiWidth, uiHeight, WedgeDist_SAD );
     2913#else
    21822914      UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD );
     2915#endif
    21832916
    21842917      if( uiActDist < uiBestNodeDist || uiBestNodeDist == MAX_UINT )
     
    21862919        uiBestNodeDist = uiActDist;
    21872920        uiBestNodeId   = uiNodeId;
    2188       }
    2189     }
    2190 
     2921#if LGE_DMM3_SIMP_C0044
     2922        ruiIntraTabIdx = uiNodeId;
     2923#endif
     2924      }
     2925    }
     2926#if LGE_DMM3_SIMP_C0044
     2927    uiBestTabIdx = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx();
     2928#else
    21912929    // refinement
    21922930    uiBestDist   = uiBestNodeDist;
     
    22082946      }
    22092947    }
    2210   }
    2211 #else
    2212   for( UInt uiIdx = 0; uiIdx < pacWedgeList->size(); uiIdx++ )
    2213   {
    2214     calcWedgeDCs       ( &(pacWedgeList->at(uiIdx)), piRefBlkY, uiWidth,      iDC1, iDC2 );
    2215     assignWedgeDCs2Pred( &(pacWedgeList->at(uiIdx)), piPred,    uiPredStride, iDC1, iDC2 );
    2216 
    2217     UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD );
    2218 
    2219     if( uiActDist < uiBestDist || uiBestDist == MAX_UINT )
    2220     {
    2221       uiBestDist   = uiActDist;
    2222       uiBestTabIdx = uiIdx;
    2223     }
    2224   }
    2225 #endif
     2948#endif
     2949  }
    22262950
    22272951  cPredYuv.destroy();
     
    22622986  {
    22632987    // decoder: get and store wedge pattern in CU
     2988      // decoder: get and store wedge pattern in CU
     2989#if LGE_DMM3_SIMP_C0044
     2990    UInt uiIntraTabIdx   = pcCU->getWedgePredTexIntraTabIdx ( uiAbsPartIdx );
     2991    uiTextureWedgeTabIdx = getBestWedgeFromTex( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight, uiIntraTabIdx );
     2992#else
    22642993    uiTextureWedgeTabIdx = getBestWedgeFromTex( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight );
     2994#endif
    22652995
    22662996    UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1);
     
    22773007  getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
    22783008
     3009#if HHI_DMM_DELTADC_Q1_C0034
     3010#else
    22793011  if( bDelta )
    22803012  {
     
    22823014    xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
    22833015  }
     3016#endif
    22843017
    22853018  // assign wedge pred DCs to prediction
     
    23023035  getWedgePredDCs( pcContourWedge, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
    23033036
     3037#if HHI_DMM_DELTADC_Q1_C0034
     3038#else
    23043039  if( bDelta )
    23053040  {
     
    23073042    xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
    23083043  }
     3044#endif
    23093045
    23103046  // assign wedge pred DCs to prediction
     
    23153051  delete pcContourWedge;
    23163052}
    2317 #endif
     3053#endif // HHI_DMM_PRED_TEX
    23183054
    23193055#if HHI_DMM_WEDGE_INTRA
     
    24833219  getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
    24843220
     3221#if HHI_DMM_DELTADC_Q1_C0034
     3222#else
    24853223  if( bDelta )
    24863224  {
     
    24883226    xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
    24893227  }
     3228#endif
    24903229
    24913230  // assign wedge pred DCs to prediction
     
    25243263  getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
    25253264
     3265#if HHI_DMM_DELTADC_Q1_C0034
     3266#else
    25263267  if( bDelta )
    25273268  {
     
    25293270    xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
    25303271  }
     3272#endif
    25313273
    25323274  // assign wedge pred DCs to prediction
     
    26133355
    26143356  // 2nd step: derive wedge direction
    2615 #if LOGI_INTRA_NAME_3MPM
    26163357  Int uiPreds[3] = {-1, -1, -1};
    2617 #else
    2618   Int uiPreds[2] = {-1, -1};
    2619 #endif
    26203358  Int iMode = -1;
    26213359  Int iPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds, &iMode ); 
    26223360
    26233361  UInt uiDirMode = 0;
    2624 #if LOGI_INTRA_NAME_3MPM
    26253362  if( iMode >= 0 ) { iPredNum = iMode; }
    26263363  if( iPredNum == 1 ) { uiDirMode = uiPreds[0]; }
     
    26323369  Bool modeVer       = !modeHor;
    26333370  Int intraPredAngle = modeVer ? (Int)uiDirMode - VER_IDX : modeHor ? -((Int)uiDirMode - HOR_IDX) : 0;
    2634 #else
    2635   if( iPredNum == 1 ) { uiDirMode = g_aucAngIntraModeOrder[uiPreds[0]]; }
    2636   if( iPredNum == 2 ) { uiDirMode = g_aucAngIntraModeOrder[uiPreds[1]]; }
    2637 
    2638   if( uiDirMode == 0 ) {  return false; } // no DC
    2639 
    2640   Bool modeVer       = (uiDirMode < 18);
    2641   Bool modeHor       = !modeVer;
    2642   Int intraPredAngle = modeVer ? uiDirMode - 9 : modeHor ? uiDirMode - 25 : 0;
    2643 #endif
    26443371  Int absAng         = abs(intraPredAngle);
    26453372  Int signAng        = intraPredAngle < 0 ? -1 : 1;
     
    29603687  Int*  ptrSrc  = pcTComPattern->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );
    29613688  Int   sw      = ( iWidth<<1 ) + 1;
    2962 #if !LOGI_INTRA_NAME_3MPM
    2963   uiDirMode     = g_aucAngIntraModeOrder[ uiDirMode ];
    2964 #endif
    29653689  xPredIntraAngDepth( ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, uiDirMode );
    29663690}
Note: See TracChangeset for help on using the changeset viewer.