Ignore:
Timestamp:
15 Jul 2015, 14:57:32 (9 years ago)
Author:
tech
Message:

Merged 14.1-update-dev2@1277.

Location:
branches/HTM-14.1-update-dev1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-14.1-update-dev1

  • branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComPrediction.cpp

    r1243 r1279  
    8282    }
    8383  }
    84 #if H_3D_VSP
    85   m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int));
     84#if NH_3D_VSP
     85  m_pDepthBlock = (Int*) malloc(MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH*sizeof(Int));
    8686  if (m_pDepthBlock == NULL)
    8787  {
     
    9494TComPrediction::~TComPrediction()
    9595{
    96 #if H_3D_VSP
     96#if NH_3D_VSP
    9797  if (m_pDepthBlock != NULL)
    9898  {
     
    123123  m_cYuvPredTemp.destroy();
    124124
    125 #if H_3D_ARP
     125#if NH_3D_ARP
    126126  m_acYuvPredBase[0].destroy();
    127127  m_acYuvPredBase[1].destroy();
     
    182182
    183183    m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
    184 #if H_3D_ARP
    185     m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    186     m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
    187 #endif
    188 #if H_3D_VSP
    189     m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight );
     184#if NH_3D_ARP
     185    m_acYuvPredBase[0] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
     186    m_acYuvPredBase[1] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
     187#endif
     188#if NH_3D_VSP
     189    m_cYuvDepthOnVsp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
    190190#endif
    191191
     
    201201    }
    202202  }
    203 #if H_3D_IC
     203#if NH_3D_IC
    204204  m_uiaShift[0] = 0;
    205205  for( Int i = 1; i < 64; i++ )
     
    584584      Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC();
    585585      Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC();
    586 #if H_3D_ARP
     586#if NH_3D_ARP
    587587      if(!pcCU->getARPW(PartAddr) && RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
    588588#else
     
    597597}
    598598
    599 #if H_3D_SPIVMP
     599#if NH_3D_SPIVMP
    600600Void TComPrediction::xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr )
    601601{
     
    606606    pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]);
    607607  }
     608#if H_3D_ARP // check this!
    608609  if( pcCU->getARPW( uiPartAddr ) != 0 )
    609610  {
    610611    return;
    611612  }
     613#endif
    612614
    613615  // horizontal sub-PU merge
     
    683685#endif
    684686
    685 #if H_3D_DBBP
     687#if NH_3D_DBBP
    686688PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize, TComDataCU*& pcCU)
    687689{
     690  const TComSPS* sps = pcCU->getSlice()->getSPS();
     691  UInt uiMaxCUWidth = sps->getMaxCUWidth();
     692  UInt uiMaxCUHeight = sps->getMaxCUHeight();
     693 
    688694  // find virtual partitioning for this CU based on depth block
    689695  // segmentation of texture block --> mask IDs
     
    693699  Int iSumDepth = 0;
    694700  Int iSubSample = 4;
    695   Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth();
    696   Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight();
     701  Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(COMPONENT_Y);
     702  Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(COMPONENT_Y);
    697703  TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag(  ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV;
    698704  if( pcCU->getSlice()->getDepthRefinementFlag(  ) )
     
    700706    cDv.setVer(0);
    701707  }
    702   Int iBlkX = ( pcCU->getAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getHor()+2)>>2);
    703   Int iBlkY = ( pcCU->getAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getVer()+2)>>2);
     708  Int iBlkX = ( pcCU->getCtuRsAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getHor()+2)>>2);
     709  Int iBlkY = ( pcCU->getCtuRsAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getVer()+2)>>2);
    704710 
    705711  UInt t=0;
     
    788794  }
    789795
    790   PartSize matchedPartSize = SIZE_NONE;
     796  PartSize matchedPartSize = NUMBER_OF_PART_SIZES;
    791797
    792798  Int iMaxMatchSum = 0;
     
    803809  }
    804810
    805   AOF( matchedPartSize != SIZE_NONE );
     811  AOF( matchedPartSize != NUMBER_OF_PART_SIZES );
    806812
    807813  return matchedPartSize;
     
    810816Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask, TComDataCU*& pcCU)
    811817{
     818  const TComSPS* sps = pcCU->getSlice()->getSPS();
     819  UInt uiMaxCUWidth = sps->getMaxCUWidth();
     820  UInt uiMaxCUHeight = sps->getMaxCUHeight();
     821 
    812822  // segmentation of texture block --> mask IDs
    813823  Pel*  pDepthBlockStart      = pDepthPels;
     
    821831  iSumDepth  = pDepthPels[ 0 ];
    822832 
    823   Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth();
    824   Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(); 
     833  Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(COMPONENT_Y);
     834  Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(COMPONENT_Y); 
    825835  TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag(  ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV;
    826836  if( pcCU->getSlice()->getDepthRefinementFlag(  ) )
     
    828838    cDv.setVer(0);
    829839  }
    830   Int iBlkX = ( pcCU->getAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getHor()+2)>>2);
    831   Int iBlkY = ( pcCU->getAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getVer()+2)>>2);
     840  Int iBlkX = ( pcCU->getCtuRsAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getHor()+2)>>2);
     841  Int iBlkY = ( pcCU->getCtuRsAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getVer()+2)>>2);
    832842  if (iBlkX>(Int)(iPictureWidth - uiWidth))
    833843  {
     
    944954}
    945955
    946 Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize )
    947 {
    948   Pel*  piSrc[2]    = {pInYuv[0]->getLumaAddr(uiPartAddr), pInYuv[1]->getLumaAddr(uiPartAddr)};
    949   UInt  uiSrcStride = pInYuv[0]->getStride();
    950   Pel*  piDst       = pOutYuv->getLumaAddr(uiPartAddr);
    951   UInt  uiDstStride = pOutYuv->getStride();
     956Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize, Int bitDepthY )
     957{
     958  Pel*  piSrc[2]    = {pInYuv[0]->getAddr(COMPONENT_Y, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Y, uiPartAddr)};
     959  UInt  uiSrcStride = pInYuv[0]->getStride(COMPONENT_Y);
     960  Pel*  piDst       = pOutYuv->getAddr(COMPONENT_Y, uiPartAddr);
     961  UInt  uiDstStride = pOutYuv->getStride(COMPONENT_Y);
    952962 
    953963  UInt  uiMaskStride= MAX_CU_SIZE;
     
    988998        right  = (x==uiWidth-1)  ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x+1];
    989999       
    990         piDst[x] = (l!=r) ? ClipY( Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 )) : tmpTar[y*uiWidth+x];
     1000        piDst[x] = (l!=r) ? ClipBD( Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 ), bitDepthY) : tmpTar[y*uiWidth+x];
    9911001      }
    9921002      piDst     += uiDstStride;
     
    10061016        bottom = (y==uiHeight-1) ? tmpTar[y*uiWidth+x] : tmpTar[(y+1)*uiWidth+x];
    10071017       
    1008         piDst[x] = (t!=b) ? ClipY( Pel(( top + (tmpTar[y*uiWidth+x] << 1) + bottom ) >> 2 )) : tmpTar[y*uiWidth+x];
     1018        piDst[x] = (t!=b) ? ClipBD( Pel(( top + (tmpTar[y*uiWidth+x] << 1) + bottom ) >> 2 ), bitDepthY) : tmpTar[y*uiWidth+x];
    10091019      }
    10101020      piDst     += uiDstStride;
     
    10191029 
    10201030  // now combine chroma
    1021   Pel*  piSrcU[2]       = { pInYuv[0]->getCbAddr(uiPartAddr), pInYuv[1]->getCbAddr(uiPartAddr) };
    1022   Pel*  piSrcV[2]       = { pInYuv[0]->getCrAddr(uiPartAddr), pInYuv[1]->getCrAddr(uiPartAddr) };
    1023   UInt  uiSrcStrideC    = pInYuv[0]->getCStride();
    1024   Pel*  piDstU          = pOutYuv->getCbAddr(uiPartAddr);
    1025   Pel*  piDstV          = pOutYuv->getCrAddr(uiPartAddr);
    1026   UInt  uiDstStrideC    = pOutYuv->getCStride();
     1031  Pel*  piSrcU[2]       = { pInYuv[0]->getAddr(COMPONENT_Cb, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Cb, uiPartAddr) };
     1032  Pel*  piSrcV[2]       = { pInYuv[0]->getAddr(COMPONENT_Cr, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Cr, uiPartAddr) };
     1033  UInt  uiSrcStrideC    = pInYuv[0]->getStride(COMPONENT_Cb);
     1034  Pel*  piDstU          = pOutYuv->getAddr(COMPONENT_Cb, uiPartAddr);
     1035  Pel*  piDstV          = pOutYuv->getAddr(COMPONENT_Cr, uiPartAddr);
     1036  UInt  uiDstStrideC    = pOutYuv->getStride(COMPONENT_Cb);
    10271037  UInt  uiWidthC        = uiWidth >> 1;
    10281038  UInt  uiHeightC       = uiHeight >> 1;
     
    10701080        if (l!=r)
    10711081        {
    1072           filSrcU = ClipC( Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ));
    1073           filSrcV = ClipC( Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ));
     1082          filSrcU = ClipBD( Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ), bitDepthY);
     1083          filSrcV = ClipBD( Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ), bitDepthY);
    10741084        }
    10751085        else
     
    11031113        if (t!=b)
    11041114        {
    1105           filSrcU = ClipC( Pel(( topU + (tmpTarU[y*uiWidthC+x] << 1) + bottomU ) >> 2 ));
    1106           filSrcV = ClipC( Pel(( topV + (tmpTarV[y*uiWidthC+x] << 1) + bottomV ) >> 2 ));
     1115          filSrcU = ClipBD( Pel(( topU + (tmpTarU[y*uiWidthC+x] << 1) + bottomU ) >> 2 ), bitDepthY);
     1116          filSrcV = ClipBD( Pel(( topV + (tmpTarV[y*uiWidthC+x] << 1) + bottomV ) >> 2 ), bitDepthY);
    11071117        }
    11081118        else
     
    11411151  {
    11421152    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
    1143 #if H_3D_VSP
     1153#if NH_3D_VSP
    11441154    if ( pcCU->getVSPFlag(uiPartAddr) == 0)
    11451155    {
    11461156#endif
    1147     if ( eRefPicList != REF_PIC_LIST_X )
    1148     {
    1149       if( pcCU->getSlice()->getPPS()->getUseWP())
    1150       {
    1151         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
     1157      if ( eRefPicList != REF_PIC_LIST_X )
     1158      {
     1159        if( pcCU->getSlice()->getPPS()->getUseWP())
     1160        {
     1161          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
     1162        }
     1163        else
     1164        {
     1165          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
     1166        }
     1167        if ( pcCU->getSlice()->getPPS()->getUseWP() )
     1168        {
     1169          xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
     1170        }
    11521171      }
    11531172      else
    11541173      {
    1155         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1156       }
    1157       if ( pcCU->getSlice()->getPPS()->getUseWP() )
    1158       {
    1159         xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1160       }
    1161     }
    1162     else
    1163     {
    1164 #if H_3D_SPIVMP
     1174#if NH_3D_SPIVMP
    11651175        if ( pcCU->getSPIVMPFlag(uiPartAddr)!=0) 
    11661176        {
     
    11941204        {
    11951205#endif
     1206          if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
     1207          {
     1208            xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
     1209          }
     1210          else
     1211          {
     1212            xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
     1213          }
     1214#if NH_3D_SPIVMP
     1215        }
     1216#endif
     1217      }
     1218#if NH_3D_VSP
     1219    }
     1220    else
     1221    {
    11961222      if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    11971223      {
    1198         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
     1224        xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
    11991225      }
    12001226      else
    12011227      {
    1202         xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1203       }
    1204 #if H_3D_SPIVMP
    1205         }
    1206 #endif
    1207     }
    1208 #if H_3D_VSP
     1228        xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
     1229      }
     1230    }
     1231#endif
     1232    return;
     1233  }
     1234
     1235  for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ )
     1236  {
     1237    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
     1238
     1239#if NH_3D_VSP
     1240    if ( pcCU->getVSPFlag(uiPartAddr) == 0 )
     1241    {
     1242#endif
     1243    if ( eRefPicList != REF_PIC_LIST_X )
     1244    {
     1245      if( pcCU->getSlice()->getPPS()->getUseWP())
     1246      {
     1247        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
     1248      }
     1249      else
     1250      {
     1251        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
     1252      }
     1253      if ( pcCU->getSlice()->getPPS()->getUseWP() )
     1254      {
     1255        xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
     1256      }
    12091257    }
    12101258    else
    12111259    {
    1212       if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1213       {
    1214         xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
    1215       }
    1216       else
    1217       {
    1218         xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1219       }
    1220     }
    1221 #endif
    1222     return;
    1223   }
    1224 
    1225   for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ )
    1226   {
    1227     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
    1228 
    1229 #if H_3D_VSP
    1230     if ( pcCU->getVSPFlag(uiPartAddr) == 0 )
    1231     {
    1232 #endif
    1233     if ( eRefPicList != REF_PIC_LIST_X )
    1234     {
    1235       if( pcCU->getSlice()->getPPS()->getUseWP())
    1236       {
    1237         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
    1238       }
    1239       else
    1240       {
    1241         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1242       }
    1243       if ( pcCU->getSlice()->getPPS()->getUseWP() )
    1244       {
    1245         xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
    1246       }
    1247     }
    1248     else
    1249     {
    1250 #if H_3D_SPIVMP
    1251        if (pcCU->getSPIVMPFlag(uiPartAddr)!=0) 
     1260#if NH_3D_SPIVMP
     1261      if (pcCU->getSPIVMPFlag(uiPartAddr)!=0) 
    12521262      {
    12531263        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
     
    12791289      {
    12801290#endif
    1281       if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
    1282       {
    1283         xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
    1284       }
    1285       else
    1286       {
    1287         xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
    1288       }
    1289 #if H_3D_SPIVMP
    1290        }
    1291 #endif
    1292     }
    1293 #if H_3D_VSP
     1291        if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
     1292        {
     1293          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
     1294        }
     1295        else
     1296        {
     1297          xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
     1298        }
     1299#if NH_3D_SPIVMP
     1300      }
     1301#endif
     1302    }
     1303#if NH_3D_VSP
    12941304    }
    12951305    else
     
    13171327  pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx );
    13181328#endif
    1319 #if H_3D_ARP
    1320   if(pcCU->getARPW( uiPartAddr ) > 0  && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC())
    1321   {
    1322     xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , bi );
     1329#if NH_3D_ARP
     1330  if(  pcCU->getARPW( uiPartAddr ) > 0 )
     1331  {
     1332    if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC() )
     1333  {
     1334      xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , pcYuvPred , bi );
    13231335  }
    13241336  else
    13251337  {
    1326     if(  pcCU->getARPW( uiPartAddr ) > 0
    1327       && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N
    1328       && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC()
    1329       )
    1330     {
    1331       xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi );
     1338      xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, bi );
     1339    }     
    13321340    }
    13331341    else
    13341342    {
    13351343#endif
    1336 #if H_3D_IC
    1337       Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() );
    1338       xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
    1339 #if H_3D_ARP
    1340         , false
    1341 #endif
    1342         , bICFlag );
    1343       bICFlag = bICFlag && (iWidth > 8);
    1344       xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
    1345 #if H_3D_ARP
     1344  for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)
     1345  {
     1346    const ComponentID compID=ComponentID(comp);
     1347#if NH_3D_IC
     1348    Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ) && ( isLuma(compID) || (iWidth > 8) );
     1349      xPredInterBlk(compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID))
     1350#if NH_3D_ARP
    13461351        , false
    13471352#endif
    13481353        , bICFlag );
    13491354#else
    1350 
    1351   for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)
    1352   {
    1353     const ComponentID compID=ComponentID(comp);
    13541355    xPredInterBlk  (compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) );
    1355   }
    1356 #endif
    1357 #if H_3D_ARP
    1358     }
    1359   }
    1360 #endif
    1361 }
    1362 
    1363 #if H_3D_VSP
     1356#endif
     1357  }
     1358#if NH_3D_ARP
     1359  }
     1360#endif
     1361}
     1362
     1363#if NH_3D_VSP
    13641364Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
    13651365{
     
    13821382Void TComPrediction::xPredInterUniSubPU( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU, Int heightSubPU )
    13831383{
    1384   UInt numPartsInLine       = pcCU->getPic()->getNumPartInWidth();
     1384  UInt numPartsInLine       = pcCU->getPic()->getNumPartInCtuWidth();
    13851385  UInt horiNumPartsInSubPU  = widthSubPU >> 2;
    13861386  UInt vertNumPartsInSubPU  = (heightSubPU >> 2) * numPartsInLine;
     
    13981398      pcCU->clipMv(cMv);
    13991399
    1400       xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi );
    1401       xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi );
    1402 
    1403     }
    1404   }
    1405 }
    1406 
    1407 #endif
    1408 
    1409 #if H_3D_ARP
    1410 Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
    1411 {
    1412   Int         iRefIdx      = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
    1413   TComMv      cMv          = pNewMvFiled ? pNewMvFiled->getMv()     : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
     1400      xPredInterBlk( COMPONENT_Y,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
     1401      xPredInterBlk( COMPONENT_Cb, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) );
     1402      xPredInterBlk( COMPONENT_Cr, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) );
     1403    }
     1404  }
     1405}
     1406#endif
     1407
     1408#if NH_3D_ARP
     1409//temporal ARP
     1410Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
     1411{
     1412  Int         iRefIdx      = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
     1413  TComMv      cMv          = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
    14141414  Bool        bTobeScaled  = false;
    14151415  TComPic* pcPicYuvBaseCol = NULL;
    14161416  TComPic* pcPicYuvBaseRef = NULL;
    14171417
    1418 #if H_3D_NBDV
     1418#if NH_3D_NBDV
    14191419  DisInfo cDistparity;
    14201420  cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV;
     
    14251425  UChar dW = pcCU->getARPW ( uiPartAddr );
    14261426
    1427   {
    14281427    Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList);
    1429     if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() )
    1430     {
    1431       bTobeScaled = true;
    1432     }
    1433 
    1434     pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
    1435 
    1436     pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan );
    1437 
    1438     if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
     1428  if (arpRefIdx < 0 || !pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
    14391429    {
    14401430      dW = 0;
     
    14431433    else
    14441434    {
    1445       assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC() );
     1435    if( arpRefIdx != iRefIdx )
     1436    {
     1437      bTobeScaled = true;
     1438    }
     1439    pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
     1440    pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan );
    14461441    }
    14471442
     
    14501445      Int iCurrPOC    = pcCU->getSlice()->getPOC();
    14511446      Int iColRefPOC  = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx );
    1452       Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList,  0);
     1447    Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, arpRefIdx );
    14531448      Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC);
    14541449      if ( iScale != 4096 )
     
    14561451        cMv = cMv.scaleMv( iScale );
    14571452      }
    1458       iRefIdx = 0;
    1459     }
     1453    iRefIdx = arpRefIdx;
    14601454  }
    14611455
    14621456  pcCU->clipMv(cMv);
    14631457  TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec();
    1464   xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true );
    1465   xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true );
     1458
     1459  for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++)
     1460  {
     1461    const ComponentID compID=ComponentID(comp);
     1462    xPredInterBlk  ( compID,  pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
     1463  }
    14661464
    14671465  if( dW > 0 )
     
    14791477    pcCU->clipMv( cNBDV );
    14801478   
    1481     pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec();
    1482     xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true );
    1483     if (iWidth > 8)
    1484       xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true );
     1479    TComPicYuv* pcPicYuvBaseColRec = pcPicYuvBaseCol->getPicYuvRec();
     1480    TComPicYuv* pcPicYuvBaseRefRec = pcPicYuvBaseRef->getPicYuvRec();
    14851481   
    1486     pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec();
    1487     xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true );
    1488  
    1489     if (iWidth > 8)
    1490       xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true );
     1482    UInt uiCompNum = ( iWidth > 8 ) ? 3: 1;
     1483    for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++)
     1484    {
     1485      const ComponentID compID=ComponentID(comp);
     1486      xPredInterBlk  ( compID,  pcCU, pcPicYuvBaseColRec, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
     1487      xPredInterBlk  ( compID,  pcCU, pcPicYuvBaseRefRec, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
     1488    }   
    14911489   
    14921490    pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight );
     
    14961494      pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
    14971495    }
    1498     rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi );
     1496    rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() );
    14991497  }
    15001498}
     
    15051503  TComMv      cDMv          = pcCU->getCUMvField( eBaseRefPicList )->getMv( uiPartAddr );
    15061504  TComPic* pcPicYuvBaseCol  = pcCU->getSlice()->getRefPic( eBaseRefPicList, iRefIdx ); 
    1507   TComPicYuv* pcYuvBaseCol  = pcPicYuvBaseCol->getPicYuvRec();
    1508   Int uiLCUAddr,uiAbsPartAddr;
    15091505  Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
    15101506  Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
     
    15121508  irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
    15131509  irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); 
    1514   pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
    1515   TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
     1510
     1511  Int uiLCUAddr,uiAbsPartAddr;
     1512  pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
     1513  TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr );
    15161514
    15171515  TComPic* pcPicYuvBaseTRef = NULL;
     
    15651563}
    15661564
    1567 Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
     1565//inter-view ARP
     1566Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
    15681567{
    15691568  Int         iRefIdx       = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
     
    15781577  Bool bTMVAvai = false;     
    15791578  TComMv cBaseTMV;
    1580   if( pNewMvFiled )
    1581   {
    1582     iRefIdx = pNewMvFiled->getRefIdx();
    1583     cDMv = pNewMvFiled->getMv();
    1584   }
     1579
    15851580  pcCU->clipMv(cTempDMv);
    15861581
    1587   assert(dW > 0);
    1588   if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, pcPicYuvBaseCol->getViewIndex()))
    1589   {
    1590     dW = 0;
    1591   }
    1592   Int uiLCUAddr,uiAbsPartAddr;
    15931582  Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
    15941583  Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
     
    15961585  irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
    15971586  irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY); 
    1598   pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
    1599   TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
     1587 
     1588  Int uiLCUAddr,uiAbsPartAddr;
     1589  pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
     1590  TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr );
    16001591  if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getIsDepth() )
    16011592  {
     
    16681659      RefPicList eRefPicListCurr = RefPicList(iList);
    16691660      Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr);
    1670       if( iRef != -1)
     1661      if( iRef != -1 && pcCU->getSlice()->getArpRefPicAvailable( eRefPicListCurr, pcPicYuvBaseCol->getViewIndex()))
    16711662      {
    16721663        pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef); 
     
    17021693  }
    17031694
    1704   xPredInterLumaBlk  ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ),        bTMVAvai);
    1705   xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ),        bTMVAvai);
    1706 
    1707   if( dW > 0 && bTMVAvai )
    1708   {
     1695  for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++)
     1696  {
     1697    const ComponentID compID=ComponentID(comp);
     1698    xPredInterBlk  ( compID,  pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), bTMVAvai );
     1699  }
     1700
     1701  if( dW > 0 )
     1702  {
     1703    assert ( bTMVAvai );
    17091704    TComYuv*    pYuvCurrTRef    = &m_acYuvPredBase[0];
    17101705    TComYuv*    pYuvBaseTRef    = &m_acYuvPredBase[1];
     
    17201715      pYuvCurrTRef->clear(); pYuvBaseTRef->clear();
    17211716    }
    1722     xPredInterLumaBlk  ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true,   true);
    1723 
    1724     if (iWidth > 8)
    1725       xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true,   true);
    1726 
    1727     xPredInterLumaBlk  ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, true,   true);
    1728 
    1729     if (iWidth > 8)
    1730       xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, true,   true);
     1717
     1718    UInt uiCompNum = ( iWidth > 8 ) ? 3: 1;
     1719    for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++)
     1720    {
     1721      const ComponentID compID=ComponentID(comp);
     1722      xPredInterBlk  ( compID,  pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
     1723      xPredInterBlk  ( compID,  pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
     1724    }
    17311725
    17321726    pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight ); 
     
    17351729      pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
    17361730    }
    1737     rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi );
     1731    rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() );
    17381732  }
    17391733}
     
    17901784}
    17911785
    1792 #if H_3D_VSP
    1793 
     1786#if NH_3D_VSP
    17941787Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred )
    17951788{
     
    18131806  }
    18141807
    1815   xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
    1816 }
    1817 
     1808  xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, pcCU->getSlice()->getSPS()->getBitDepths() );
     1809}
    18181810#endif
    18191811
     
    18351827
    18361828Void TComPrediction::xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth
    1837 #if H_3D_ARP
     1829#if NH_3D_ARP
    18381830    , Bool filterType
    18391831#endif
    1840 #if H_3D_IC
     1832#if NH_3D_IC
    18411833    , Bool bICFlag
    18421834#endif
     
    18571849  Int     yFrac  = mv->getVer() & ((1<<shiftVer)-1);
    18581850
    1859 #if H_3D_IC
     1851#if NH_3D_INTEGER_MV_DEPTH
    18601852  if( cu->getSlice()->getIsDepth() )
    18611853  {
    18621854    refOffset = mv->getHor() + mv->getVer() * refStride;
    1863     ref       = refPic->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refOffset;
     1855    ref       = refPic->getAddr(compID, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refOffset;
    18641856    xFrac     = 0;
    18651857    yFrac     = 0;
     
    18741866  if ( yFrac == 0 )
    18751867  {
    1876 #if H_3D_IC
    1877     m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi || bICFlag
     1868#if NH_3D_IC
     1869    m_if.filterHor(compID, ref, refStride, dst,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag, chFmt, bitDepth
    18781870#else
    18791871    m_if.filterHor(compID, ref, refStride, dst,  dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth
    18801872#endif
    1881 #if H_3D_ARP
     1873#if NH_3D_ARP
    18821874    , filterType
    18831875#endif
     
    18861878  else if ( xFrac == 0 )
    18871879  {
    1888 #if H_3D_IC
    1889     m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi || bICFlag
     1880#if NH_3D_IC
     1881    m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag, chFmt, bitDepth
    18901882#else
    18911883    m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth
    18921884#endif
    1893 #if H_3D_ARP
     1885#if NH_3D_ARP
    18941886    , filterType
    18951887#endif
     
    19041896
    19051897    m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false,      chFmt, bitDepth
    1906 #if H_3D_ARP
     1898#if NH_3D_ARP
    19071899    , filterType
    19081900#endif
    19091901);
    1910 #if H_3D_IC
    1911     m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi || bICFlag
     1902#if NH_3D_IC
     1903    m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight,               yFrac, false, !bi || bICFlag, chFmt, bitDepth
    19121904#else
    19131905    m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight,               yFrac, false, !bi, chFmt, bitDepth
    19141906#endif
    1915 #if H_3D_ARP
     1907#if NH_3D_ARP
    19161908    , filterType
    19171909#endif
     
    19191911  }
    19201912
    1921 #if H_3D_IC
     1913#if NH_3D_IC
    19221914  if( bICFlag )
    19231915  {
    19241916    Int a, b, i, j;
    19251917    const Int iShift = IC_CONST_SHIFT;
    1926 
    1927     xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_LUMA );
    1928 
    1929 
    1930     for ( i = 0; i < height; i++ )
    1931     {
    1932       for ( j = 0; j < width; j++ )
    1933       {
    1934           dst[j] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, ( ( a*dst[j] ) >> iShift ) + b );
     1918    Pel *dst2 = dst;
     1919
     1920    xGetLLSICPrediction( compID, cu, mv, refPic, a, b, bitDepth );
     1921
     1922    for ( i = 0; i < cxHeight; i++ )
     1923    {
     1924      for ( j = 0; j < cxWidth; j++ )
     1925      {
     1926        dst[j] = Clip3( 0, ( 1 << bitDepth ) - 1, ( ( a*dst[j] ) >> iShift ) + b );
    19351927      }
    19361928      dst += dstStride;
     
    19391931    if(bi)
    19401932    {
    1941       Pel *dst2      = dstPic->getLumaAddr( partAddr );
    1942       Int shift = IF_INTERNAL_PREC - g_bitDepthY;
    1943       for (i = 0; i < height; i++)
    1944       {
    1945         for (j = 0; j < width; j++)
    1946         {
    1947           Short val = dst2[j] << shift;
    1948           dst2[j] = val - (Short)IF_INTERNAL_OFFS;
     1933      Int shift = IF_INTERNAL_PREC - bitDepth;
     1934      for (i = 0; i < cxHeight; i++)
     1935      {
     1936        for (j = 0; j < cxWidth; j++)
     1937        {
     1938          Pel val = dst2[j] << shift;
     1939          dst2[j] = val - (Pel)IF_INTERNAL_OFFS;
    19491940        }
    19501941        dst2 += dstStride;
     
    19561947}
    19571948
    1958 
    1959 #if H_3D_ARP
    1960     , Bool filterType
    1961 #endif
    1962 #if H_3D_IC
    1963     , Bool bICFlag
    1964 #endif
    1965 #if H_3D_IC
    1966     m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag
    1967 #else
    1968 #endif
    1969 #if H_3D_ARP
    1970     , filterType
    1971 #endif
    1972 #if H_3D_IC
    1973     m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag
    1974 #else
    1975 #endif
    1976 #if H_3D_ARP
    1977     , filterType
    1978 #endif
    1979 #if H_3D_IC
    1980     m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
    1981 #else
    1982 #endif
    1983 #if H_3D_ARP
    1984     , filterType
    1985 #endif
    1986 #if H_3D_IC
    1987     m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
    1988 #else
    1989 #endif
    1990 #if H_3D_ARP
    1991     , filterType
    1992 #endif
    1993 #if H_3D_ARP
    1994     , filterType
    1995 #endif 
    1996 #if H_3D_IC
    1997     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
    1998 #else
    1999 #endif
    2000 #if H_3D_ARP
    2001     , filterType
    2002 #endif
    2003 #if H_3D_ARP
    2004     , filterType
    2005 #endif
    2006 #if H_3D_IC
    2007     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
    2008 #else
    2009 #endif
    2010 #if H_3D_ARP
    2011     , filterType
    2012 #endif
    2013 #if H_3D_IC
    2014   if( bICFlag )
    2015   {
    2016     Int a, b, i, j;
    2017     const Int iShift = IC_CONST_SHIFT;
    2018 
    2019     xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_U ); // Cb
    2020     for ( i = 0; i < cxHeight; i++ )
    2021     {
    2022       for ( j = 0; j < cxWidth; j++ )
    2023       {
    2024           dstCb[j] = Clip3(  0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCb[j] ) >> iShift ) + b );
    2025       }
    2026       dstCb += dstStride;
    2027     }
    2028     xGetLLSICPrediction( cu, mv, refPic, a, b, TEXT_CHROMA_V ); // Cr
    2029     for ( i = 0; i < cxHeight; i++ )
    2030     {
    2031       for ( j = 0; j < cxWidth; j++ )
    2032       {
    2033           dstCr[j] = Clip3( 0, ( 1 << g_bitDepthC ) - 1, ( ( a*dstCr[j] ) >> iShift ) + b );
    2034       }
    2035       dstCr += dstStride;
    2036     }
    2037 
    2038     if(bi)
    2039     {
    2040       Pel* dstCb2 = dstPic->getCbAddr( partAddr );
    2041       Pel* dstCr2 = dstPic->getCrAddr( partAddr );
    2042       Int shift = IF_INTERNAL_PREC - g_bitDepthC;
    2043       for (i = 0; i < cxHeight; i++)
    2044       {
    2045         for (j = 0; j < cxWidth; j++)
    2046         {
    2047           Short val = dstCb2[j] << shift;
    2048           dstCb2[j] = val - (Short)IF_INTERNAL_OFFS;
    2049 
    2050           val = dstCr2[j] << shift;
    2051           dstCr2[j] = val - (Short)IF_INTERNAL_OFFS;
    2052         }
    2053         dstCb2 += dstStride;
    2054         dstCr2 += dstStride;
    2055       }
    2056     }
    2057   }
    2058 #endif
    20591949Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* pcYuvDst, const BitDepths &clipBitDepths
    20601950 )
     
    22012091          (uiDirMode==HOR_IDX || uiDirMode==VER_IDX);
    22022092}
    2203 #if H_3D_IC
     2093#if NH_3D_IC
    22042094/** Function for deriving the position of first non-zero binary bit of a value
    22052095 * \param x input value
     
    22312121/** Function for deriving LM illumination compensation.
    22322122 */
    2233 Void TComPrediction::xGetLLSICPrediction( TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, TextType eType )
     2123Void TComPrediction::xGetLLSICPrediction( const ComponentID compID, TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, const Int bitDepth )
    22342124{
    22352125  TComPicYuv *pRecPic = pcCU->getPic()->getPicYuvRec();
    22362126  Pel *pRec = NULL, *pRef = NULL;
    22372127  UInt uiWidth, uiHeight, uiTmpPartIdx;
    2238   Int iRecStride = ( eType == TEXT_LUMA ) ? pRecPic->getStride() : pRecPic->getCStride();
    2239   Int iRefStride = ( eType == TEXT_LUMA ) ? pRefPic->getStride() : pRefPic->getCStride();
     2128  Int iRecStride = pRecPic->getStride(compID);
     2129  Int iRefStride = pRefPic->getStride(compID);
    22402130  Int iRefOffset, iHor, iVer;
    22412131  iHor = pcCU->getSlice()->getIsDepth() ? pMv->getHor() : ( ( pMv->getHor() + 2 ) >> 2 );
    22422132  iVer = pcCU->getSlice()->getIsDepth() ? pMv->getVer() : ( ( pMv->getVer() + 2 ) >> 2 );
    2243   if( eType != TEXT_LUMA )
     2133  if( !isLuma(compID) )
    22442134  {
    22452135    iHor = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getHor() + 1 ) >> 1 ) : ( ( pMv->getHor() + 4 ) >> 3 );
    22462136    iVer = pcCU->getSlice()->getIsDepth() ? ( ( pMv->getVer() + 1 ) >> 1 ) : ( ( pMv->getVer() + 4 ) >> 3 );
    22472137  }
    2248   uiWidth  = ( eType == TEXT_LUMA ) ? pcCU->getWidth( 0 )  : ( pcCU->getWidth( 0 )  >> 1 );
    2249   uiHeight = ( eType == TEXT_LUMA ) ? pcCU->getHeight( 0 ) : ( pcCU->getHeight( 0 ) >> 1 );
     2138  uiWidth  = pcCU->getWidth( 0 ) >> pRefPic->getComponentScaleX(compID);
     2139  uiHeight = pcCU->getHeight( 0 ) >> pRefPic->getComponentScaleY(compID);
    22502140
    22512141  Int i, j, iCountShift = 0;
    22522142
    2253   // LLS parameters estimation -->
     2143  // LLS parameters estimation
    22542144
    22552145  Int x = 0, y = 0, xx = 0, xy = 0;
    2256   Int precShift = std::max(0, (( eType == TEXT_LUMA ) ? g_bitDepthY : g_bitDepthC) - 12);
    2257 
    2258   if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) )
     2146  Int precShift = std::max(0, bitDepth - 12);
     2147
     2148  UInt partAddr = 0;
     2149  if( pcCU->getPUAbove( uiTmpPartIdx, pcCU->getZorderIdxInCtu() ) )
    22592150  {
    22602151    iRefOffset = iHor + iVer * iRefStride - iRefStride;
    2261     if( eType == TEXT_LUMA )
    2262     {
    2263       pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2264       pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride;
    2265     }
    2266     else if( eType == TEXT_CHROMA_U )
    2267     {
    2268       pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2269       pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride;
    2270     }
    2271     else
    2272     {
    2273       assert( eType == TEXT_CHROMA_V );
    2274       pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2275       pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - iRecStride;
    2276     }
    2277 
     2152    pRef = pRefPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) + iRefOffset;
     2153    pRec = pRecPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) - iRecStride;
    22782154    for( j = 0; j < uiWidth; j+=2 )
    22792155    {
    22802156      x += pRef[j];
    22812157      y += pRec[j];
    2282       if ( eType == TEXT_LUMA )
     2158      if( isLuma(compID) )
    22832159      {
    22842160        xx += (pRef[j] * pRef[j])>>precShift;
     
    22892165  }
    22902166
    2291   if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCU() ) )
     2167  if( pcCU->getPULeft( uiTmpPartIdx, pcCU->getZorderIdxInCtu() ) )
    22922168  {
    22932169    iRefOffset = iHor + iVer * iRefStride - 1;
    2294     if( eType == TEXT_LUMA )
    2295     {
    2296       pRef = pRefPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2297       pRec = pRecPic->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1;
    2298     }
    2299     else if( eType == TEXT_CHROMA_U )
    2300     {
    2301       pRef = pRefPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2302       pRec = pRecPic->getCbAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1;
    2303     }
    2304     else
    2305     {
    2306       assert( eType == TEXT_CHROMA_V );
    2307       pRef = pRefPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) + iRefOffset;
    2308       pRec = pRecPic->getCrAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() ) - 1;
    2309     }
    2310 
     2170    pRef = pRefPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) + iRefOffset;
     2171    pRec = pRecPic->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + partAddr ) - 1;
    23112172    for( i = 0; i < uiHeight; i+=2 )
    23122173    {
    23132174      x += pRef[0];
    23142175      y += pRec[0];
    2315       if ( eType == TEXT_LUMA )
     2176      if( isLuma(compID) )
    23162177      {
    23172178        xx += (pRef[0] * pRef[0])>>precShift;
     
    23312192  }
    23322193
    2333   if (  eType != TEXT_LUMA )
    2334   {
    2335     a = 32;
     2194  if( !isLuma(compID) )
     2195  {
     2196    a = ( 1 << IC_CONST_SHIFT );
    23362197    b = (  y - x + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift;
    23372198  }
     
    23432204  Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift);
    23442205  const Int iShift = IC_CONST_SHIFT;
    2345   {
    2346     {
    23472206      const Int iShiftA2 = 6;
    23482207      const Int iAccuracyShift = 15;
     
    23502209      Int iScaleShiftA2 = 0;
    23512210      Int iScaleShiftA1 = 0;
    2352       Int a1s = a1;
    2353       Int a2s = a2;
     2211    Int a1s;
     2212    Int a2s;
    23542213
    23552214      a1 = Clip3(0, 2*a2, a1);
     
    23792238    }
    23802239  }   
    2381   }
    2382 }
    23832240#endif
    23842241
Note: See TracChangeset for help on using the changeset viewer.