Ignore:
Timestamp:
29 Aug 2013, 13:55:40 (11 years ago)
Author:
tech
Message:

Merged dev2: DEV-2.0-LG@595

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSearch.cpp

    r597 r598  
    4141#include "TEncSearch.h"
    4242#include <math.h>
     43#if LGE_INTER_SDC_E0156
     44#include <memory.h>
     45#endif
    4346
    4447//! \ingroup TLibEncoder
     
    319322#if H_3D_IC
    320323  m_cDistParam.bUseIC = pcPatternKey->getICFlag();
     324#endif
     325#if LGE_INTER_SDC_E0156
     326  m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    321327#endif
    322328  //-- jclee for using the SAD function pointer
     
    748754#if H_3D_IC
    749755    m_cDistParam.bUseIC = pcPatternKey->getICFlag();
     756#endif
     757#if LGE_INTER_SDC_E0156
     758    m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    750759#endif
    751760    m_cDistParam.pCur = piRefPos;
     
    35313540  cDistParam.bUseIC = false;
    35323541#endif
     3542#if LGE_INTER_SDC_E0156
     3543  cDistParam.bUseSDCMRSAD = false;
     3544#endif
    35333545  ruiErr = cDistParam.DistFunc( &cDistParam );
    35343546}
     
    36903702 */
    36913703#if AMP_MRG
     3704#if  MTK_FAST_TEXTURE_ENCODING_E0173
     3705Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bFMD, Bool bUseRes, Bool bUseMRG )
     3706#else
    36923707Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG )
     3708#endif
    36933709#else
    36943710Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes )
     
    38013817#if AMP_MRG
    38023818    Bool bTestNormalMC = true;
    3803    
     3819#if  MTK_FAST_TEXTURE_ENCODING_E0173
     3820    if (bFMD||( bUseMRG && pcCU->getWidth( 0 ) > 8 && iNumPart == 2 ))
     3821#else           
    38043822    if ( bUseMRG && pcCU->getWidth( 0 ) > 8 && iNumPart == 2 )
     3823#endif
    38053824    {
    38063825      bTestNormalMC = false;
     
    46894708  pcPatternKey->setICFlag( bICFlag );
    46904709#endif
     4710#if LGE_INTER_SDC_E0156
     4711  if ( pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) )
     4712  {
     4713    pcPatternKey->setSDCMRSADFlag( true );
     4714  }
     4715  else
     4716  {
     4717    pcPatternKey->setSDCMRSADFlag( false );
     4718  }
     4719#endif
    46914720
    46924721  if ( bBi )
     
    48344863#if H_3D_IC
    48354864      m_cDistParam.bUseIC = pcPatternKey->getICFlag();
     4865#endif
     4866#if LGE_INTER_SDC_E0156
     4867      m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
    48364868#endif
    48374869      m_cDistParam.bitDepth = g_bitDepthY;
     
    54405472#endif
    54415473}
     5474
     5475#if LGE_INTER_SDC_E0156
     5476Void TEncSearch::encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU, TComYuv* pcOrg, TComYuv* pcPred, TComYuv* pcResi, TComYuv* pcRec, const UInt uiDepth )
     5477{
     5478  if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( 0 ) )
     5479  {
     5480    return;
     5481  }
     5482
     5483  pcCU->setInterSDCFlagSubParts( true, 0, 0, uiDepth );
     5484
     5485  UInt  uiWidth      = pcCU->getWidth ( 0 );
     5486  UInt  uiHeight     = pcCU->getHeight( 0 );
     5487  UChar* pMask       = pcCU->getInterSDCMask();
     5488  memset( pMask, 0, uiWidth*uiHeight );
     5489
     5490  pcCU->xSetInterSDCCUMask( pcCU, pMask );
     5491
     5492  UInt uiSegSize[4] = { 0, 0, 0, 0 };
     5493  Pel *pPred, *pOrg;
     5494  UInt uiPredStride = pcPred->getStride();
     5495  UInt uiOrgStride  = pcOrg->getStride();
     5496  UInt uiPelX, uiPelY;
     5497  UInt uiPartitionSize = pcCU->getPartitionSize( 0 );
     5498  UInt uiSegmentNum = ( uiPartitionSize == SIZE_2Nx2N ) ? 1 : ( uiPartitionSize == SIZE_NxN ? 4 : 2 );
     5499
     5500  pPred = pcPred->getLumaAddr( 0 );
     5501  pOrg  = pcOrg->getLumaAddr( 0 );
     5502  Int pResDC[4] = { 0, 0, 0, 0};
     5503
     5504  //calculate dc value for prediction and original signal, and calculate residual and reconstruction
     5505  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
     5506  {
     5507    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
     5508    {
     5509      UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ];
     5510      pResDC[uiSeg] += (Int)( pOrg [uiPelX] - pPred[uiPelX] );
     5511      uiSegSize[uiSeg]++;
     5512    }
     5513    pOrg  += uiOrgStride;
     5514    pPred += uiPredStride;
     5515  }
     5516
     5517  for( UInt uiSeg = 0; uiSeg < uiSegmentNum; uiSeg++ )
     5518  {
     5519    Int iResiOffset = ( pResDC [uiSeg] > 0 ? ( uiSegSize[uiSeg] >> 1 ) : -1*( uiSegSize[uiSeg] >> 1 ) );
     5520    pResDC [uiSeg]  = ( pResDC [uiSeg] + iResiOffset ) / (Int) uiSegSize[uiSeg];
     5521
     5522    pcCU->setInterSDCSegmentDCOffset( pResDC[uiSeg], uiSeg, 0 );
     5523  }
     5524
     5525  Pel *pRec;
     5526  UInt uiRecStride  = pcRec->getStride();
     5527  pPred = pcPred->getLumaAddr( 0 );
     5528  pRec  = pcRec->getLumaAddr( 0 );
     5529
     5530  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
     5531  {
     5532    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
     5533    {
     5534      UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ];
     5535      assert( uiSeg < uiSegmentNum );
     5536
     5537      pRec[ uiPelX ] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, pPred[uiPelX] + pResDC[uiSeg] );
     5538    }
     5539    pPred     += uiPredStride;
     5540    pRec      += uiRecStride;
     5541  }
     5542
     5543  // clear UV
     5544  UInt  uiStrideC     = pcRec->getCStride();
     5545  Pel   *pRecCb       = pcRec->getCbAddr();
     5546  Pel   *pRecCr       = pcRec->getCrAddr();
     5547
     5548  for (Int y=0; y < uiHeight/2; y++)
     5549  {
     5550    for (Int x=0; x < uiWidth/2; x++)
     5551    {
     5552      pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
     5553      pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
     5554    }
     5555
     5556    pRecCb += uiStrideC;
     5557    pRecCr += uiStrideC;
     5558  }
     5559
     5560  Dist ruiDist;
     5561  Double rdCost;
     5562#if H_3D_VSO // M13
     5563  if ( m_pcRdCost->getUseVSO() )
     5564  {
     5565    ruiDist = m_pcRdCost->getDistPartVSO( pcCU, 0, pcRec->getLumaAddr(), pcRec->getStride(),  pcOrg->getLumaAddr(), pcOrg->getStride(),  uiWidth,      uiHeight     , false );
     5566  }
     5567  else   
     5568  {
     5569#endif
     5570    {
     5571      ruiDist = m_pcRdCost->getDistPart( g_bitDepthY, pcRec->getLumaAddr( 0 ), uiRecStride, pcOrg->getLumaAddr( 0 ), uiOrgStride, uiWidth, uiHeight );
     5572    }
     5573#if H_3D_VSO
     5574  }
     5575#endif
     5576
     5577  Bool bNonSkip = true;
     5578  for( UInt uiSeg = 0; uiSeg < uiSegmentNum; uiSeg++ )
     5579  {
     5580    bNonSkip &= ( pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 ) != 0 ) ? 1 : 0;
     5581  }
     5582
     5583  if( !bNonSkip )
     5584  {
     5585    pcCU->getTotalBits()       = MAX_INT;
     5586    pcCU->getTotalDistortion() = MAX_INT;
     5587    pcCU->getTotalCost()       = MAX_DOUBLE;
     5588  }
     5589  else
     5590  {
     5591    //----- determine rate and r-d cost -----
     5592    UInt uiBits = 0;
     5593    TComYuv *pDummy = NULL;
     5594    if( m_bUseSBACRD )
     5595    {
     5596      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
     5597    }
     5598
     5599    xAddSymbolBitsInter( pcCU, 0, 0, uiBits, pDummy, NULL, pDummy );
     5600
     5601#if H_3D_VSO //M 14
     5602    if ( m_pcRdCost->getUseLambdaScaleVSO() )   
     5603    {
     5604      rdCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist );   
     5605    }
     5606    else
     5607#endif
     5608    {
     5609      rdCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
     5610    }
     5611
     5612    pcCU->getTotalBits()       = m_pcEntropyCoder->getNumberOfWrittenBits();
     5613    pcCU->getTotalDistortion() = ruiDist;
     5614    pcCU->getTotalCost()       = rdCost;
     5615
     5616    if( m_bUseSBACRD )
     5617    {
     5618      m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
     5619    }
     5620  }
     5621
     5622#if H_3D_VSO // necessary? // M15
     5623  // set Model
     5624  if( !m_pcRdCost->getUseEstimatedVSD() && m_pcRdCost->getUseRenModel() )
     5625  {
     5626    Pel*  piSrc       = pcRec->getLumaAddr();
     5627    UInt  uiSrcStride = pcRec->getStride();
     5628    m_pcRdCost->setRenModelData( pcCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
     5629  }
     5630#endif
     5631}
     5632#endif
    54425633
    54435634#if H_3D_VSO // M25
     
    66056796    m_pcEntropyCoder->encodeARPW( pcCU , 0 );
    66066797#endif
     6798#if LGE_INTER_SDC_E0156
     6799    m_pcEntropyCoder->encodeInterSDCFlag( pcCU, 0, true );
     6800#endif
    66076801    Bool bDummy = false;
    66086802    m_pcEntropyCoder->encodeCoeff   ( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0), bDummy );
Note: See TracChangeset for help on using the changeset viewer.