Ignore:
Timestamp:
2 Jul 2013, 21:49:16 (11 years ago)
Author:
mitsubishi-htm
Message:

-VSP compensation part migration, not fully tested, intermediate version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.cpp

    r504 r510  
    116116#endif
    117117
     118#if H_3D_VSP
     119  m_piVSPFlag            = NULL;
     120#endif
     121
    118122#if H_3D_ARP
    119123  m_puhARPW              = NULL;
     
    157161    m_pbMergeFlag        = (Bool*  )xMalloc(Bool,   uiNumPartition);
    158162    m_puhMergeIndex      = (UChar* )xMalloc(UChar,  uiNumPartition);
     163#if H_3D_VSP
     164    m_piVSPFlag          = (Char*  )xMalloc(Char,   uiNumPartition);
     165#endif
    159166    m_puhLumaIntraDir    = (UChar* )xMalloc(UChar,  uiNumPartition);
    160167    m_puhChromaIntraDir  = (UChar* )xMalloc(UChar,  uiNumPartition);
     
    276283    if ( m_pbMergeFlag        ) { xFree(m_pbMergeFlag);         m_pbMergeFlag       = NULL; }
    277284    if ( m_puhMergeIndex      ) { xFree(m_puhMergeIndex);       m_puhMergeIndex     = NULL; }
     285#if H_3D_VSP
     286    if ( m_piVSPFlag          ) { xFree(m_piVSPFlag);           m_piVSPFlag         = NULL; }
     287#endif
    278288    if ( m_puhLumaIntraDir    ) { xFree(m_puhLumaIntraDir);     m_puhLumaIntraDir   = NULL; }
    279289    if ( m_puhChromaIntraDir  ) { xFree(m_puhChromaIntraDir);   m_puhChromaIntraDir = NULL; }
     
    442452    m_pbMergeFlag[ui]=pcFrom->m_pbMergeFlag[ui];
    443453    m_puhMergeIndex[ui]=pcFrom->m_puhMergeIndex[ui];
     454#if H_3D_VSP
     455    m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui];
     456#endif
    444457    m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui];
    445458    m_puhChromaIntraDir[ui]=pcFrom->m_puhChromaIntraDir[ui];
     
    475488    memset( m_pbMergeFlag       + firstElement, false,                    numElements * sizeof( *m_pbMergeFlag ) );
    476489    memset( m_puhMergeIndex     + firstElement, 0,                        numElements * sizeof( *m_puhMergeIndex ) );
     490#if H_3D_VSP
     491    memset( m_piVSPFlag         + firstElement, 0,                        numElements * sizeof( *m_piVSPFlag ) );
     492#endif
    477493    memset( m_puhLumaIntraDir   + firstElement, DC_IDX,                   numElements * sizeof( *m_puhLumaIntraDir ) );
    478494    memset( m_puhChromaIntraDir + firstElement, 0,                        numElements * sizeof( *m_puhChromaIntraDir ) );
     
    617633      m_pbMergeFlag[ui] = 0;
    618634      m_puhMergeIndex[ui] = 0;
     635#if H_3D_VSP
     636      m_piVSPFlag[ui] = 0;
     637#endif
    619638      m_puhLumaIntraDir[ui] = DC_IDX;
    620639      m_puhChromaIntraDir[ui] = 0;
     
    688707  memset( m_pbMergeFlag,        0, iSizeInBool  );
    689708  memset( m_puhMergeIndex,      0, iSizeInUchar );
     709#if H_3D_VSP
     710  memset( m_piVSPFlag,          0, sizeof( Char  ) * m_uiNumPartition );
     711#endif
    690712  memset( m_puhLumaIntraDir,    DC_IDX, iSizeInUchar );
    691713  memset( m_puhChromaIntraDir,  0, iSizeInUchar );
     
    744766      m_pbMergeFlag[ui]=pcCU->m_pbMergeFlag[uiPartOffset+ui];
    745767      m_puhMergeIndex[ui]=pcCU->m_puhMergeIndex[uiPartOffset+ui];
     768#if H_3D_VSP
     769      m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui];
     770#endif
    746771      m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui];
    747772      m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui];
     
    866891  m_pbMergeFlag         = pcCU->getMergeFlag()        + uiPart;
    867892  m_puhMergeIndex       = pcCU->getMergeIndex()       + uiPart;
     893#if H_3D_VSP
     894  m_piVSPFlag           = pcCU->getVSPFlag()          + uiPart;
     895#endif
    868896
    869897#if H_3D_ARP
     
    9861014  m_pbMergeFlag        = pcCU->getMergeFlag()             + uiAbsPartIdx;
    9871015  m_puhMergeIndex      = pcCU->getMergeIndex()            + uiAbsPartIdx;
     1016#if H_3D_VSP
     1017  m_piVSPFlag          = pcCU->getVSPFlag()               + uiAbsPartIdx;
     1018#endif
    9881019
    9891020  m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx;
     
    10301061  memcpy( m_pbMergeFlag         + uiOffset, pcCU->getMergeFlag(),         iSizeInBool  );
    10311062  memcpy( m_puhMergeIndex       + uiOffset, pcCU->getMergeIndex(),        iSizeInUchar );
     1063#if H_3D_VSP
     1064  memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( Char ) * uiNumPartition );
     1065#endif
    10321066  memcpy( m_puhLumaIntraDir     + uiOffset, pcCU->getLumaIntraDir(),      iSizeInUchar );
    10331067  memcpy( m_puhChromaIntraDir   + uiOffset, pcCU->getChromaIntraDir(),    iSizeInUchar );
     
    11201154  memcpy( rpcCU->getMergeFlag()         + m_uiAbsIdxInLCU, m_pbMergeFlag,         iSizeInBool  );
    11211155  memcpy( rpcCU->getMergeIndex()        + m_uiAbsIdxInLCU, m_puhMergeIndex,       iSizeInUchar );
     1156#if H_3D_VSP
     1157  memcpy( rpcCU->getVSPFlag()           + m_uiAbsIdxInLCU, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
     1158#endif
    11221159  memcpy( rpcCU->getLumaIntraDir()      + m_uiAbsIdxInLCU, m_puhLumaIntraDir,     iSizeInUchar );
    11231160  memcpy( rpcCU->getChromaIntraDir()    + m_uiAbsIdxInLCU, m_puhChromaIntraDir,   iSizeInUchar );
     
    11991236  memcpy( rpcCU->getMergeFlag()         + uiPartOffset, m_pbMergeFlag,         iSizeInBool  );
    12001237  memcpy( rpcCU->getMergeIndex()        + uiPartOffset, m_puhMergeIndex,       iSizeInUchar );
     1238#if H_3D_VSP
     1239  memcpy( rpcCU->getVSPFlag()           + uiPartOffset, m_piVSPFlag,           sizeof(Char) * uiQNumPart );
     1240#endif
    12011241  memcpy( rpcCU->getLumaIntraDir()      + uiPartOffset, m_puhLumaIntraDir,     iSizeInUchar );
    12021242  memcpy( rpcCU->getChromaIntraDir()    + uiPartOffset, m_puhChromaIntraDir,   iSizeInUchar );
     
    21432183  setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx );
    21442184}
     2185
     2186#if H_3D_VSP
     2187Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     2188{
     2189  setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
     2190}
     2191#endif
    21452192
    21462193Void TComDataCU::setChromIntraDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiDepth )
     
    25722619}
    25732620
     2621#if H_3D_VSP
     2622
     2623/** Add a VSP merging candidate
     2624 * \Inputs
     2625 * \param uiPUIdx: PU index within a CU
     2626 * \param ucVspMergePos: Specify the VSP merge candidate position
     2627 * \param mrgCandIdx: Target merge candidate index. At encoder, it is set equal to -1, such that the whole merge candidate list will be constructed.
     2628 * \param pDinfo: The "disparity information" derived from neighboring blocks. Type 1 MV.
     2629 * \param uiCount: The next position to add VSP merge candidate
     2630 *
     2631 * \Outputs
     2632 * \param uiCount: The next position to add merge candidate. Will be updated if VSP is successfully added
     2633 * \param abCandIsInter: abCandIsInter[iCount] tells that VSP candidate is an Inter candidate, if VSP is successfully added
     2634 * \param pcMvFieldNeighbours:   Return the "disparity vector". Type 1 MV. To be used to fetch a depth block. A "global" variable
     2635 * \param puhInterDirNeighbours: Tells the VSP prediction direction. TODO: The value does NOT matter for VSP, as the direction will be determined based on availability later
     2636 *                                Having it as output is mainly for coding beauty
     2637 * \param vspFlag: vspFlag[iCount] will be set (equal to 1), if VSP is successfully added. To be used to indicate the actual position of the VSP candidate
     2638 *
     2639 * \Return
     2640 *   true:  if the VSP candidate is added at the target position
     2641 *   false: otherwise
     2642 */
     2643inline Bool TComDataCU::xAddVspCand( UChar ucVspMergePos, Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
     2644                                     Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag )
     2645{
     2646  if( !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) ) // Not to add the candidate if VSP is turned off
     2647    return false;
     2648  if( m_pcSlice->getIsDepth() ) // VSP is turned off for depth layers
     2649    return false;
     2650
     2651  Int refViewIdx = pDInfo->m_aVIdxCan;
     2652  TComPic* picDepth = NULL;
     2653  //assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());
     2654  picDepth = getSlice()->getIvPic( true, refViewIdx );
     2655
     2656  /*
     2657  // Code if simply re-writing
     2658  if(ucVspMergePos == H_3D_VSPPOSITION && picDepth != NULL && 0 != m_pcSlice->getViewIndex() ) // VSP can be used only when depth is used as input
     2659  {
     2660    abCandIsInter[iCount] = true;
     2661    puhInterDirNeighbours[iCount] = 1;
     2662    vspFlag[iCount] = 1;
     2663    vspDirTrue[iCount] = 0; // TODO: Check if this is really useful!!!!
     2664
     2665    Int iRefIdxList0 = getSlice()->getRefPic(REF_PIC_LIST_0, 0)->getPOC() == getSlice()->getPOC() ? 0 :
     2666                      (getSlice()->getAlterRefIdx(REF_PIC_LIST_0) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_0));
     2667    pcMvFieldNeighbours[iCount<<1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList0 );
     2668    if (getSlice()->isInterB())
     2669    {
     2670      puhInterDirNeighbours[iCount] = xGetVspDirection(uiPUIdx);
     2671      Int iRefIdxList1 = getSlice()->getRefPic(REF_PIC_LIST_1, 0)->getPOC() == getSlice()->getPOC() ? 0 :
     2672                        (getSlice()->getAlterRefIdx(REF_PIC_LIST_1) == -1 ? NOT_VALID : getSlice()->getAlterRefIdx(REF_PIC_LIST_1));
     2673      pcMvFieldNeighbours[(iCount<<1)+1].setMvField( pDInfo->m_acDoNBDV, iRefIdxList1 );
     2674    }
     2675
     2676    if ( mrgCandIdx == iCount )
     2677      return true;
     2678
     2679    iCount++;
     2680  }
     2681  */
     2682  if(ucVspMergePos == H_3D_VSP_POSITION && picDepth != NULL && 0 != m_pcSlice->getViewIndex() ) // VSP can be used only when depth is used as input
     2683  {
     2684    abCandIsInter[iCount] = true;
     2685    puhInterDirNeighbours[iCount] = 0;
     2686    vspFlag[iCount] = 1;
     2687
     2688    Bool refViewAvailFlag = false;
     2689    UChar predFlag[2] = {0, 0};
     2690    Int  iRefListIdX = 0;
     2691    Int  iRefListIdY = 0;
     2692
     2693    for( iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ )
     2694    {
     2695      RefPicList eRefPicList = RefPicList( iRefListIdX );
     2696      for (Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicList) && !refViewAvailFlag; i++)
     2697      {
     2698        Int viewIdxRefInList = m_pcSlice->getRefPic(eRefPicList, i)->getViewIndex();
     2699        if (refViewIdx == viewIdxRefInList)
     2700        {
     2701          refViewAvailFlag = true;
     2702          predFlag[iRefListIdX] = 1;
     2703          iRefListIdY = 1 - iRefListIdX;
     2704          pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acDoNBDV, i );
     2705        }
     2706      }
     2707    }
     2708
     2709    if (m_pcSlice->isInterB() && refViewAvailFlag)
     2710    {
     2711      RefPicList eRefPicList = RefPicList( iRefListIdY );
     2712      refViewAvailFlag = false;
     2713      for (Int i = 0; i < m_pcSlice->getNumRefIdx(eRefPicList) && !refViewAvailFlag; i++)
     2714      {
     2715        Int viewIdxRefInList = m_pcSlice->getRefPic(eRefPicList, i)->getViewIndex();
     2716        if (refViewIdx != viewIdxRefInList)
     2717        {
     2718          refViewAvailFlag = true;
     2719          predFlag[iRefListIdY] = 1;
     2720          pcMvFieldNeighbours[(iCount<<1)+iRefListIdY].setMvField( pDInfo->m_acDoNBDV, i );
     2721        }
     2722      }
     2723    }
     2724
     2725    puhInterDirNeighbours[iCount] = (predFlag[0] | (predFlag[1] << 1));
     2726
     2727    if ( mrgCandIdx == iCount )
     2728      return true;
     2729
     2730    iCount++;
     2731  }
     2732
     2733  return false;
     2734}
     2735#endif
     2736
    25742737/** Constructs a list of merging candidates
    25752738 * \param uiAbsPartIdx
     
    25802743 * \param numValidMergeCand
    25812744 */
    2582 Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
     2745Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
     2746#if H_3D_VSP
     2747      , Int* vspFlag
     2748#endif
     2749      , Int& numValidMergeCand
     2750      , Int mrgCandIdx
     2751)
    25832752{
    25842753  UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx;
     
    28302999      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
    28313000#endif
     3001#if H_3D_VSP
     3002      if (pcCULeft->getVSPFlag(uiLeftPartIdx) == 1)
     3003        vspFlag[iCount] = 1;
     3004#endif
    28323005      if ( mrgCandIdx == iCount )
    28333006      {
     
    28943067      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
    28953068#endif
     3069#if H_3D_VSP
     3070      if (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1)
     3071        vspFlag[iCount] = 1;
     3072#endif
    28963073      if ( mrgCandIdx == iCount )
    28973074      {
     
    29363113    pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
    29373114#endif
     3115#if H_3D_VSP
     3116    if (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1)
     3117      vspFlag[iCount] = 1;
     3118#endif
    29383119    if ( mrgCandIdx == iCount )
    29393120    {
     
    30033184#endif
    30043185
     3186#if H_3D_VSP
     3187  if ( xAddVspCand( 3, mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag ) )
     3188    return;
     3189  // early termination
     3190  if (iCount == getSlice()->getMaxNumMergeCand())
     3191    return;
     3192#endif
     3193
    30053194  //left bottom
    30063195  UInt uiLeftBottomPartIdx = 0;
     
    30253214    pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
    30263215#endif
     3216#if H_3D_VSP
     3217    if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) == 1)
     3218      vspFlag[iCount] = 1;
     3219#endif
    30273220    if ( mrgCandIdx == iCount )
    30283221    {
     
    30603253      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
    30613254      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
     3255#endif
     3256#if H_3D_VSP
     3257      if (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1)
     3258        vspFlag[iCount] = 1;
    30623259#endif
    30633260      if ( mrgCandIdx == iCount )
     
    31923389    {
    31933390      Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
     3391#if H_3D_VSP
     3392      Bool bValid = true;
     3393      if ( vspFlag[i] == 1 || vspFlag[j] == 1 )
     3394        bValid = false;
     3395      if( !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) )
     3396        assert(bValid == true);
     3397#endif
     3398#if H_3D_VSP
     3399      if (abCandIsInter[i] && abCandIsInter[j] && (puhInterDirNeighbours[i]&0x1) && (puhInterDirNeighbours[j]&0x2) && bValid)
     3400#else
    31943401      if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
     3402#endif
    31953403      {
    31963404        abCandIsInter[uiArrayAddr] = true;
     
    45154723            estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv );
    45164724
    4517           //Notes from MTK: Please uncomment the following parts while integrating VSP
    4518 #if H_3D_VSP
     4725#if 0 // H_3D_VSP
    45194726          Int refFrmIdx = 0;
    45204727          RefPicList privateRefPicList = REF_PIC_LIST_0;
     
    46354842          pDInfo->m_acDoNBDV = cDispVec;
    46364843         
    4637 #if H_3D_VSP
     4844#if 0 // H_3D_VSP
    46384845          Int refFrmIdx = 0;
    46394846          RefPicList privateRefPicList = REF_PIC_LIST_0 ;
     
    46664873  pDInfo->m_acDoNBDV = defaultDV;
    46674874
    4668 #if H_3D_VSP
     4875#if 0 // H_3D_VSP
    46694876  Int refFrmIdx = 0;
    46704877  RefPicList privateRefPicList = REF_PIC_LIST_0 ;
     
    46844891  Int iPictureWidth  = pcBaseViewDepthPicYuv->getWidth();
    46854892  Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight();
    4686  
    46874893
    46884894  Int depthStartPosX = Clip3(0,   iPictureWidth - iBlkWidth,  iBlkX + ((mv->getHor()+2)>>2));
     
    47494955          pNbDvInfo->m_aVIdxCan = refViewIdx;
    47504956#if H_3D_NBDV_REF
    4751           TComPic* picDepth = NULL;         
     4957          TComPic* picDepth = NULL;
    47524958          assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());         
    4753           picDepth   = getSlice()->getIvPic (true, refViewIdx );         
     4959          picDepth   = getSlice()->getIvPic (true, refViewIdx );
    47544960          assert(picDepth != NULL);
    47554961
     
    47604966            estimateDVFromDM(refViewIdx, uiPartIdx, picDepth, uiPartAddr, &cMvPred );
    47614967
    4762          
     4968#if 0 // H_3D_VSP
     4969          pNbDvInfo->m_aListIdx[ pNbDvInfo->iN ] = eRefPicList;
     4970          pNbDvInfo->m_aRefIdx [ pNbDvInfo->iN ] = -1-refId;
     4971          assert(pNbDvInfo->m_aRefIdx [ pNbDvInfo->iN ] < 0);
     4972#endif
     4973
    47634974          pNbDvInfo->m_acDoNBDV = cMvPred;
    47644975#endif
     
    47694980          assert( uiMvpDvPos < IDV_CANDS );
    47704981          paIDVInfo->m_acMvCand[iList][ uiMvpDvPos ] = TComMv( cMvPred.getIDVHor(), cMvPred.getIDVVer() );
    4771           //Notes from QC: DvMCP is implemented in a way that doesn’t carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design.
     4982          //Notes from QC: DvMCP is implemented in a way that doesnt carry the reference view identifier as NBDV. It only works for CTC and needs to be fixed to be aligned with other part of the NBDV design.
    47724983          paIDVInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = 0;
    47734984          paIDVInfo->m_bAvailab[iList][ uiMvpDvPos ] = true;
Note: See TracChangeset for help on using the changeset viewer.