Ignore:
Timestamp:
6 Sep 2013, 00:42:44 (11 years ago)
Author:
tech
Message:

Cleanups and macro removals related to merge and vsp

  • MTK_VSP_FIX_ALIGN_WD_E0172
  • H_3D_FIX_BVSP
  • QC_INRIA_MTK_MRG_E0126
  • MTK_DVMCP_FIX_E0172
  • TComDataCU::xAddVspCand
  • TComDataCU::xAddIvMRGCand
  • TComDataCU::getInterMergeCandidates
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-8.0-dev0/source/Lib/TLibCommon/TComDataCU.cpp

    r612 r615  
    146146#if H_3D_VSP
    147147  m_piVSPFlag            = NULL;
    148 #if MTK_VSP_FIX_E0172
    149   m_piVSPDir             = NULL;
    150 #endif
    151148#endif
    152149#if H_3D_ARP
     
    200197#if H_3D_VSP
    201198    m_piVSPFlag          = (Char*  )xMalloc(Char,   uiNumPartition);
    202 #if MTK_VSP_FIX_E0172
    203     m_piVSPDir           = (Char*  )xMalloc(Char,   uiNumPartition);
    204 #endif
    205199#endif
    206200    m_puhLumaIntraDir    = (UChar* )xMalloc(UChar,  uiNumPartition);
     
    363357#if H_3D_VSP
    364358    if ( m_piVSPFlag          ) { xFree(m_piVSPFlag);           m_piVSPFlag         = NULL; }
    365 #if MTK_VSP_FIX_E0172
    366     if ( m_piVSPDir           ) { xFree(m_piVSPDir  );          m_piVSPDir          = NULL; }
    367 #endif
    368359#endif
    369360    if ( m_puhLumaIntraDir    ) { xFree(m_puhLumaIntraDir);     m_puhLumaIntraDir   = NULL; }
     
    573564#if H_3D_VSP
    574565    m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui];
    575 #if MTK_VSP_FIX_E0172
    576     m_piVSPDir  [ui] = pcFrom->m_piVSPDir[ui];
    577 #endif
    578566#endif
    579567    m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui];
     
    618606#if H_3D_VSP
    619607    memset( m_piVSPFlag         + firstElement, 0,                        numElements * sizeof( *m_piVSPFlag ) );
    620 #if MTK_VSP_FIX_E0172
    621     memset( m_piVSPDir          + firstElement, 0,                        numElements * sizeof( *m_piVSPDir   ) );
    622 #endif
    623608#endif
    624609    memset( m_puhLumaIntraDir   + firstElement, DC_IDX,                   numElements * sizeof( *m_puhLumaIntraDir ) );
     
    802787#if H_3D_VSP
    803788      m_piVSPFlag[ui] = 0;
    804 #if MTK_VSP_FIX_E0172
    805       m_piVSPDir  [ui] = 0;
    806 #endif
    807789#endif
    808790      m_puhLumaIntraDir[ui] = DC_IDX;
     
    906888#if H_3D_VSP
    907889  memset( m_piVSPFlag,          0, sizeof( Char  ) * m_uiNumPartition );
    908 #if MTK_VSP_FIX_E0172
    909   memset( m_piVSPDir  ,         0, sizeInChar );
    910 #endif
    911890#endif
    912891  memset( m_puhLumaIntraDir,    DC_IDX, iSizeInUchar );
     
    1005984#if H_3D_VSP
    1006985      m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui];
    1007 #if MTK_VSP_FIX_ALIGN_WD_E0172
    1008986      m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];
    1009 #endif
    1010 #if MTK_VSP_FIX_E0172
    1011       m_piVSPDir[ui]=pcCU->m_piVSPDir[uiPartOffset+ui];
    1012 #endif
    1013987#endif
    1014988      m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui];
     
    11621136#if H_3D_VSP
    11631137  m_piVSPFlag           = pcCU->getVSPFlag()          + uiPart;
    1164 #if MTK_VSP_FIX_E0172
    1165   m_piVSPDir            = pcCU->getVSPDir  ()         + uiPart;
    1166 #endif
    11671138#endif
    11681139
     
    13211292#if H_3D_VSP
    13221293  m_piVSPFlag          = pcCU->getVSPFlag()               + uiAbsPartIdx;
    1323 #if MTK_VSP_FIX_ALIGN_WD_E0172
    13241294  m_pDvInfo            = pcCU->getDvInfo()                + uiAbsPartIdx;
    1325 #endif
    1326 #if MTK_VSP_FIX_E0172
    1327   m_piVSPDir           = pcCU->getVSPDir  ()              + uiAbsPartIdx;
    1328 #endif
    13291295#endif
    13301296
     
    13741340#if H_3D_VSP
    13751341  memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( Char ) * uiNumPartition );
    1376 #if MTK_VSP_FIX_ALIGN_WD_E0172
    13771342  memcpy( m_pDvInfo             + uiOffset, pcCU->getDvInfo(),            sizeof( *m_pDvInfo ) * uiNumPartition );
    1378 #endif
    1379 #if MTK_VSP_FIX_E0172
    1380   memcpy( m_piVSPDir            + uiOffset, pcCU->getVSPDir  (),          sizeInChar );
    1381 #endif
     1343
    13821344#endif
    13831345  memcpy( m_puhLumaIntraDir     + uiOffset, pcCU->getLumaIntraDir(),      iSizeInUchar );
     
    15091471#if H_3D_VSP
    15101472  memcpy( rpcCU->getVSPFlag()           + m_uiAbsIdxInLCU, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
    1511 #if MTK_VSP_FIX_ALIGN_WD_E0172
    15121473  memcpy( rpcCU->getDvInfo()            + m_uiAbsIdxInLCU, m_pDvInfo,             sizeof( *m_pDvInfo ) * m_uiNumPartition );
    1513 #endif
    1514 #if MTK_VSP_FIX_E0172
    1515   memcpy( rpcCU->getVSPDir  ()          + m_uiAbsIdxInLCU, m_piVSPDir  ,          sizeInChar );
    1516 #endif
    15171474#endif
    15181475  memcpy( rpcCU->getLumaIntraDir()      + m_uiAbsIdxInLCU, m_puhLumaIntraDir,     iSizeInUchar );
     
    16321589#if H_3D_VSP
    16331590  memcpy( rpcCU->getVSPFlag()           + uiPartOffset, m_piVSPFlag,           sizeof(Char) * uiQNumPart );
    1634 #if MTK_VSP_FIX_E0172
    1635   memcpy( rpcCU->getVSPDir  ()          + uiPartOffset, m_piVSPDir  ,          sizeInChar );
    1636 #endif
    16371591#endif
    16381592  memcpy( rpcCU->getLumaIntraDir()      + uiPartOffset, m_puhLumaIntraDir,     iSizeInUchar );
     
    27612715  setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
    27622716}
    2763 #if MTK_VSP_FIX_ALIGN_WD_E0172
     2717#if H_3D_VSP
    27642718template<typename T>
    27652719Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx )
     
    28952849  }
    28962850
    2897 }
    2898 #endif
    2899 #if MTK_VSP_FIX_E0172
    2900 Void TComDataCU::setVSPDirSubParts ( Char iVSPDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
    2901 {
    2902   setSubPart<Char>( iVSPDir, m_piVSPDir, uiAbsPartIdx, uiDepth, uiPartIdx );
    29032851}
    29042852#endif
     
    33553303 *   false: otherwise
    33563304 */
    3357 #if MTK_VSP_FIX_E0172
    3358 inline Bool TComDataCU::xAddVspCand( UChar ucVspMergePos, Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
    3359                                     Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag, Int* vspDir )
    3360 #else
    3361 inline Bool TComDataCU::xAddVspCand( UChar ucVspMergePos, Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
     3305inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
    33623306                                     Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag )
    3363 #endif
    3364 {
    3365   if ( ucVspMergePos != H_3D_VSP_POSITION || 0 == m_pcSlice->getViewIndex() || !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) || m_pcSlice->getIsDepth() )
     3307{
     3308  if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) || m_pcSlice->getIsDepth() )
     3309  {
    33663310    return false;
     3311  }
    33673312
    33683313  Int refViewIdx = pDInfo->m_aVIdxCan;
    33693314  TComPic* picDepth = getSlice()->getIvPic( true, refViewIdx );
     3315 
    33703316  if( picDepth == NULL ) // No depth reference avail
     3317  {
     3318    // Is this allowed to happen? When not an assertion should be added here!
    33713319    return false;
    3372  
    3373   Bool refViewAvailFlag = false;
    3374   UChar predFlag[2] = {0, 0};
    3375   Int  iRefListIdX = 0;
    3376   Int  iRefListIdY = 0;
    3377   Int  i;
    3378 #if MTK_VSP_FIX_ALIGN_WD_E0172
    3379   Int currViewId = m_pcSlice->getViewId();
    3380   Int derivedViewId = -1;
    3381   Int otherViewId = -1;
    3382 #endif
    3383 #if MTK_VSP_FIX_E0172
    3384   Int currViewId = m_pcSlice->getViewId();
    3385   Int derivedViewId = -1;
    3386   Int otherViewId = -1;
    3387 #endif
    3388   for( iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ )
    3389   {
    3390     RefPicList eRefPicList = RefPicList( iRefListIdX );
    3391     for ( i = 0; i < m_pcSlice->getNumRefIdx(eRefPicList) && !refViewAvailFlag; i++ )
    3392     {
    3393       Int viewIdxRefInList = m_pcSlice->getRefPic(eRefPicList, i)->getViewIndex();
    3394       if ( viewIdxRefInList == refViewIdx )
    3395       {
    3396         refViewAvailFlag = true;
     3320  }
     3321 
     3322  Bool  refViewAvailFlag = false;
     3323  UChar predFlag[2]      = {0, 0}; 
     3324  Int   refListIdY       = 0;   
     3325  Int   viewIdInRefListX = -1;
     3326 
     3327  for( Int iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ )
     3328  {
     3329    RefPicList eRefPicListX = RefPicList( iRefListIdX );
     3330    for ( Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicListX) && !refViewAvailFlag; i++ )
     3331    {
     3332      Int viewIdxRefInListX = m_pcSlice->getRefPic(eRefPicListX, i)->getViewIndex();
     3333      if ( viewIdxRefInListX == refViewIdx )
     3334      {
     3335        refViewAvailFlag      = true;
    33973336        predFlag[iRefListIdX] = 1;
    3398 #if MTK_VSP_FIX_ALIGN_WD_E0172
    3399         derivedViewId = m_pcSlice->getRefPic(eRefPicList, i)->getViewId();
    3400 #endif
    3401 #if MTK_VSP_FIX_E0172
    3402         vspDir[iCount] = iRefListIdX;
    3403         derivedViewId = m_pcSlice->getRefPic(eRefPicList, i)->getViewId();
    3404 #endif
    3405         iRefListIdY = 1 - iRefListIdX;
    3406 #if H_3D_FIX_BVSP
     3337        viewIdInRefListX      = m_pcSlice->getRefPic(eRefPicListX, i)->getViewId();
     3338        refListIdY            = 1 - iRefListIdX;
    34073339        pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acNBDV, i );
    3408 #else
    3409         pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acDoNBDV, i );
    3410 #endif
    34113340#if H_3D_NBDV
    34123341        pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].getMv().setIDVFlag (false);
     
    34183347  if (m_pcSlice->isInterB() && refViewAvailFlag)
    34193348  {
    3420     RefPicList eRefPicList = RefPicList( iRefListIdY );
     3349    RefPicList eRefPicListY = RefPicList( refListIdY );
    34213350    refViewAvailFlag = false;
    3422     for ( i = 0; i < m_pcSlice->getNumRefIdx(eRefPicList) && !refViewAvailFlag; i++ )
    3423     {
    3424       Int viewIdxRefInList = m_pcSlice->getRefPic(eRefPicList, i)->getViewIndex();
    3425       if ( viewIdxRefInList != refViewIdx && viewIdxRefInList != m_pcSlice->getViewIndex() )
     3351    for ( Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicListY) && !refViewAvailFlag; i++ )
     3352    {
     3353      Int viewIdxRefInListY = m_pcSlice->getRefPic(eRefPicListY, i)->getViewIndex();
     3354      if ( viewIdxRefInListY != refViewIdx && viewIdxRefInListY != m_pcSlice->getViewIndex() )
    34263355      {
    34273356        refViewAvailFlag = true;
    3428         predFlag[iRefListIdY] = 1;
    3429 #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172
    3430 #if H_3D_FIX_BVSP
     3357        predFlag[refListIdY] = 1;
    34313358        TComMv  cMv = pDInfo->m_acNBDV;
    3432 #else
    3433         TComMv  cMv = pDInfo->m_acDoNBDV;
    3434 #endif
    3435         otherViewId = m_pcSlice->getRefPic( eRefPicList, i)->getViewId();
    3436         Int iScale = xGetDistScaleFactor( currViewId, otherViewId, currViewId, derivedViewId );
     3359       
     3360        Int viewIdInRefListY = m_pcSlice->getRefPic( eRefPicListY, i)->getViewId();
     3361        Int currViewId       = m_pcSlice->getViewId();
     3362       
     3363        //// Following might be added here when MV-HEVC 5 HLS is included (and derivations above removed):
     3364        // Int viewIdInRefListX = m_pcSlice->getVPS()->getViewIdVal( refViewIdx  );
     3365       
     3366        Int iScale      = xGetDistScaleFactor( currViewId, viewIdInRefListY, currViewId, viewIdInRefListX );
     3367       
     3368        // Can iScale == 4096 happen?, I guess not since viewIdInRefListY is always unequal to viewIdInRefListX.
    34373369        if ( iScale != 4096 && m_pcSlice->getVPS()->getIvMvScalingFlag() )
    34383370        {
     
    34453377        }
    34463378        clipMv( cMv );
    3447         pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].setMvField( cMv, i );
    3448 #else
    3449 #if H_3D_FIX_BVSP
    3450         pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].setMvField( pDInfo->m_acNBDV, i );
    3451 #else
    3452         pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].setMvField( pDInfo->m_acDoNBDV, i );
    3453 #endif
    3454 #endif
     3379        pcMvFieldNeighbours[(iCount<<1)+refListIdY].setMvField( cMv, i );
    34553380#if H_3D_NBDV
    3456         pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].getMv().setIDVFlag (false);
     3381        pcMvFieldNeighbours[(iCount<<1)+refListIdY].getMv().setIDVFlag (false);
    34573382#endif
    34583383      }
     
    34613386
    34623387  // Set values to be returned
    3463   abCandIsInter[iCount] = true;
     3388  abCandIsInter        [iCount] = true;
    34643389  puhInterDirNeighbours[iCount] = (predFlag[0] | (predFlag[1] << 1));
    3465   vspFlag[iCount] = 1;
     3390  vspFlag              [iCount] = 1;
    34663391
    34673392  if ( mrgCandIdx == iCount )
     3393  {
    34683394    return true;
     3395  }
    34693396
    34703397  iCount++;
     
    34753402#endif
    34763403
    3477 #if QC_INRIA_MTK_MRG_E0126
    3478 inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int*   iPdmDir, TComMv* acPdmMv,
    3479                                        Int* aiPdmRefIdx, Int iPosDmv, Int* vspFlag )
    3480 {
    3481   for(Int iLoop = 0; iLoop  < 2; iLoop ++ )
    3482   {
     3404#if H_3D_IV_MERGE
     3405inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* ivCandDir, TComMv* ivCandMv,
     3406                                       Int* ivCandRefIdx, Int iPosIvDC, Int* vspFlag )
     3407{
     3408  for(Int iLoop = 0; iLoop < 2; iLoop ++ )
     3409  {
     3410    // IvDcShift (Derived from spatial Iv neighboring blocks)
    34833411    if( iLoop == 1 )
    34843412    {
    34853413      Int iFirDispCand = -1;
    3486       if (xFirstDmvAvai(iCount, pcMvFieldNeighbours, iPdmDir, iPosDmv, vspFlag, iFirDispCand))
     3414      if (xGetPosFirstAvailDmvCand(iCount, pcMvFieldNeighbours, ivCandDir, iPosIvDC, vspFlag, iFirDispCand))
    34873415      {
    34883416        TComMv cMv;
     
    34943422        }
    34953423        clipMv( cMv );
    3496         abCandIsInter[ iCount ] = true;
     3424        abCandIsInter        [ iCount ] = true;
    34973425        puhInterDirNeighbours[ iCount ] = puhInterDirNeighbours[iFirDispCand];
    3498         pcMvFieldNeighbours[ iCount<<1  ].setMvField(cMv, pcMvFieldNeighbours[( iFirDispCand << 1)].getRefIdx() );
    3499         pcMvFieldNeighbours[ (iCount<<1)+1 ].setMvField(pcMvFieldNeighbours[(iFirDispCand << 1) + 1].getMv(), pcMvFieldNeighbours[( iFirDispCand << 1) + 1].getRefIdx() );
     3426        pcMvFieldNeighbours  [ iCount << 1      ].setMvField(cMv, pcMvFieldNeighbours[( iFirDispCand << 1)].getRefIdx() );
     3427        pcMvFieldNeighbours  [(iCount << 1) + 1 ].setMvField(pcMvFieldNeighbours[(iFirDispCand << 1) + 1].getMv(), pcMvFieldNeighbours[( iFirDispCand << 1) + 1].getRefIdx() );
     3428       
    35003429        if( mrgCandIdx == iCount )
    35013430        {
    35023431          return true;
    35033432        }
     3433
    35043434        iCount++;
    35053435        break;
    35063436      }
    35073437    }
    3508     if(iPdmDir[iLoop + 2])
    3509     {
    3510       abCandIsInter[ iCount ] = true;
    3511       puhInterDirNeighbours[ iCount ] = iPdmDir[iLoop + 2];
    3512       if( ( iPdmDir[iLoop + 2] & 1 ) == 1 )
    3513       {
    3514         pcMvFieldNeighbours[ iCount<<1 ].setMvField( acPdmMv[ (iLoop<<1) + 4 ], aiPdmRefIdx[ (iLoop<<1) + 4 ] );
    3515       }
    3516       if( ( iPdmDir[iLoop + 2] & 2 ) == 2 )
    3517       {
    3518         pcMvFieldNeighbours[ (iCount<<1)+1 ].setMvField( acPdmMv[ (iLoop<<1) + 5 ], aiPdmRefIdx[ (iLoop<<1) + 5 ] );
     3438
     3439    /// iLoop = 0 --> IvMCShift
     3440    /// iLoop = 1 --> IvDCShift  (Derived from IvDC)
     3441    if(ivCandDir[iLoop + 2])
     3442    {
     3443      abCandIsInter        [ iCount ] = true;
     3444      puhInterDirNeighbours[ iCount ] = ivCandDir[iLoop + 2];
     3445      if( ( ivCandDir[iLoop + 2] & 1 ) == 1 )
     3446      {
     3447        pcMvFieldNeighbours[ iCount<<1 ].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] );
     3448      }
     3449      if( ( ivCandDir[iLoop + 2] & 2 ) == 2 )
     3450      {
     3451        pcMvFieldNeighbours[ (iCount<<1)+1 ].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] );
    35193452      }
    35203453     
    3521       bool bRemove = false;
    3522       if(!iLoop && iPdmDir[0] > 0)
    3523       {
    3524         if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[0] && pcMvFieldNeighbours[0]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[1]==pcMvFieldNeighbours[(iCount<<1)+1])
     3454      // Prune IvMC vs. IvMcShift
     3455      Bool bRemove = false;     
     3456      if( !iLoop && ivCandDir[0] > 0)
     3457      {
     3458        if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[0] && pcMvFieldNeighbours[0 ]== pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[1]==pcMvFieldNeighbours[(iCount<<1)+1])
    35253459        {
    3526             bRemove                      = true;
     3460            bRemove                         = true;
    35273461            abCandIsInter        [ iCount ] = false; 
    3528             puhInterDirNeighbours[iCount]  = 0;
     3462            puhInterDirNeighbours[ iCount ] = 0;
    35293463            TComMv  cZeroMv;
    3530             pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID );
    3531             pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID );
     3464            pcMvFieldNeighbours  [ iCount<<1   ].setMvField( cZeroMv, NOT_VALID );
     3465            pcMvFieldNeighbours  [(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID );
    35323466        }
    35333467      }
     
    35353469      {
    35363470#if H_3D_NBDV
    3537         if(iLoop)
     3471        if(iLoop) // For IvMcShift candidate
    35383472        {
    35393473          pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
     
    35533487}
    35543488
    3555 inline Bool TComDataCU::xFirstDmvAvai( Int& iCount, TComMvField* pcMvFieldNeighbours, Int* iPdmDir, Int iPosDmv, Int* vspFlag, Int& iFirDispCand )
    3556 {
    3557   for ( Int i = (iPdmDir[0] ? 1: 0); i < iCount; i++ )
    3558   {
    3559     if ( ( i == iPosDmv ) || ( vspFlag[ i ] == 1 ) )
     3489inline Bool TComDataCU::xGetPosFirstAvailDmvCand( Int iCount, TComMvField* pcMvFieldNeighbours, Int* ivCandDir, Int posIvDC, Int* vspFlag, Int& posFirstAvailDmvCand )
     3490{
     3491  // ivCandDir[0] == true --> IvMC is available and excluded in loop over merge list.
     3492  for ( Int currListPos = (ivCandDir[0] ? 1 : 0); currListPos < iCount; currListPos++ )
     3493  {
     3494    if ( ( currListPos == posIvDC ) || ( vspFlag[ currListPos ] == 1 ) )
    35603495    {
    35613496      continue;
    35623497    }
    3563     else if((pcMvFieldNeighbours[i<<1].getRefIdx()!=-1) && (getSlice()->getViewIndex() != getSlice()->getRefPic(RefPicList(0), pcMvFieldNeighbours[i<<1].getRefIdx())->getViewIndex()))
    3564     {
    3565       iFirDispCand = i;
     3498    else if((pcMvFieldNeighbours[currListPos<<1].getRefIdx() != -1 ) && (getSlice()->getViewIndex() != getSlice()->getRefPic(RefPicList(0), pcMvFieldNeighbours[currListPos<<1].getRefIdx())->getViewIndex()))
     3499    {
     3500      posFirstAvailDmvCand = currListPos;
    35663501      return true;
    35673502    }
     
    35823517#if H_3D_VSP
    35833518      , Int* vspFlag
    3584 #if MTK_VSP_FIX_ALIGN_WD_E0172
    35853519      , InheritedVSPDisInfo*  inheritedVSPDisInfo
    3586 #endif
    3587 #if MTK_VSP_FIX_E0172
    3588       , Int* vspDir
    3589 #endif
    35903520#endif
    35913521      , Int& numValidMergeCand, Int mrgCandIdx
     
    35943524  UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx;
    35953525#if H_3D_IV_MERGE
     3526  ////////////////////////////
     3527  //////// INIT LISTS ////////
     3528  ////////////////////////////
    35963529  TComMv cZeroMv;
    35973530  Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
     
    36113544  }
    36123545  numValidMergeCand = getSlice()->getMaxNumMergeCand();
     3546#if H_3D
     3547  //////////////////////////////////
     3548  //////// DERIVE LOCATIONS ////////
     3549  //////////////////////////////////
     3550#endif
    36133551  // compute the location of the current PU
    36143552  Int xP, yP, nPSW, nPSH;
     
    36223560  deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
    36233561#if H_3D_IV_MERGE
    3624   Bool ivMvPredFlag   = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() );
    3625 
    3626   //===== add merge with predicted depth maps =====
    3627 #if QC_INRIA_MTK_MRG_E0126
    3628   TComMv acPdmMv         [8];
    3629   Int aiPdmRefIdx        [8] = {-1, -1, -1, -1, -1, -1, -1, -1};
    3630   Int iPosDmv                = -1;
    3631 #else
    3632   TComMv  acPdmMv       [4];
    3633   Int     aiPdmRefIdx   [4] = {-1, -1, -1, -1};
    3634 #endif
    3635   Bool    bLeftAvai         = false;
    3636   Int     iPosLeftAbove[2]  = {-1, -1};
    3637 
    3638 
    3639   DisInfo cDisInfo;
    3640 
    3641   cDisInfo.bDV = getDvInfo(uiAbsPartIdx).bDV;
    3642 #if H_3D_NBDV_REF
    3643   cDisInfo.m_acDoNBDV = getDvInfo(uiAbsPartIdx).m_acDoNBDV;
    3644 #endif //H_3D_NBDV_REF
    3645   cDisInfo.m_acNBDV = getDvInfo(uiAbsPartIdx).m_acNBDV;
    3646   cDisInfo.m_aVIdxCan = getDvInfo(uiAbsPartIdx).m_aVIdxCan;
    3647 #if MTK_VSP_FIX_ALIGN_WD_E0172
    3648   for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++)
    3649   {
    3650     inheritedVSPDisInfo[i].m_acDvInfo = cDisInfo;
    3651   }
    3652 #endif
     3562 
     3563  /////////////////////////////////////////////
     3564  //////// TEXTURE MERGE CANDIDATE (T) ////////
     3565  /////////////////////////////////////////////
     3566
    36533567  if( m_pcSlice->getIsDepth())
    36543568  {
     
    36593573    if ( pcTextureCU && !pcTextureCU->isIntra( uiPartIdxCenter ) )
    36603574    {
    3661 #if MTK_TEXTURE_MRGCAND_BUGFIX_E0182
    36623575      pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    36633576      Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1].getRefIdx() );
     
    36993612        iCount ++;
    37003613      }
    3701 #else
    3702       abCandIsInter[iCount] = true;     
    3703       puhInterDirNeighbours[iCount] = pcTextureCU->getInterDir( uiPartIdxCenter );
    3704 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
    3705       pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3706       if (pcMvFieldNeighbours[iCount<<1].getRefIdx()>=0)
    3707 #else
    3708       if( ( puhInterDirNeighbours[iCount] & 1 ) == 1 )
    3709 #endif
    3710       {
    3711 #if !MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
    3712         pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
    3713 #endif
    3714         TComMv cMvPred = pcMvFieldNeighbours[iCount<<1].getMv();
    3715 
    3716 #if H_3D_IC
    3717         const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
    3718         cMvPred+=cAdd;
    3719         cMvPred>>=2;
    3720         clipMv(cMvPred);
    3721 #endif
    3722         //pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,pcMvFieldNeighbours[iCount<<1].getRefIdx());
    3723 #if H_3D //Notes from QC: for BVSP coded blocks, the reference index shall not be equal to -1 due to the adoption of JCT3V-D0191
    3724         pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,pcMvFieldNeighbours[iCount<<1].getRefIdx());
    3725 #endif
    3726       }
    3727      
    3728       if ( getSlice()->isInterB() )
    3729       {
    3730 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
    3731         pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3732         if (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()>=0)
    3733 #else
    3734         if( ( puhInterDirNeighbours[iCount] & 2 ) == 2 )
    3735 #endif
    3736         {
    3737 #if !MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
    3738           pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
    3739 #endif
    3740           TComMv cMvPred = pcMvFieldNeighbours[(iCount<<1)+1].getMv();
    3741 #if H_3D_IC
    3742           const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
    3743           cMvPred+=cAdd;
    3744           cMvPred>>=2;
    3745           clipMv(cMvPred);
    3746 #endif
    3747           pcMvFieldNeighbours[(iCount<<1)+1].setMvField(cMvPred,pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx());
    3748         }
    3749       }
    3750 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170
    3751       puhInterDirNeighbours[iCount] = (pcMvFieldNeighbours[iCount<<1].getRefIdx()>=0)?1:0;
    3752       puhInterDirNeighbours[iCount] += (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()>=0)?2:0;
    3753 #endif
    3754 #if H_3D_NBDV
    3755       pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
    3756       pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
    3757 #endif
    3758       if ( mrgCandIdx == iCount )
    3759       {
    3760         return;
    3761       }
    3762       iCount ++;
    3763 #endif//Bug fix
    3764     }
    3765   }
    3766 
    3767 #if QC_INRIA_MTK_MRG_E0126
    3768   Int iPdmDir[4] = {0, 0, 0, 0};
    3769 #else
    3770   Int iPdmDir[2] = {0, 0};
    3771 #endif
     3614    }
     3615  }
     3616
     3617  //////////////////////////////////
     3618  //////// GET DISPARITIES  ////////
     3619  //////////////////////////////////
     3620
     3621  DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
     3622
     3623  for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++)
     3624  {
     3625    inheritedVSPDisInfo[i].m_acDvInfo = cDisInfo;
     3626  }
     3627
     3628  /////////////////////////////////////////////////////////////////
     3629  //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC  Candidates /////
     3630  /////////////////////////////////////////////////////////////////
     3631
     3632  Int  posIvDC          = -1;
     3633  Bool bLeftAvai        = false;
     3634  Int  iPosLeftAbove[2] = {-1, -1};
     3635
     3636
     3637  // { IvMCL0, IvMCL1, IvDCL0, IvDCL1, IvMCL0Shift, IvMCL1Shift, IvDCL0Shift, IvDCL1Shift }; 
     3638  // An enumerator would be appropriate here!
     3639  TComMv ivCandMv    [8];
     3640  Int    ivCandRefIdx[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
     3641
     3642  // { IvMC, IvDC, IvMCShift, IvDCShift }; 
     3643  Int    ivCandDir   [4] = {0, 0, 0, 0};
     3644
     3645  Bool ivMvPredFlag   = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() );
    37723646 
    37733647  if ( ivMvPredFlag )
    37743648  {
    3775     getInterViewMergeCands(uiPUIdx, aiPdmRefIdx, acPdmMv, &cDisInfo, iPdmDir );
     3649    getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir );
    37763650  } 
    3777    
    3778   Int iPdmInterDir;
    3779 
    3780   if( iPdmDir[0] )
     3651 
     3652  ///////////////////////////////////////////////
     3653  //////// INTER VIEW MOTION COMP(IvMC) /////////
     3654  ///////////////////////////////////////////////
     3655
     3656  if( ivCandDir[0] )
    37813657  {
    37823658    abCandIsInter        [ iCount ] = true;
    3783     puhInterDirNeighbours[ iCount ] = iPdmDir[0];
    3784     iPdmInterDir                    = iPdmDir[0];
    3785 
    3786     if( ( iPdmInterDir & 1 ) == 1 )
    3787     {
    3788       pcMvFieldNeighbours[ iCount<<1    ].setMvField( acPdmMv[ 0 ], aiPdmRefIdx[ 0 ] );
    3789     }
    3790     if( ( iPdmInterDir & 2 ) == 2 )
    3791     {
    3792       pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 1 ], aiPdmRefIdx[ 1 ] );
     3659    puhInterDirNeighbours[ iCount ] = ivCandDir[0];   
     3660
     3661    if( ( ivCandDir[0] & 1 ) == 1 )
     3662    {
     3663      pcMvFieldNeighbours[ iCount<<1    ].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] );
     3664    }
     3665    if( ( ivCandDir[0] & 2 ) == 2 )
     3666    {
     3667      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] );
    37933668    }
    37943669
     
    37993674    iCount ++;
    38003675  }
     3676
    38013677  // early termination
    38023678  if (iCount == getSlice()->getMaxNumMergeCand())
     
    38063682#endif
    38073683
     3684#if H_3D
     3685  ////////////////////////////
     3686  //////// LEFT (A1) /////////
     3687  ////////////////////////////
     3688#endif
    38083689  //left
    38093690  UInt uiLeftPartIdx = 0;
     
    38523733#if H_3D_VSP
    38533734      if (pcCULeft->getVSPFlag(uiLeftPartIdx) == 1)
    3854 #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172
    3855       {
    3856 #endif
     3735      {
    38573736        vspFlag[iCount] = 1;
    3858 #if MTK_VSP_FIX_ALIGN_WD_E0172
    38593737        xInheritVSPDisInfo(pcCULeft,uiLeftPartIdx,iCount,inheritedVSPDisInfo);
    38603738      }
    38613739#endif
    3862 #if MTK_VSP_FIX_E0172
    3863         vspDir[iCount] = pcCULeft->getVSPDir( uiLeftPartIdx );
    3864       }
    3865 #endif
    3866 #endif
    38673740      if ( mrgCandIdx == iCount )
    38683741      {
     
    38713744      iCount ++;
    38723745    }
    3873 #else
     3746#else // H_3D_IV_MERGE
    38743747    if ( mrgCandIdx == iCount )
    38753748    {
     
    38773750    }
    38783751    iCount ++;
    3879 #endif
     3752#endif // H_3D_IV_MERGE
    38803753  }
    38813754 
     
    38853758    return;
    38863759  }
     3760#if H_3D
     3761  ////////////////////////////
     3762  //////// ABOVE (B1) ////////
     3763  ////////////////////////////
     3764#endif
    38873765  // above
    38883766  UInt uiAbovePartIdx = 0;
     
    39173795        puhInterDirNeighbours[iCount]   = 0;
    39183796
    3919         pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID );
     3797        pcMvFieldNeighbours[iCount<<1]    .setMvField( cZeroMv, NOT_VALID );
    39203798        pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID );
    39213799        break;
    39223800      }
    39233801    }
     3802
    39243803    if(!bRemoveSpa)
    39253804    {
     
    39313810#if H_3D_VSP
    39323811      if (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1)
    3933 #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172
    3934       {
    3935 #endif
     3812      {
     3813
    39363814        vspFlag[iCount] = 1;
    3937 #if MTK_VSP_FIX_ALIGN_WD_E0172
    39383815        xInheritVSPDisInfo(pcCUAbove,uiAbovePartIdx,iCount,inheritedVSPDisInfo);
    39393816      }
    39403817#endif
    3941 #if MTK_VSP_FIX_E0172
    3942         vspDir[iCount] = pcCUAbove->getVSPDir( uiAbovePartIdx );
    3943       }
    3944 #endif
    3945 #endif
    39463818      if ( mrgCandIdx == iCount )
    39473819      {
     
    39503822      iCount ++;
    39513823    }
    3952 #else
     3824#else // H_3D_IV_MERGE
    39533825    if ( mrgCandIdx == iCount )
    39543826    {
     
    39563828    }
    39573829    iCount ++;
    3958 #endif
     3830#endif // H_3D_IV_MERGE
    39593831  }
    39603832  // early termination
     
    39633835    return;
    39643836  }
     3837
     3838#if H_3D
     3839  //////////////////////////////////
     3840  //////// ABOVE RIGHT (B0) ////////
     3841  //////////////////////////////////
     3842#endif
    39653843
    39663844  // above right
     
    39883866#if H_3D_VSP
    39893867    if (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1)
    3990 #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172
    3991     {
    3992 #endif
     3868    {
    39933869      vspFlag[iCount] = 1;
    3994 #if MTK_VSP_FIX_ALIGN_WD_E0172
    39953870      xInheritVSPDisInfo(pcCUAboveRight,uiAboveRightPartIdx,iCount,inheritedVSPDisInfo);
    39963871    }
    3997 #endif
    3998 #if MTK_VSP_FIX_E0172
    3999       vspDir[iCount] = pcCUAboveRight->getVSPDir( uiAboveRightPartIdx);
    4000     }
    4001 #endif
    40023872#endif
    40033873    if ( mrgCandIdx == iCount )
     
    40143884
    40153885#if H_3D_IV_MERGE
    4016   if( iPdmDir[1] )
     3886  /////////////////////////////////////////////
     3887  //////// INTER VIEW DISP COMP (IvDC) ////////
     3888  /////////////////////////////////////////////
     3889
     3890  if( ivCandDir[1] )
    40173891  {
    40183892    assert(iCount < getSlice()->getMaxNumMergeCand());
    40193893    abCandIsInter        [ iCount ] = true;
    4020     puhInterDirNeighbours[ iCount ] = iPdmDir[1];
    4021     if( ( iPdmDir[1] & 1 ) == 1 )
    4022     {
    4023       pcMvFieldNeighbours[ iCount<<1    ].setMvField( acPdmMv[ 2 ], aiPdmRefIdx[ 2 ] );
    4024     }
    4025     if( ( iPdmDir[1] & 2 ) == 2 )
    4026     {
    4027       pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 3 ], aiPdmRefIdx[ 3 ] );
     3894    puhInterDirNeighbours[ iCount ] = ivCandDir[1];
     3895    if( ( ivCandDir[1] & 1 ) == 1 )
     3896    {
     3897      pcMvFieldNeighbours[ iCount<<1    ].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
     3898    }
     3899    if( ( ivCandDir[1] & 2 ) == 2 )
     3900    {
     3901      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
    40283902    }
    40293903
     
    40323906    {
    40333907      Int iCnloop = iPosLeftAbove[i];
    4034       if(iCnloop == -1)
     3908      if ( iCnloop == -1 )
     3909      {
    40353910        continue;
     3911      }
    40363912      if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
    40373913      {
     
    40513927      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
    40523928#endif
    4053 #if QC_INRIA_MTK_MRG_E0126
    4054       iPosDmv  = iCount;
    4055 #endif
     3929      posIvDC  = iCount;
    40563930      if ( mrgCandIdx == iCount )
    40573931        return;
     
    40653939    }
    40663940  }
    4067 #endif
     3941#endif // H_3D_IV_MERGE
    40683942
    40693943#if H_3D_VSP
    4070 #if MTK_VSP_FIX_E0172
    4071   if ( xAddVspCand( H_3D_VSP_POSITION, mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, vspDir ) )
    4072 #else
    4073   if ( xAddVspCand( H_3D_VSP_POSITION, mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag ) )
    4074 #endif
     3944  /////////////////////////////////////////////////
     3945  //////// VIEW SYNTHESIS PREDICTION (VSP) ////////
     3946  /////////////////////////////////////////////////
     3947
     3948  if ( xAddVspCand( mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag ) )
     3949  {
    40753950    return;
     3951  }
     3952
    40763953  // early termination
    40773954  if (iCount == getSlice()->getMaxNumMergeCand())
     3955  {
    40783956    return;
     3957  }
     3958#endif
     3959#if H_3D
     3960  ///////////////////////////////////
     3961  //////// LEFT BOTTOM (A0) ////////
     3962  ///////////////////////////////////
    40793963#endif
    40803964
     
    41033987#if H_3D_VSP
    41043988    if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) == 1)
    4105 #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172
    4106     {
    4107 #endif
     3989    {
    41083990      vspFlag[iCount] = 1;
    4109 #if MTK_VSP_FIX_ALIGN_WD_E0172
    41103991      xInheritVSPDisInfo(pcCULeftBottom,uiLeftBottomPartIdx,iCount,inheritedVSPDisInfo);
    41113992    }
    4112 #endif
    4113 #if MTK_VSP_FIX_E0172
    4114       vspDir[iCount] = pcCULeftBottom->getVSPDir( uiLeftBottomPartIdx);
    4115     }
    4116 #endif
    41173993#endif
    41183994    if ( mrgCandIdx == iCount )
     
    41274003    return;
    41284004  }
     4005#if H_3D
     4006  ///////////////////////////////////
     4007  //////// LEFT ABOVE (B2) ////////
     4008  ///////////////////////////////////
     4009#endif
     4010
    41294011  // above left
    41304012  if( iCount < 4 )
     
    41544036#if H_3D_VSP
    41554037      if (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1)
    4156 #if MTK_VSP_FIX_E0172 || MTK_VSP_FIX_ALIGN_WD_E0172
    4157       {
    4158 #endif
     4038      {
    41594039        vspFlag[iCount] = 1;
    4160 #if MTK_VSP_FIX_ALIGN_WD_E0172
    41614040        xInheritVSPDisInfo(pcCUAboveLeft,uiAboveLeftPartIdx,iCount,inheritedVSPDisInfo);
    41624041      }
    4163 #endif
    4164 #if MTK_VSP_FIX_E0172
    4165         vspDir[iCount] = pcCUAboveLeft->getVSPDir( uiAboveLeftPartIdx);
    4166       }
    4167 #endif
    41684042#endif
    41694043      if ( mrgCandIdx == iCount )
     
    41794053    return;
    41804054  }
    4181 #if QC_INRIA_MTK_MRG_E0126
     4055#if H_3D_IV_MERGE
     4056  ////////////////////////////////////////////////////
     4057  //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
     4058  ////////////////////////////////////////////////////
     4059
    41824060  if(  ivMvPredFlag  )
    41834061  {
    4184     if(xAddIvMRGCand( mrgCandIdx,  iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, iPdmDir, acPdmMv, aiPdmRefIdx, iPosDmv, vspFlag))
     4062    if(xAddIvMRGCand( mrgCandIdx,  iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, ivCandDir, ivCandMv, ivCandRefIdx, posIvDC, vspFlag))
    41854063    {
    41864064      return;
     
    41924070    }
    41934071  }
     4072#endif
     4073#if H_3D
     4074  /////////////////////////////////
     4075  //////// Collocate (COL) ////////
     4076  /////////////////////////////////
    41944077#endif
    41954078  if ( getSlice()->getEnableTMVPFlag())
     
    43114194      Bool bValid = true;
    43124195      if ( vspFlag[i] == 1 || vspFlag[j] == 1 )
     4196      {
    43134197        bValid = false;
     4198      }
    43144199      if( !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) )
     4200      {
    43154201        assert(bValid == true);
     4202      }
    43164203#endif
    43174204#if H_3D_VSP
     
    43744261  numValidMergeCand = uiArrayAddr;
    43754262}
    4376 #if MTK_VSP_FIX_ALIGN_WD_E0172
     4263#if H_3D_VSP
    43774264inline Void TComDataCU::xInheritVSPDisInfo(TComDataCU* pcCURef, UInt uiAbsPartIdx, Int iCount, InheritedVSPDisInfo*  inheritedVSPDisInfo)
    43784265{
     
    60115898  }
    60125899}
    6013 #if MTK_VSP_FIX_ALIGN_WD_E0172
     5900#if H_3D_VSP
    60145901Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth )
    60155902{
     
    61506037TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc )
    61516038{
    6152   TComSlice*    pcSlice         = getSlice (); 
    6153   Int iViewIndex = pDInfo->m_aVIdxCan;
     6039  TComSlice*    pcSlice = getSlice (); 
     6040  Int iViewIndex        = pDInfo->m_aVIdxCan;
     6041 
    61546042  //--- get base CU/PU and check prediction mode ---
    61556043  TComPic*    pcBasePic   = pcSlice->getIvPic( false, iViewIndex );
     
    61746062  TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
    61756063 
    6176 #if !QC_INRIA_MTK_MRG_E0126
    6177   Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
    6178   Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + 2 ) >> 2 ));
    6179 
    6180   Int         iBaseCUAddr;
    6181   Int         iBaseAbsPartIdx;
    6182   pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
    6183 
    6184   TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
    6185 #endif
    6186 #if QC_INRIA_MTK_MRG_E0126
    61876064  Bool abPdmAvailable[8] =  {false, false, false, false, false, false, false, false};
    6188 #else
    6189   Bool abPdmAvailable[4] = {false, false, false, false};
    6190 #endif
    61916065#if H_3D_NBDV
    6192 #if QC_INRIA_MTK_MRG_E0126
    61936066  for( Int i = 0; i < 8; i++)
    6194 #else
    6195   for( Int i = 0; i < 4; i++)
    6196 #endif
    61976067  {
    61986068    pacPdmMv[i].setIDVFlag   (false);
    61996069  }
    62006070#endif
    6201 #if QC_INRIA_MTK_MRG_E0126
    6202   for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    6203   {
     6071
     6072  ////////////////////////////////
     6073  /////// IvMC + IvMCShift ///////
     6074  ////////////////////////////////
     6075
     6076  for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++) 
     6077  {
     6078    // iLoopCan == 0 --> IvMC
     6079    // iLoopCan == 1 --> IvMCShift
     6080
    62046081    Int         iBaseCUAddr;
    62056082    Int         iBaseAbsPartIdx;
    62066083
    6207     Int offsetW = (iLoopCan == 0) ? 0 : ( ((iWidth/2)*4) + 4 );
     6084    Int offsetW = (iLoopCan == 0) ? 0 : ( ((iWidth /2)*4) + 4 );
    62086085    Int offsetH = (iLoopCan == 0) ? 0 : ( ((iHeight/2)*4) + 4 );
    6209    
     6086
    62106087    Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
    62116088    Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) );
     
    62136090
    62146091    TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
    6215 #endif
    6216   if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
    6217   {
    6218     for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
    6219     {
    6220       RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
    6221 
    6222       Bool stopLoop = false;
    6223       for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop)
    6224       {
    6225         RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
    6226         TComMvField cBaseMvField;
    6227         pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
    6228         Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
    6229         if (iBaseRefIdx >= 0)
     6092    if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
     6093    {
     6094      // Loop reference picture list of current slice (X in spec).
     6095      for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )       
     6096      {
     6097        RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
     6098
     6099        Bool stopLoop = false;
     6100        // Loop reference picture list of candidate slice (Y in spec)
     6101        for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop)
    62306102        {
    6231           Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
    6232           if (iBaseRefPOC != pcSlice->getPOC())   
     6103          RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
     6104          TComMvField cBaseMvField;
     6105          pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
     6106          Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
     6107          if (iBaseRefIdx >= 0)
    62336108          {
    6234             for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
     6109            Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
     6110            if (iBaseRefPOC != pcSlice->getPOC())   
    62356111            {
    6236               if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
     6112              for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
    62376113              {
    6238 #if QC_INRIA_MTK_MRG_E0126
     6114                if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
     6115                {
    62396116                  abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true;
    62406117                  TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
     
    62436120                  cMv.setIDVHor    (cDv.getHor());                 
    62446121                  cMv.setIDVVer    (cDv.getVer()); 
    6245 #if MTK_DVMCP_FIX_E0172
    62466122                  cMv.setIDVVId    (iViewIndex);
    6247 #endif
    62486123#endif
    62496124                  clipMv( cMv );
    62506125                  paiPdmRefIdx  [ (uiCurrRefListId + (iLoopCan<<2)) ] = iPdmRefIdx;
    62516126                  pacPdmMv      [ (uiCurrRefListId + (iLoopCan<<2)) ] = cMv;
    6252 #else
    6253                 abPdmAvailable[ uiCurrRefListId ] = true;
    6254                 TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
    6255 #if H_3D_NBDV
    6256                 cMv.setIDVFlag   (true);
    6257                 cMv.setIDVHor    (cDv.getHor());                 
    6258                 cMv.setIDVVer    (cDv.getVer()); 
    6259 #if MTK_DVMCP_FIX_E0172
    6260                 cMv.setIDVVId    (iViewIndex);
    6261 #endif
    6262 #endif
    6263                 clipMv( cMv );
    6264                 paiPdmRefIdx  [ uiCurrRefListId ] = iPdmRefIdx;
    6265                 pacPdmMv      [ uiCurrRefListId ] = cMv;
    6266 #endif
    6267                 stopLoop = true;
    6268                 break;
     6127                  stopLoop = true;
     6128                  break;
     6129                }
    62696130              }
    62706131            }
     
    62746135    }
    62756136  }
    6276 #if QC_INRIA_MTK_MRG_E0126
    6277   }
    6278 #endif
    6279 #if QC_INRIA_MTK_MRG_E0126
    62806137  for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    62816138  {
    62826139    availableMcDc[(iLoopCan << 1)] = ( abPdmAvailable[(iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[1 + (iLoopCan<<2)] ? 2 : 0);
    62836140  }
    6284 #else
    6285   availableMcDc[0] = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 );
    6286 #endif
     6141 
     6142 
     6143  ////////////////////////////////
     6144  /////// IvDC + IvDCShift ///////
     6145  ////////////////////////////////
     6146 
    62876147  for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ )
    62886148  {
     
    62916151    for( Int iPdmRefIdx = 0; iPdmRefIdx < iNumRefPics; iPdmRefIdx++ )
    62926152    {
    6293 #if MTK_DIVMC_FIX_E0172
    62946153      if(( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC()) && (pcSlice->getRefPic( eRefPicListDMV, iPdmRefIdx )->getViewIndex() == pDInfo->m_aVIdxCan))
    6295 #else
    6296       if( pcSlice->getRefPOC( eRefPicListDMV, iPdmRefIdx ) == pcSlice->getPOC())
    6297 #endif
    6298       {
    6299 #if QC_INRIA_MTK_MRG_E0126
     6154      {
    63006155        for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    63016156        {
     
    63126167        }
    63136168        break;
    6314 #else
    6315         abPdmAvailable[ iRefListId+2 ] = true;
    6316         paiPdmRefIdx  [ iRefListId+2 ] = iPdmRefIdx;
    6317 
    6318 #if H_3D_NBDV_REF
    6319         TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV;
    6320 #endif // H_3D_NBDV_REF
    6321         cMv.setVer(0);
    6322         clipMv( cMv );
    6323         pacPdmMv      [ iRefListId + 2] = cMv;
    6324         break;
    6325 #endif
    6326       }
    6327     }
    6328   }
    6329 #if QC_INRIA_MTK_MRG_E0126
     6169      }
     6170    }
     6171  }
    63306172  for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
    63316173  {
    63326174    availableMcDc[1 + (iLoopCan << 1)] = ( abPdmAvailable[2 + (iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[3 + (iLoopCan<<2)] ? 2 : 0 );
    63336175  }
    6334 #else
    6335   availableMcDc[1] = ( abPdmAvailable[2] ? 1 : 0 ) + ( abPdmAvailable[3] ? 2 : 0 );
    6336 #endif
    63376176  return false;
    63386177}
Note: See TracChangeset for help on using the changeset viewer.