Ignore:
Timestamp:
11 Jul 2014, 03:49:39 (10 years ago)
Author:
mediatek-htm
Message:

Integration of Single Depth Mode proposed in JCT3V-I0095.
The MACRO is "MTK_SINGLE_DEPTH_MODE_I0095".

By Yi-Wen Chen (yiwen.chen@…)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-11.2-dev3-MediaTek/source/Lib/TLibEncoder/TEncSearch.cpp

    r976 r983  
    915915        }
    916916        m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true );
     917#if MTK_SINGLE_DEPTH_MODE_I0095
     918        m_pcEntropyCoder->encodeSingleDepthMode(pcCU, 0, true );
     919        if(!pcCU->getSingleDepthFlag(uiAbsPartIdx))
     920#endif
    917921        m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
    918922      }
    919      
     923#if MTK_SINGLE_DEPTH_MODE_I0095
     924      else
     925      {
     926        m_pcEntropyCoder->encodeSingleDepthMode(pcCU, 0, true );
     927      }
     928#endif     
     929#if MTK_SINGLE_DEPTH_MODE_I0095
     930      if(!pcCU->getSingleDepthFlag(uiAbsPartIdx))
     931      {
     932#endif
    920933      m_pcEntropyCoder  ->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
    921934
     
    932945        }
    933946      }
    934     }
     947#if MTK_SINGLE_DEPTH_MODE_I0095
     948    }
     949#endif
     950    }
     951#if MTK_SINGLE_DEPTH_MODE_I0095
     952      if(!pcCU->getSingleDepthFlag(uiAbsPartIdx))
     953      {
     954#endif
    935955    // luma prediction mode
    936956    if( pcCU->getPartitionSize(0) == SIZE_2Nx2N )
     
    975995    }
    976996  }
    977 
     997#if MTK_SINGLE_DEPTH_MODE_I0095
     998    }
     999#endif
    9781000  }
    9791001  if( bChroma )
     
    18371859  dRDCost  += dSingleCost;
    18381860}
    1839 
     1861#if MTK_SINGLE_DEPTH_MODE_I0095
     1862Void TEncSearch::xIntraCodingSingleDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Int iTestDepthIdx, Pel *DepthNeighbor )
     1863{
     1864  UInt    uiWidth           = pcCU     ->getWidth   ( 0 );
     1865  UInt    uiHeight          = pcCU     ->getHeight  ( 0 );
     1866  UInt    uiStride          = pcOrgYuv ->getStride  ();
     1867  Pel*    piOrg             = pcOrgYuv ->getLumaAddr( uiAbsPartIdx );
     1868  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
     1869
     1870  AOF( uiWidth == uiHeight );
     1871  AOF( uiAbsPartIdx == 0 );
     1872  pcCU->setSingleDepthValueSubParts((Pel)iTestDepthIdx,uiAbsPartIdx, 0, pcCU->getDepth(0)); 
     1873  //===== reconstruction =====
     1874
     1875  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
     1876  {
     1877    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
     1878    {
     1879    piPred[ uiX ] = DepthNeighbor[iTestDepthIdx];
     1880    }
     1881    piPred     += uiStride;
     1882  }
     1883
     1884  // clear UV
     1885  UInt  uiStrideC     = pcPredYuv->getCStride();
     1886  Pel   *pRecCb       = pcPredYuv->getCbAddr();
     1887  Pel   *pRecCr       = pcPredYuv->getCrAddr();
     1888
     1889  for (Int y=0; y<uiHeight/2; y++)
     1890  {
     1891    for (Int x=0; x<uiWidth/2; x++)
     1892    {
     1893      pRecCb[x] = 1<<(g_bitDepthC-1);
     1894      pRecCr[x] = 1<<(g_bitDepthC-1);
     1895    }
     1896
     1897    pRecCb += uiStrideC;
     1898    pRecCr += uiStrideC;
     1899  }
     1900
     1901  piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
     1902  //===== determine distortion =====
     1903#if H_3D_VSO
     1904  if ( m_pcRdCost->getUseVSO() )
     1905    ruiDist = m_pcRdCost->getDistPartVSO  ( pcCU, uiAbsPartIdx, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, false );
     1906  else
     1907#endif
     1908    ruiDist = m_pcRdCost->getDistPart(g_bitDepthY, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight );
     1909
     1910  //===== determine rate and r-d cost =====
     1911  m_pcEntropyCoder->resetBits();
     1912  m_pcEntropyCoder->encodeSingleDepthMode( pcCU, 0, true );
     1913  UInt uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
     1914
     1915#if H_3D_VSO
     1916  if ( m_pcRdCost->getUseLambdaScaleVSO())
     1917    dRDCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist );
     1918  else
     1919#endif
     1920    dRDCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
     1921}
     1922#endif
    18401923#if H_3D_DIM_SDC
    18411924Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bZeroResidual, Int iSDCDeltaResi  )
     
    27772860  pcCU->setChromIntraDirSubParts( uiBestMode, 0, pcCU->getDepth( 0 ) );
    27782861}
    2779 
     2862#if MTK_SINGLE_DEPTH_MODE_I0095
     2863Void
     2864TEncSearch::estIntraPredSingleDepth( TComDataCU* pcCU,
     2865                           TComYuv*    pcOrgYuv,
     2866                           TComYuv*    pcPredYuv,
     2867                           TComYuv*    pcResiYuv,
     2868                           TComYuv*    pcRecoYuv,
     2869                           UInt&       ruiDistC,
     2870                           Bool        bLumaOnly )
     2871{
     2872  UInt    uiDepth        = pcCU->getDepth(0);
     2873  UInt    uiWidth        = pcCU->getWidth (0);
     2874  UInt    uiHeight       = pcCU->getHeight(0);
     2875
     2876
     2877  Pel* piOrg         = pcOrgYuv ->getLumaAddr( 0, uiWidth );
     2878  UInt uiStride      = pcPredYuv->getStride();
     2879
     2880  Int index=0;
     2881  Pel testDepth;
     2882  Pel DepthNeighbours[5];
     2883  //construction of depth candidates
     2884  for( Int i = 0; (i < 5)  && (index<MTK_SINGLE_DEPTH_MODE_CANDIDATE_LIST_SIZE) ; i++ )
     2885  {
     2886    if(!pcCU->getNeighDepth (0, 0, &testDepth, i))
     2887    {
     2888      continue;
     2889    }
     2890    DepthNeighbours[index]=testDepth;
     2891    index++;
     2892    for(Int j=0;j<index-1;j++)
     2893    {
     2894      if( (DepthNeighbours[index-1]==DepthNeighbours[j]))
     2895      {
     2896        index--;
     2897        break;
     2898      }
     2899    }
     2900  }
     2901
     2902  if(index==0)
     2903  {
     2904    DepthNeighbours[index]=1<<(g_bitDepthY-1);
     2905    index++;
     2906  }
     2907
     2908  if(index==1)
     2909  {
     2910    DepthNeighbours[index]=ClipY(DepthNeighbours[0] + 1 );
     2911    index++;
     2912  }
     2913
     2914
     2915  Dist   uiDist = 0;
     2916  Double dCost   = 0.0;
     2917  Dist    uiBestDist = 0;
     2918  Double  dBestCost   = MAX_DOUBLE;
     2919  Pel     pBestSingleDepthValue = 0;
     2920
     2921  for( Int testdepthidx = 0; testdepthidx < index ; testdepthidx++ )
     2922  {
     2923      // set context models
     2924      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
     2925
     2926      // determine residual for partition
     2927      uiDist = 0;
     2928      dCost   = 0.0;
     2929#if H_3D_VSO // M36
     2930      if( m_pcRdCost->getUseRenModel() )
     2931      {
     2932        m_pcRdCost->setRenModelData( pcCU, 0, piOrg, uiStride, uiWidth, uiHeight );
     2933      }
     2934#endif
     2935      xIntraCodingSingleDepth(pcCU, 0, pcOrgYuv, pcPredYuv, uiDist, dCost, testdepthidx, DepthNeighbours);
     2936      // check r-d cost
     2937      if( dCost < dBestCost )
     2938      {
     2939        uiBestDist = uiDist;
     2940        dBestCost   = dCost;
     2941        pBestSingleDepthValue = pcCU->getSingleDepthValue(0);
     2942        // copy reconstruction
     2943        pcPredYuv->copyPartToPartYuv(pcRecoYuv, 0, uiWidth, uiHeight);
     2944      }
     2945  } // depth index loop
     2946
     2947
     2948  pcCU->setSingleDepthValueSubParts((Pel)pBestSingleDepthValue,0, 0, uiDepth);
     2949  assert(pBestSingleDepthValue>=0);
     2950
     2951  //===== reset context models =====
     2952  m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
     2953 
     2954  //===== set distortion (rate and r-d costs are determined later) =====
     2955  pcCU->getTotalDistortion() = uiBestDist;
     2956}
     2957
     2958#endif
    27802959Void
    27812960TEncSearch::estIntraPredQT( TComDataCU* pcCU,
     
    69817160    }
    69827161    m_pcEntropyCoder->encodeSkipFlag ( pcCU, 0, true );
     7162#if MTK_SINGLE_DEPTH_MODE_I0095
     7163    m_pcEntropyCoder->encodeSingleDepthMode ( pcCU, 0, true );
     7164#endif
    69837165    m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
    69847166    m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
Note: See TracChangeset for help on using the changeset viewer.