Changeset 608 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComRdCost.cpp


Ignore:
Timestamp:
1 Sep 2013, 22:47:26 (11 years ago)
Author:
tech
Message:

Merged DEV-2.0-dev0@604.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibCommon/TComRdCost.cpp

    r296 r608  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4040#include "TComRom.h"
    4141#include "TComRdCost.h"
     42#if H_3D
    4243#include "TComDataCU.h"
     44#endif
    4345
    4446//! \ingroup TLibCommon
    4547//! \{
    4648
    47 #if SAIT_VSO_EST_A0033
     49#if H_3D_VSO
     50// SAIT_VSO_EST_A0033
    4851Double TComRdCost::m_dDisparityCoeff = 1.0;
    4952#endif
     
    6265
    6366// Calculate RD functions
     67#if H_3D_VSO
     68Double TComRdCost::calcRdCost( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc )
     69#else
    6470Double TComRdCost::calcRdCost( UInt uiBits, UInt uiDistortion, Bool bFlag, DFunc eDFunc )
     71#endif
    6572{
    6673  Double dRdCost = 0.0;
     
    8693  }
    8794 
    88 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    89   dLambda = m_dLambdaScale * dLambda ;
    90 #endif
    9195  if (bFlag)
    9296  {
    9397    // Intra8x8, Intra4x4 Block only...
    94 #if LOSSLESS_CODING && SEQUENCE_LEVEL_LOSSLESS
     98#if SEQUENCE_LEVEL_LOSSLESS
    9599    dRdCost = (Double)(uiBits);
    96100#else
     
    107111    else
    108112    {
    109 #if LOSSLESS_CODING && SEQUENCE_LEVEL_LOSSLESS
     113#if SEQUENCE_LEVEL_LOSSLESS
    110114      dRdCost = (Double)(uiBits);
    111115#else
     
    119123}
    120124
     125#if H_3D_VSO
     126Double TComRdCost::calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag, DFunc eDFunc )
     127#else
    121128Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc )
     129#endif
    122130{
    123131  Double dRdCost = 0.0;
     
    146154  {
    147155    // Intra8x8, Intra4x4 Block only...
    148 #if LOSSLESS_CODING && SEQUENCE_LEVEL_LOSSLESS
     156#if SEQUENCE_LEVEL_LOSSLESS
    149157    dRdCost = (Double)(uiBits);
    150158#else
     
    161169    else
    162170    {
    163 #if LOSSLESS_CODING && SEQUENCE_LEVEL_LOSSLESS
     171#if SEQUENCE_LEVEL_LOSSLESS
    164172      dRdCost = (Double)(uiBits);
    165173#else
     
    181189}
    182190
    183 #if H3D_IVMP
    184 Void
    185 TComRdCost::setLambdaMVReg( Double dLambda )
    186 {
    187   m_uiLambdaMVRegSAD = (UInt)floor( 65536.0 * sqrt( dLambda ) );
    188   m_uiLambdaMVRegSSE = (UInt)floor( 65536.0 *       dLambda   );
    189 }
    190 #endif
    191191
    192192// Initalize Function Pointer by [eDFunc]
     
    235235  m_afpDistortFunc[27] = TComRdCost::xGetHADs;
    236236  m_afpDistortFunc[28] = TComRdCost::xGetHADs;
    237  
    238 #if SAIT_VSO_EST_A0033
     237
     238#if H_3D_VSO
     239  // SAIT_VSO_EST_A0033
    239240  m_afpDistortFunc[29]  = TComRdCost::xGetVSD;
    240241  m_afpDistortFunc[30]  = TComRdCost::xGetVSD4;
     
    245246  m_afpDistortFunc[35]  = TComRdCost::xGetVSD16N;
    246247#endif
    247 
    248248#if !FIX203
    249249  m_puiComponentCostOriginP = NULL;
     
    256256#if !FIX203
    257257  m_iSearchLimit            = 0xdeaddead;
    258 
    259 #if HHI_VSO
    260   m_apRefPics               = NULL;
    261   m_paaiShiftLUTs           = NULL;
    262   m_uiNumberRefPics         = 0;
     258#endif
     259#if H_3D_VSO
    263260  m_bUseVSO                 = false;
    264 #if SAIT_VSO_EST_A0033
    265   m_bUseEstimatedVSD        = false;
    266 #endif
    267261  m_uiVSOMode               = 0;
    268262  m_fpDistortFuncVSO        = NULL;
    269263  m_pcRenModel              = NULL;
    270 #endif
    271 
    272 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    273   m_dLambdaScale            = 1;
    274 #endif
     264
     265  // SAIT_VSO_EST_A0033
     266  m_bUseEstimatedVSD        = false;
    275267#endif
    276268}
     
    290282   
    291283    m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ];
    292     m_puiMultiviewRegCostHorOrgP  = new UInt[ 4 * iSubPelSearchLimit ];
    293     m_puiMultiviewRegCostVerOrgP  = new UInt[ 4 * iSubPelSearchLimit ];
    294 
    295284    iSubPelSearchLimit *= 2;
    296285   
    297286    m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit;
    298 
    299     m_puiMultiviewRegCostHor = m_puiMultiviewRegCostHorOrgP + iSubPelSearchLimit;
    300     m_puiMultiviewRegCostVer = m_puiMultiviewRegCostVerOrgP + iSubPelSearchLimit;
    301 
    302287   
    303288    for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++)
    304289    {
    305290      m_puiComponentCost[n] = xGetComponentBits( n );
    306       m_puiMultiviewRegCostHor[n] = xGetComponentBits( n );  // first version
    307       m_puiMultiviewRegCostVer[n] = xGetComponentBits( n );  // first version
    308291    }
    309292  }
     
    316299    delete [] m_puiComponentCostOriginP;
    317300    m_puiComponentCostOriginP = NULL;
    318   }
    319 
    320   if( m_puiMultiviewRegCostHorOrgP )
    321     {
    322       delete [] m_puiMultiviewRegCostHorOrgP;
    323       m_puiMultiviewRegCostHorOrgP = NULL;
    324     }
    325   if( m_puiMultiviewRegCostVerOrgP )
    326   {
    327     delete [] m_puiMultiviewRegCostVerOrgP;
    328     m_puiMultiviewRegCostVerOrgP = NULL;
    329301  }
    330302}
     
    356328  // initialize
    357329  rcDistParam.iSubShift  = 0;
    358 #if HHI_INTERVIEW_SKIP
    359   rcDistParam.pUsed       = 0;
    360   rcDistParam.iStrideUsed = 0;
    361 #endif
    362330}
    363331
     
    394362  // initialize
    395363  rcDistParam.iSubShift  = 0;
    396 #if HHI_INTERVIEW_SKIP
    397   rcDistParam.pUsed       = 0;
    398   rcDistParam.iStrideUsed = 0;
    399 #endif
    400364}
    401365
     
    450414  // initialize
    451415  rcDistParam.iSubShift  = 0;
    452 #if HHI_INTERVIEW_SKIP
    453   rcDistParam.pUsed       = 0;
    454   rcDistParam.iStrideUsed = 0;
    455 #endif
    456416}
    457417
     
    460420TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard, Bool bUseNSHAD )
    461421#else
    462 TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard )
     422TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard )
    463423#endif
    464424{
     
    471431  rcDP.iStep      = 1;
    472432  rcDP.iSubShift  = 0;
     433  rcDP.bitDepth   = bitDepth;
    473434  rcDP.DistFunc   = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ];
    474 #if HHI_INTERVIEW_SKIP
    475   rcDP.pUsed       = 0;
    476   rcDP.iStrideUsed = 0;
    477 #endif
    478435#if NS_HAD
    479436  rcDP.bUseNSHAD  = bUseNSHAD;
     
    481438}
    482439
    483 UInt TComRdCost::calcHAD( Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight )
     440UInt TComRdCost::calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight )
    484441{
    485442  UInt uiSum = 0;
     
    523480  }
    524481 
    525   return ( uiSum >> g_uiBitIncrement );
    526 }
    527 #if HHI_INTERVIEW_SKIP
    528 UInt TComRdCost::getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, Pel* piUsed, Int iUsedStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc )
    529 {
    530   DistParam cDtParam;
    531   setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam );
    532   cDtParam.pOrg       = piOrg;
    533   cDtParam.pCur       = piCur;
    534   cDtParam.pUsed      = piUsed;
    535   cDtParam.iStrideOrg = iOrgStride;
    536   cDtParam.iStrideCur = iCurStride;
    537   cDtParam.iStrideUsed= iUsedStride;
    538 #ifdef DCM_RDCOST_TEMP_FIX //Temporary fix since DistParam is lacking a constructor and the variable iStep is not initialized
    539   cDtParam.iStep      = 1;
    540 #endif
    541 #ifdef WEIGHT_PRED
    542   cDtParam.applyWeight  = false;
    543   cDtParam.uiComp       = 255;    // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed.
    544 #endif
    545 #if LGE_ILLUCOMP_B0045
    546   cDtParam.bUseIC = false;
    547 #endif
    548   return cDtParam.DistFunc( &cDtParam );
    549 }
    550 #endif
     482  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8);
     483
     484}
     485
     486#if SCU_HS_FAST_DEPTH_INTRA_E0238
     487
     488UInt TComRdCost::calcVAR (Pel* pi0, Int stride, Int width, Int height, Int cuDepth)
     489{
     490  Int temp = 0;
     491
     492  for (Int y = 0; y < height; y++)
     493  {
     494    for (Int x = 0; x < width; x++)
     495    {
     496      temp += pi0[ y * stride + x ];
     497    }
     498  }
     499
     500  Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2;
     501 
     502  if ( width == 4 )
     503  {
     504    cuDepth = cuMaxLog2Size - 2;
     505  }
     506
     507  temp = temp >> (cuMaxLog2Size-cuDepth) * 2;
     508
     509  UInt sum = 0;
     510  for (Int y = 0; y < height; y++)
     511  {
     512    for (Int x = 0; x <  width; x++)
     513    {
     514      sum += (pi0[ y * stride + x ] - temp ) * (pi0[ y * stride + x ] - temp );
     515    }
     516  }
     517  return (sum >> (cuMaxLog2Size-cuDepth)*2);
     518
     519}
     520#endif
     521
    551522
    552523#if WEIGHTED_CHROMA_DISTORTION
    553 UInt TComRdCost::getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bWeighted, DFunc eDFunc )
     524UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText, DFunc eDFunc)
    554525#else
    555 UInt TComRdCost::getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc )
     526UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc )
    556527#endif
    557528{
     
    566537  cDtParam.bApplyWeight = false;
    567538  cDtParam.uiComp       = 255;    // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed.
    568 
     539  cDtParam.bitDepth = bitDepth;
     540
     541#if H_3D_IC
     542  cDtParam.bUseIC       = false;
     543#endif
     544#if LGE_INTER_SDC_E0156
     545  cDtParam.bUseSDCMRSAD = false;
     546#endif
    569547#if WEIGHTED_CHROMA_DISTORTION
    570 #if LGE_ILLUCOMP_B0045
    571   cDtParam.bUseIC = false;
    572 #endif
    573   if (bWeighted)
    574   {
    575     return ((int) (m_chromaDistortionWeight * cDtParam.DistFunc( &cDtParam )));
     548  if (eText == TEXT_CHROMA_U)
     549  {
     550   return ((Int) (m_cbDistortionWeight * cDtParam.DistFunc( &cDtParam )));
     551  }
     552  else if (eText == TEXT_CHROMA_V)
     553  {
     554   return ((Int) (m_crDistortionWeight * cDtParam.DistFunc( &cDtParam )));
    576555  }
    577556  else
     
    583562#endif
    584563}
    585 
    586 
    587 #if SAIT_VSO_EST_A0033
    588 UInt TComRdCost::getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, Pel* piVirRec, Pel* piVirOrg, Int iVirStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc )
     564#if H_3D_VSO
     565// SAIT_VSO_EST_A0033
     566UInt TComRdCost::getDistPartVSD( TComDataCU* pcCU, UInt uiPartOffset, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight,  Bool bHAD, DFunc eDFunc )
    589567{
    590568  AOT( ( m_dDisparityCoeff <= 0 ) || ( m_dDisparityCoeff > 10 ) );
     569
     570  Pel* piVirRec  = m_pcVideoRecPicYuv->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset);
     571  Pel* piVirOrg  = m_pcDepthPicYuv   ->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset);
     572  Int iVirStride = m_pcVideoRecPicYuv->getStride();   
    591573
    592574  DistParam cDtParam;
     
    604586  cDtParam.uiComp       = 255;    // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed.
    605587
    606 #if LGE_ILLUCOMP_B0045
    607   cDtParam.bUseIC = false;
    608 #endif
    609   return cDtParam.DistFunc( &cDtParam );
    610 }
    611 #endif
     588  Dist dist = cDtParam.DistFunc( &cDtParam );
     589
     590  if ( m_bUseWVSO )   
     591  {
     592    Int iDWeight   = m_iDWeight   * m_iDWeight;
     593    Int iVSOWeight = m_iVSDWeight * m_iVSDWeight;
     594    Dist distDepth;
     595
     596    if ( !bHAD )
     597    {
     598      distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
     599    }
     600    else
     601    {
     602      distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
     603    }
     604
     605    dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight);
     606  }
     607#if H_3D_FIX_UINT_WARNING
     608  return (UInt) dist;
     609#else
     610  return dist;
     611#endif
     612
     613}
     614#endif
     615
     616#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     617UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height )
     618{
     619  UInt SAD = 0;
     620  Int shift = DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8);
     621  for ( Int i=0; i<height; i++ )
     622  {
     623    for( Int j=0; j<width; j++ )
     624    {
     625      SAD += abs((pelCur[j] - pelOrg[j])) >> shift;
     626    }
     627    pelCur = pelCur + curStride;
     628    pelOrg = pelOrg + orgStride;
     629  }
     630  return SAD;
     631}
     632#endif
     633
     634// ====================================================================================================================
     635// Distortion functions
     636// ====================================================================================================================
     637
     638// --------------------------------------------------------------------------------------------------------------------
     639// SAD
     640// --------------------------------------------------------------------------------------------------------------------
    612641
    613642UInt TComRdCost::xGetSAD( DistParam* pcDtParam )
     
    617646    return xGetSADw( pcDtParam );
    618647  }
    619 #if LGE_ILLUCOMP_B0045
    620   if(pcDtParam->bUseIC)
     648#if H_3D_IC
     649  if( pcDtParam->bUseIC )
     650  {
     651    return xGetSADic( pcDtParam );
     652  }
     653#endif
     654#if LGE_INTER_SDC_E0156
     655  if( pcDtParam->bUseSDCMRSAD )
    621656  {
    622657    return xGetSADic( pcDtParam );
     
    629664  Int  iStrideCur = pcDtParam->iStrideCur;
    630665  Int  iStrideOrg = pcDtParam->iStrideOrg;
    631 
     666 
    632667  UInt uiSum = 0;
    633 
     668 
    634669  for( ; iRows != 0; iRows-- )
    635670  {
     
    641676    piCur += iStrideCur;
    642677  }
    643 
    644   return ( uiSum >> g_uiBitIncrement );
     678 
     679  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    645680}
    646681
     
    651686    return xGetSADw( pcDtParam );
    652687  }
    653 #if LGE_ILLUCOMP_B0045
    654   if(pcDtParam->bUseIC)
     688#if H_3D_IC
     689  if( pcDtParam->bUseIC )
     690  {
     691    return xGetSAD4ic( pcDtParam );
     692  }
     693#endif
     694#if LGE_INTER_SDC_E0156
     695  if( pcDtParam->bUseSDCMRSAD )
    655696  {
    656697    return xGetSAD4ic( pcDtParam );
     
    664705  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    665706  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    666 
     707 
    667708  UInt uiSum = 0;
    668 
     709 
    669710  for( ; iRows != 0; iRows-=iSubStep )
    670711  {
     
    673714    uiSum += abs( piOrg[2] - piCur[2] );
    674715    uiSum += abs( piOrg[3] - piCur[3] );
    675 
    676     piOrg += iStrideOrg;
    677     piCur += iStrideCur;
    678   }
    679 
     716   
     717    piOrg += iStrideOrg;
     718    piCur += iStrideCur;
     719  }
     720 
    680721  uiSum <<= iSubShift;
    681   return ( uiSum >> g_uiBitIncrement );
     722  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    682723}
    683724
     
    688729    return xGetSADw( pcDtParam );
    689730  }
    690 #if LGE_ILLUCOMP_B0045
    691   if(pcDtParam->bUseIC)
     731#if H_3D_IC
     732  if( pcDtParam->bUseIC )
     733  {
     734    return xGetSAD8ic( pcDtParam );
     735  }
     736#endif
     737#if LGE_INTER_SDC_E0156
     738  if( pcDtParam->bUseSDCMRSAD )
    692739  {
    693740    return xGetSAD8ic( pcDtParam );
     
    701748  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    702749  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    703 
     750 
    704751  UInt uiSum = 0;
    705 
     752 
    706753  for( ; iRows != 0; iRows-=iSubStep )
    707754  {
     
    714761    uiSum += abs( piOrg[6] - piCur[6] );
    715762    uiSum += abs( piOrg[7] - piCur[7] );
    716 
    717     piOrg += iStrideOrg;
    718     piCur += iStrideCur;
    719   }
    720 
     763   
     764    piOrg += iStrideOrg;
     765    piCur += iStrideCur;
     766  }
     767 
    721768  uiSum <<= iSubShift;
    722   return ( uiSum >> g_uiBitIncrement );
     769  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    723770}
    724771
     
    729776    return xGetSADw( pcDtParam );
    730777  }
    731 #if LGE_ILLUCOMP_B0045
    732   if(pcDtParam->bUseIC)
     778#if H_3D_IC
     779  if( pcDtParam->bUseIC )
     780  {
     781    return xGetSAD16ic( pcDtParam );
     782  }
     783#endif
     784#if LGE_INTER_SDC_E0156
     785  if( pcDtParam->bUseSDCMRSAD )
    733786  {
    734787    return xGetSAD16ic( pcDtParam );
     
    742795  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    743796  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    744 
     797 
    745798  UInt uiSum = 0;
    746 
     799 
    747800  for( ; iRows != 0; iRows-=iSubStep )
    748801  {
     
    763816    uiSum += abs( piOrg[14] - piCur[14] );
    764817    uiSum += abs( piOrg[15] - piCur[15] );
    765 
    766     piOrg += iStrideOrg;
    767     piCur += iStrideCur;
    768   }
    769 
     818   
     819    piOrg += iStrideOrg;
     820    piCur += iStrideCur;
     821  }
     822 
    770823  uiSum <<= iSubShift;
    771   return ( uiSum >> g_uiBitIncrement );
     824  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    772825}
    773826
     
    779832    return xGetSADw( pcDtParam );
    780833  }
    781 #if LGE_ILLUCOMP_B0045
    782   if(pcDtParam->bUseIC)
     834#if H_3D_IC
     835  if( pcDtParam->bUseIC )
     836  {
     837    return xGetSAD12ic( pcDtParam );
     838  }
     839#endif
     840#if LGE_INTER_SDC_E0156
     841  if( pcDtParam->bUseSDCMRSAD )
    783842  {
    784843    return xGetSAD12ic( pcDtParam );
     
    792851  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    793852  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    794 
     853 
    795854  UInt uiSum = 0;
    796 
     855 
    797856  for( ; iRows != 0; iRows-=iSubStep )
    798857  {
     
    809868    uiSum += abs( piOrg[10] - piCur[10] );
    810869    uiSum += abs( piOrg[11] - piCur[11] );
    811 
    812     piOrg += iStrideOrg;
    813     piCur += iStrideCur;
    814   }
    815 
     870   
     871    piOrg += iStrideOrg;
     872    piCur += iStrideCur;
     873  }
     874 
    816875  uiSum <<= iSubShift;
    817   return ( uiSum >> g_uiBitIncrement );
     876  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    818877}
    819878#endif
     
    821880UInt TComRdCost::xGetSAD16N( DistParam* pcDtParam )
    822881{
    823 #if LGE_ILLUCOMP_B0045
    824   if(pcDtParam->bUseIC)
     882#if H_3D_IC
     883  if( pcDtParam->bUseIC )
     884  {
     885    return xGetSAD16Nic( pcDtParam );
     886  }
     887#endif
     888#if LGE_INTER_SDC_E0156
     889  if( pcDtParam->bUseSDCMRSAD )
    825890  {
    826891    return xGetSAD16Nic( pcDtParam );
     
    835900  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    836901  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    837 
     902 
    838903  UInt uiSum = 0;
    839 
     904 
    840905  for( ; iRows != 0; iRows-=iSubStep )
    841906  {
     
    862927    piCur += iStrideCur;
    863928  }
    864 
     929 
    865930  uiSum <<= iSubShift;
    866   return ( uiSum >> g_uiBitIncrement );
     931  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    867932}
    868933
     
    873938    return xGetSADw( pcDtParam );
    874939  }
    875 #if LGE_ILLUCOMP_B0045
    876   if(pcDtParam->bUseIC)
     940#if H_3D_IC
     941  if( pcDtParam->bUseIC )
     942  {
     943    return xGetSAD32ic( pcDtParam );
     944  }
     945#endif
     946#if LGE_INTER_SDC_E0156
     947  if( pcDtParam->bUseSDCMRSAD )
    877948  {
    878949    return xGetSAD32ic( pcDtParam );
     
    886957  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    887958  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    888 
     959 
    889960  UInt uiSum = 0;
    890 
     961 
    891962  for( ; iRows != 0; iRows-=iSubStep )
    892963  {
     
    923994    uiSum += abs( piOrg[30] - piCur[30] );
    924995    uiSum += abs( piOrg[31] - piCur[31] );
    925 
    926     piOrg += iStrideOrg;
    927     piCur += iStrideCur;
    928   }
    929 
     996   
     997    piOrg += iStrideOrg;
     998    piCur += iStrideCur;
     999  }
     1000 
    9301001  uiSum <<= iSubShift;
    931   return ( uiSum >> g_uiBitIncrement );
     1002  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    9321003}
    9331004
     
    9391010    return xGetSADw( pcDtParam );
    9401011  }
    941 #if LGE_ILLUCOMP_B0045
    942   if(pcDtParam->bUseIC)
     1012#if H_3D_IC
     1013  if( pcDtParam->bUseIC )
     1014  {
     1015    return xGetSAD24ic( pcDtParam );
     1016  }
     1017#endif
     1018#if LGE_INTER_SDC_E0156
     1019  if( pcDtParam->bUseSDCMRSAD )
    9431020  {
    9441021    return xGetSAD24ic( pcDtParam );
     
    9521029  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    9531030  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    954 
     1031 
    9551032  UInt uiSum = 0;
    956 
     1033 
    9571034  for( ; iRows != 0; iRows-=iSubStep )
    9581035  {
     
    9811058    uiSum += abs( piOrg[22] - piCur[22] );
    9821059    uiSum += abs( piOrg[23] - piCur[23] );
    983 
    984     piOrg += iStrideOrg;
    985     piCur += iStrideCur;
    986   }
    987 
     1060   
     1061    piOrg += iStrideOrg;
     1062    piCur += iStrideCur;
     1063  }
     1064 
    9881065  uiSum <<= iSubShift;
    989   return ( uiSum >> g_uiBitIncrement );
     1066  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    9901067}
    9911068
     
    9981075    return xGetSADw( pcDtParam );
    9991076  }
    1000 #if LGE_ILLUCOMP_B0045
    1001   if(pcDtParam->bUseIC)
     1077#if H_3D_IC
     1078  if( pcDtParam->bUseIC )
     1079  {
     1080    return xGetSAD64ic( pcDtParam );
     1081  }
     1082#endif
     1083#if LGE_INTER_SDC_E0156
     1084  if( pcDtParam->bUseSDCMRSAD )
    10021085  {
    10031086    return xGetSAD64ic( pcDtParam );
     
    10111094  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    10121095  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1013 
     1096 
    10141097  UInt uiSum = 0;
    1015 
     1098 
    10161099  for( ; iRows != 0; iRows-=iSubStep )
    10171100  {
     
    10801163    uiSum += abs( piOrg[62] - piCur[62] );
    10811164    uiSum += abs( piOrg[63] - piCur[63] );
    1082 
    1083     piOrg += iStrideOrg;
    1084     piCur += iStrideCur;
    1085   }
    1086 
     1165   
     1166    piOrg += iStrideOrg;
     1167    piCur += iStrideCur;
     1168  }
     1169 
    10871170  uiSum <<= iSubShift;
    1088   return ( uiSum >> g_uiBitIncrement );
     1171  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    10891172}
    10901173
     
    10961179    return xGetSADw( pcDtParam );
    10971180  }
    1098 #if LGE_ILLUCOMP_B0045
    1099   if(pcDtParam->bUseIC)
     1181#if H_3D_IC
     1182  if( pcDtParam->bUseIC )
     1183  {
     1184    return xGetSAD48ic( pcDtParam );
     1185  }
     1186#endif
     1187#if LGE_INTER_SDC_E0156
     1188  if( pcDtParam->bUseSDCMRSAD )
    11001189  {
    11011190    return xGetSAD48ic( pcDtParam );
     
    11091198  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    11101199  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1111 
     1200 
    11121201  UInt uiSum = 0;
    1113 
     1202 
    11141203  for( ; iRows != 0; iRows-=iSubStep )
    11151204  {
     
    11621251    uiSum += abs( piOrg[46] - piCur[46] );
    11631252    uiSum += abs( piOrg[47] - piCur[47] );
    1164 
    1165     piOrg += iStrideOrg;
    1166     piCur += iStrideCur;
    1167   }
    1168 
     1253   
     1254    piOrg += iStrideOrg;
     1255    piCur += iStrideCur;
     1256  }
     1257 
    11691258  uiSum <<= iSubShift;
    1170   return ( uiSum >> g_uiBitIncrement );
    1171 }
    1172 #endif
    1173 
    1174 // ====================================================================================================================
    1175 // Distortion functions
    1176 // ====================================================================================================================
    1177 
    1178 // --------------------------------------------------------------------------------------------------------------------
    1179 // SAD
    1180 // --------------------------------------------------------------------------------------------------------------------
    1181 #if LGE_ILLUCOMP_B0045
     1259  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     1260}
     1261#endif
     1262
     1263#if H_3D_IC || LGE_INTER_SDC_E0156
    11821264UInt TComRdCost::xGetSADic( DistParam* pcDtParam )
    11831265{
     
    11921274  Int  iStrideCur = pcDtParam->iStrideCur;
    11931275  Int  iStrideOrg = pcDtParam->iStrideOrg;
    1194  
     1276
    11951277  UInt uiSum = 0;
    1196  
     1278
    11971279  Int  iOrigAvg = 0, iCurAvg = 0;
    11981280  Int  iDeltaC;
     
    12251307  }
    12261308
    1227   return ( uiSum >> g_uiBitIncrement );
     1309  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    12281310}
    12291311
     
    12411323  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    12421324  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1243  
     1325
    12441326  UInt uiSum = 0;
    1245  
     1327
    12461328  Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    12471329  Int  iDeltaC;
     
    12801362    piCur += iStrideCur;
    12811363  }
    1282  
     1364
    12831365  uiSum <<= iSubShift;
    1284   return ( uiSum >> g_uiBitIncrement );
     1366  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    12851367}
    12861368
     
    12981380  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    12991381  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1300  
     1382
    13011383  UInt uiSum = 0;
    1302  
     1384
    13031385  Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    13041386  Int  iDeltaC;
     
    13491431    piCur += iStrideCur;
    13501432  }
    1351  
     1433
    13521434  uiSum <<= iSubShift;
    1353   return ( uiSum >> g_uiBitIncrement );
     1435  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    13541436}
    13551437
     
    13671449  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    13681450  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1369  
     1451
    13701452  UInt uiSum = 0;
    1371  
     1453
    13721454  Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    13731455  Int iDeltaC;
     
    14421524    piCur += iStrideCur;
    14431525  }
    1444  
     1526
    14451527  uiSum <<= iSubShift;
    1446   return ( uiSum >> g_uiBitIncrement );
     1528  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    14471529}
    14481530
     
    14611543  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    14621544  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1463  
     1545
    14641546  UInt uiSum = 0;
    1465  
     1547
    14661548  Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    14671549  Int  iDeltaC;
     
    15241606    piCur += iStrideCur;
    15251607  }
    1526  
     1608
    15271609  uiSum <<= iSubShift;
    1528   return ( uiSum >> g_uiBitIncrement );
     1610  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    15291611}
    15301612#endif
     
    15401622  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    15411623  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1542  
     1624
    15431625  UInt uiSum = 0;
    15441626
     
    16181700    piCur += iStrideCur;
    16191701  }
    1620  
     1702
    16211703  uiSum <<= iSubShift;
    1622   return ( uiSum >> g_uiBitIncrement );
     1704  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    16231705}
    16241706
     
    16361718  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    16371719  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1638  
     1720
    16391721  UInt uiSum = 0;
    1640  
     1722
    16411723  Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    16421724  Int  iDeltaC;
     
    17591841    piCur += iStrideCur;
    17601842  }
    1761  
     1843
    17621844  uiSum <<= iSubShift;
    1763   return ( uiSum >> g_uiBitIncrement );
     1845  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    17641846}
    17651847
     
    17781860  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    17791861  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1780  
     1862
    17811863  UInt uiSum = 0;
    1782  
     1864
    17831865  Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    17841866  Int  iDeltaC;
     
    18441926  piCur   = pcDtParam->pCur;
    18451927  iRows   = pcDtParam->iRows;
    1846  
     1928
    18471929  iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/24) : 0;
    18481930
     
    18791961
    18801962  uiSum <<= iSubShift;
    1881   return ( uiSum >> g_uiBitIncrement );
     1963  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    18821964}
    18831965#endif
     
    18961978  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    18971979  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1898  
     1980
    18991981  UInt uiSum = 0;
    1900  
     1982
    19011983  Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    19021984  Int  iDeltaC;
     
    21152197    piCur += iStrideCur;
    21162198  }
    2117  
     2199
    21182200  uiSum <<= iSubShift;
    2119   return ( uiSum >> g_uiBitIncrement );
     2201  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    21202202}
    21212203
     
    21272209    return xGetSADw( pcDtParam );
    21282210  }
     2211
    21292212  Pel* piOrg   = pcDtParam->pOrg;
    21302213  Pel* piCur   = pcDtParam->pCur;
     
    21342217  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    21352218  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    2136  
     2219
    21372220  UInt uiSum = 0;
    2138  
     2221
    21392222  Int  iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0;
    21402223  Int  iDeltaC;
     
    23052388    piCur += iStrideCur;
    23062389  }
    2307  
     2390
    23082391  uiSum <<= iSubShift;
    2309   return ( uiSum >> g_uiBitIncrement );
    2310 }
    2311 #endif
    2312 #endif
    2313 
     2392  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
     2393}
     2394#endif
     2395
     2396#endif
    23142397// --------------------------------------------------------------------------------------------------------------------
    23152398// SSE
    23162399// --------------------------------------------------------------------------------------------------------------------
    23172400
    2318 #if IBDI_DISTORTION
    23192401UInt TComRdCost::xGetSSE( DistParam* pcDtParam )
    23202402{
     2403  if ( pcDtParam->bApplyWeight )
     2404  {
     2405    return xGetSSEw( pcDtParam );
     2406  }
    23212407  Pel* piOrg   = pcDtParam->pOrg;
    23222408  Pel* piCur   = pcDtParam->pCur;
     
    23252411  Int  iStrideOrg = pcDtParam->iStrideOrg;
    23262412  Int  iStrideCur = pcDtParam->iStrideCur;
    2327 
     2413 
    23282414  UInt uiSum = 0;
    2329   Int  iShift = g_uiBitIncrement;
    2330   Int  iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0;
    2331 
     2415  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     2416 
    23322417  Int iTemp;
    2333 
     2418 
    23342419  for( ; iRows != 0; iRows-- )
    23352420  {
    23362421    for (Int n = 0; n < iCols; n++ )
    23372422    {
    2338       iTemp = ((piOrg[n  ]+iOffset)>>iShift) - ((piCur[n  ]+iOffset)>>iShift);
    2339       uiSum += iTemp * iTemp;
    2340     }
    2341     piOrg += iStrideOrg;
    2342     piCur += iStrideCur;
    2343   }
    2344 
     2423      iTemp = piOrg[n  ] - piCur[n  ];
     2424      uiSum += ( iTemp * iTemp ) >> uiShift;
     2425    }
     2426    piOrg += iStrideOrg;
     2427    piCur += iStrideCur;
     2428  }
     2429 
    23452430  return ( uiSum );
    23462431}
     
    23482433UInt TComRdCost::xGetSSE4( DistParam* pcDtParam )
    23492434{
     2435  if ( pcDtParam->bApplyWeight )
     2436  {
     2437    assert( pcDtParam->iCols == 4 );
     2438    return xGetSSEw( pcDtParam );
     2439  }
    23502440  Pel* piOrg   = pcDtParam->pOrg;
    23512441  Pel* piCur   = pcDtParam->pCur;
     
    23532443  Int  iStrideOrg = pcDtParam->iStrideOrg;
    23542444  Int  iStrideCur = pcDtParam->iStrideCur;
    2355 
     2445 
    23562446  UInt uiSum = 0;
    2357   Int  iShift = g_uiBitIncrement;
    2358   Int  iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0;
    2359 
     2447  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     2448 
    23602449  Int  iTemp;
    2361 
    2362   for( ; iRows != 0; iRows-- )
    2363   {
    2364 
    2365     iTemp = ((piOrg[0]+iOffset)>>iShift) - ((piCur[0]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2366     iTemp = ((piOrg[1]+iOffset)>>iShift) - ((piCur[1]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2367     iTemp = ((piOrg[2]+iOffset)>>iShift) - ((piCur[2]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2368     iTemp = ((piOrg[3]+iOffset)>>iShift) - ((piCur[3]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2369 
    2370     piOrg += iStrideOrg;
    2371     piCur += iStrideCur;
    2372   }
    2373 
    2374   return ( uiSum );
    2375 }
    2376 
    2377 UInt TComRdCost::xGetSSE8( DistParam* pcDtParam )
    2378 {
    2379   Pel* piOrg   = pcDtParam->pOrg;
    2380   Pel* piCur   = pcDtParam->pCur;
    2381   Int  iRows   = pcDtParam->iRows;
    2382   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2383   Int  iStrideCur = pcDtParam->iStrideCur;
    2384 
    2385   UInt uiSum = 0;
    2386   Int  iShift = g_uiBitIncrement;
    2387   Int  iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0;
    2388 
    2389   Int  iTemp;
    2390 
    2391   for( ; iRows != 0; iRows-- )
    2392   {
    2393     iTemp = ((piOrg[0]+iOffset)>>iShift) - ((piCur[0]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2394     iTemp = ((piOrg[1]+iOffset)>>iShift) - ((piCur[1]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2395     iTemp = ((piOrg[2]+iOffset)>>iShift) - ((piCur[2]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2396     iTemp = ((piOrg[3]+iOffset)>>iShift) - ((piCur[3]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2397     iTemp = ((piOrg[4]+iOffset)>>iShift) - ((piCur[4]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2398     iTemp = ((piOrg[5]+iOffset)>>iShift) - ((piCur[5]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2399     iTemp = ((piOrg[6]+iOffset)>>iShift) - ((piCur[6]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2400     iTemp = ((piOrg[7]+iOffset)>>iShift) - ((piCur[7]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2401 
    2402     piOrg += iStrideOrg;
    2403     piCur += iStrideCur;
    2404   }
    2405 
    2406   return ( uiSum );
    2407 }
    2408 
    2409 UInt TComRdCost::xGetSSE16( DistParam* pcDtParam )
    2410 {
    2411   Pel* piOrg   = pcDtParam->pOrg;
    2412   Pel* piCur   = pcDtParam->pCur;
    2413   Int  iRows   = pcDtParam->iRows;
    2414   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2415   Int  iStrideCur = pcDtParam->iStrideCur;
    2416 
    2417   UInt uiSum = 0;
    2418   Int  iShift = g_uiBitIncrement;
    2419   Int  iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0;
    2420 
    2421   Int  iTemp;
    2422 
    2423   for( ; iRows != 0; iRows-- )
    2424   {
    2425 
    2426     iTemp = ((piOrg[ 0]+iOffset)>>iShift) - ((piCur[ 0]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2427     iTemp = ((piOrg[ 1]+iOffset)>>iShift) - ((piCur[ 1]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2428     iTemp = ((piOrg[ 2]+iOffset)>>iShift) - ((piCur[ 2]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2429     iTemp = ((piOrg[ 3]+iOffset)>>iShift) - ((piCur[ 3]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2430     iTemp = ((piOrg[ 4]+iOffset)>>iShift) - ((piCur[ 4]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2431     iTemp = ((piOrg[ 5]+iOffset)>>iShift) - ((piCur[ 5]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2432     iTemp = ((piOrg[ 6]+iOffset)>>iShift) - ((piCur[ 6]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2433     iTemp = ((piOrg[ 7]+iOffset)>>iShift) - ((piCur[ 7]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2434     iTemp = ((piOrg[ 8]+iOffset)>>iShift) - ((piCur[ 8]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2435     iTemp = ((piOrg[ 9]+iOffset)>>iShift) - ((piCur[ 9]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2436     iTemp = ((piOrg[10]+iOffset)>>iShift) - ((piCur[10]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2437     iTemp = ((piOrg[11]+iOffset)>>iShift) - ((piCur[11]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2438     iTemp = ((piOrg[12]+iOffset)>>iShift) - ((piCur[12]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2439     iTemp = ((piOrg[13]+iOffset)>>iShift) - ((piCur[13]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2440     iTemp = ((piOrg[14]+iOffset)>>iShift) - ((piCur[14]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2441     iTemp = ((piOrg[15]+iOffset)>>iShift) - ((piCur[15]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2442 
    2443     piOrg += iStrideOrg;
    2444     piCur += iStrideCur;
    2445   }
    2446 
    2447   return ( uiSum );
    2448 }
    2449 
    2450 UInt TComRdCost::xGetSSE16N( DistParam* pcDtParam )
    2451 {
    2452   Pel* piOrg   = pcDtParam->pOrg;
    2453   Pel* piCur   = pcDtParam->pCur;
    2454   Int  iRows   = pcDtParam->iRows;
    2455   Int  iCols   = pcDtParam->iCols;
    2456   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2457   Int  iStrideCur = pcDtParam->iStrideCur;
    2458 
    2459   UInt uiSum = 0;
    2460   Int  iShift = g_uiBitIncrement;
    2461   Int  iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0;
    2462   Int  iTemp;
    2463 
    2464   for( ; iRows != 0; iRows-- )
    2465   {
    2466     for (Int n = 0; n < iCols; n+=16 )
    2467     {
    2468 
    2469       iTemp = ((piOrg[n+ 0]+iOffset)>>iShift) - ((piCur[n+ 0]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2470       iTemp = ((piOrg[n+ 1]+iOffset)>>iShift) - ((piCur[n+ 1]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2471       iTemp = ((piOrg[n+ 2]+iOffset)>>iShift) - ((piCur[n+ 2]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2472       iTemp = ((piOrg[n+ 3]+iOffset)>>iShift) - ((piCur[n+ 3]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2473       iTemp = ((piOrg[n+ 4]+iOffset)>>iShift) - ((piCur[n+ 4]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2474       iTemp = ((piOrg[n+ 5]+iOffset)>>iShift) - ((piCur[n+ 5]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2475       iTemp = ((piOrg[n+ 6]+iOffset)>>iShift) - ((piCur[n+ 6]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2476       iTemp = ((piOrg[n+ 7]+iOffset)>>iShift) - ((piCur[n+ 7]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2477       iTemp = ((piOrg[n+ 8]+iOffset)>>iShift) - ((piCur[n+ 8]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2478       iTemp = ((piOrg[n+ 9]+iOffset)>>iShift) - ((piCur[n+ 9]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2479       iTemp = ((piOrg[n+10]+iOffset)>>iShift) - ((piCur[n+10]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2480       iTemp = ((piOrg[n+11]+iOffset)>>iShift) - ((piCur[n+11]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2481       iTemp = ((piOrg[n+12]+iOffset)>>iShift) - ((piCur[n+12]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2482       iTemp = ((piOrg[n+13]+iOffset)>>iShift) - ((piCur[n+13]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2483       iTemp = ((piOrg[n+14]+iOffset)>>iShift) - ((piCur[n+14]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2484       iTemp = ((piOrg[n+15]+iOffset)>>iShift) - ((piCur[n+15]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2485 
    2486     }
    2487     piOrg += iStrideOrg;
    2488     piCur += iStrideCur;
    2489   }
    2490 
    2491   return ( uiSum );
    2492 }
    2493 
    2494 UInt TComRdCost::xGetSSE32( DistParam* pcDtParam )
    2495 {
    2496   Pel* piOrg   = pcDtParam->pOrg;
    2497   Pel* piCur   = pcDtParam->pCur;
    2498   Int  iRows   = pcDtParam->iRows;
    2499   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2500   Int  iStrideCur = pcDtParam->iStrideCur;
    2501 
    2502   UInt uiSum = 0;
    2503   Int  iShift = g_uiBitIncrement;
    2504   Int  iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0;
    2505   Int  iTemp;
    2506 
    2507   for( ; iRows != 0; iRows-- )
    2508   {
    2509 
    2510     iTemp = ((piOrg[ 0]+iOffset)>>iShift) - ((piCur[ 0]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2511     iTemp = ((piOrg[ 1]+iOffset)>>iShift) - ((piCur[ 1]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2512     iTemp = ((piOrg[ 2]+iOffset)>>iShift) - ((piCur[ 2]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2513     iTemp = ((piOrg[ 3]+iOffset)>>iShift) - ((piCur[ 3]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2514     iTemp = ((piOrg[ 4]+iOffset)>>iShift) - ((piCur[ 4]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2515     iTemp = ((piOrg[ 5]+iOffset)>>iShift) - ((piCur[ 5]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2516     iTemp = ((piOrg[ 6]+iOffset)>>iShift) - ((piCur[ 6]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2517     iTemp = ((piOrg[ 7]+iOffset)>>iShift) - ((piCur[ 7]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2518     iTemp = ((piOrg[ 8]+iOffset)>>iShift) - ((piCur[ 8]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2519     iTemp = ((piOrg[ 9]+iOffset)>>iShift) - ((piCur[ 9]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2520     iTemp = ((piOrg[10]+iOffset)>>iShift) - ((piCur[10]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2521     iTemp = ((piOrg[11]+iOffset)>>iShift) - ((piCur[11]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2522     iTemp = ((piOrg[12]+iOffset)>>iShift) - ((piCur[12]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2523     iTemp = ((piOrg[13]+iOffset)>>iShift) - ((piCur[13]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2524     iTemp = ((piOrg[14]+iOffset)>>iShift) - ((piCur[14]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2525     iTemp = ((piOrg[15]+iOffset)>>iShift) - ((piCur[15]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2526     iTemp = ((piOrg[16]+iOffset)>>iShift) - ((piCur[16]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2527     iTemp = ((piOrg[17]+iOffset)>>iShift) - ((piCur[17]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2528     iTemp = ((piOrg[18]+iOffset)>>iShift) - ((piCur[18]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2529     iTemp = ((piOrg[19]+iOffset)>>iShift) - ((piCur[19]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2530     iTemp = ((piOrg[20]+iOffset)>>iShift) - ((piCur[20]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2531     iTemp = ((piOrg[21]+iOffset)>>iShift) - ((piCur[21]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2532     iTemp = ((piOrg[22]+iOffset)>>iShift) - ((piCur[22]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2533     iTemp = ((piOrg[23]+iOffset)>>iShift) - ((piCur[23]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2534     iTemp = ((piOrg[24]+iOffset)>>iShift) - ((piCur[24]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2535     iTemp = ((piOrg[25]+iOffset)>>iShift) - ((piCur[25]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2536     iTemp = ((piOrg[26]+iOffset)>>iShift) - ((piCur[26]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2537     iTemp = ((piOrg[27]+iOffset)>>iShift) - ((piCur[27]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2538     iTemp = ((piOrg[28]+iOffset)>>iShift) - ((piCur[28]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2539     iTemp = ((piOrg[29]+iOffset)>>iShift) - ((piCur[29]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2540     iTemp = ((piOrg[30]+iOffset)>>iShift) - ((piCur[30]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2541     iTemp = ((piOrg[31]+iOffset)>>iShift) - ((piCur[31]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2542 
    2543     piOrg += iStrideOrg;
    2544     piCur += iStrideCur;
    2545   }
    2546 
    2547   return ( uiSum );
    2548 }
    2549 
    2550 UInt TComRdCost::xGetSSE64( DistParam* pcDtParam )
    2551 {
    2552   Pel* piOrg   = pcDtParam->pOrg;
    2553   Pel* piCur   = pcDtParam->pCur;
    2554   Int  iRows   = pcDtParam->iRows;
    2555   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2556   Int  iStrideCur = pcDtParam->iStrideCur;
    2557 
    2558   UInt uiSum = 0;
    2559   Int  iShift = g_uiBitIncrement;
    2560   Int  iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0;
    2561   Int  iTemp;
    2562 
    2563   for( ; iRows != 0; iRows-- )
    2564   {
    2565     iTemp = ((piOrg[ 0]+iOffset)>>iShift) - ((piCur[ 0]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2566     iTemp = ((piOrg[ 1]+iOffset)>>iShift) - ((piCur[ 1]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2567     iTemp = ((piOrg[ 2]+iOffset)>>iShift) - ((piCur[ 2]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2568     iTemp = ((piOrg[ 3]+iOffset)>>iShift) - ((piCur[ 3]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2569     iTemp = ((piOrg[ 4]+iOffset)>>iShift) - ((piCur[ 4]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2570     iTemp = ((piOrg[ 5]+iOffset)>>iShift) - ((piCur[ 5]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2571     iTemp = ((piOrg[ 6]+iOffset)>>iShift) - ((piCur[ 6]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2572     iTemp = ((piOrg[ 7]+iOffset)>>iShift) - ((piCur[ 7]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2573     iTemp = ((piOrg[ 8]+iOffset)>>iShift) - ((piCur[ 8]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2574     iTemp = ((piOrg[ 9]+iOffset)>>iShift) - ((piCur[ 9]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2575     iTemp = ((piOrg[10]+iOffset)>>iShift) - ((piCur[10]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2576     iTemp = ((piOrg[11]+iOffset)>>iShift) - ((piCur[11]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2577     iTemp = ((piOrg[12]+iOffset)>>iShift) - ((piCur[12]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2578     iTemp = ((piOrg[13]+iOffset)>>iShift) - ((piCur[13]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2579     iTemp = ((piOrg[14]+iOffset)>>iShift) - ((piCur[14]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2580     iTemp = ((piOrg[15]+iOffset)>>iShift) - ((piCur[15]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2581     iTemp = ((piOrg[16]+iOffset)>>iShift) - ((piCur[16]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2582     iTemp = ((piOrg[17]+iOffset)>>iShift) - ((piCur[17]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2583     iTemp = ((piOrg[18]+iOffset)>>iShift) - ((piCur[18]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2584     iTemp = ((piOrg[19]+iOffset)>>iShift) - ((piCur[19]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2585     iTemp = ((piOrg[20]+iOffset)>>iShift) - ((piCur[20]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2586     iTemp = ((piOrg[21]+iOffset)>>iShift) - ((piCur[21]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2587     iTemp = ((piOrg[22]+iOffset)>>iShift) - ((piCur[22]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2588     iTemp = ((piOrg[23]+iOffset)>>iShift) - ((piCur[23]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2589     iTemp = ((piOrg[24]+iOffset)>>iShift) - ((piCur[24]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2590     iTemp = ((piOrg[25]+iOffset)>>iShift) - ((piCur[25]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2591     iTemp = ((piOrg[26]+iOffset)>>iShift) - ((piCur[26]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2592     iTemp = ((piOrg[27]+iOffset)>>iShift) - ((piCur[27]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2593     iTemp = ((piOrg[28]+iOffset)>>iShift) - ((piCur[28]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2594     iTemp = ((piOrg[29]+iOffset)>>iShift) - ((piCur[29]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2595     iTemp = ((piOrg[30]+iOffset)>>iShift) - ((piCur[30]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2596     iTemp = ((piOrg[31]+iOffset)>>iShift) - ((piCur[31]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2597     iTemp = ((piOrg[32]+iOffset)>>iShift) - ((piCur[32]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2598     iTemp = ((piOrg[33]+iOffset)>>iShift) - ((piCur[33]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2599     iTemp = ((piOrg[34]+iOffset)>>iShift) - ((piCur[34]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2600     iTemp = ((piOrg[35]+iOffset)>>iShift) - ((piCur[35]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2601     iTemp = ((piOrg[36]+iOffset)>>iShift) - ((piCur[36]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2602     iTemp = ((piOrg[37]+iOffset)>>iShift) - ((piCur[37]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2603     iTemp = ((piOrg[38]+iOffset)>>iShift) - ((piCur[38]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2604     iTemp = ((piOrg[39]+iOffset)>>iShift) - ((piCur[39]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2605     iTemp = ((piOrg[40]+iOffset)>>iShift) - ((piCur[40]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2606     iTemp = ((piOrg[41]+iOffset)>>iShift) - ((piCur[41]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2607     iTemp = ((piOrg[42]+iOffset)>>iShift) - ((piCur[42]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2608     iTemp = ((piOrg[43]+iOffset)>>iShift) - ((piCur[43]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2609     iTemp = ((piOrg[44]+iOffset)>>iShift) - ((piCur[44]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2610     iTemp = ((piOrg[45]+iOffset)>>iShift) - ((piCur[45]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2611     iTemp = ((piOrg[46]+iOffset)>>iShift) - ((piCur[46]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2612     iTemp = ((piOrg[47]+iOffset)>>iShift) - ((piCur[47]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2613     iTemp = ((piOrg[48]+iOffset)>>iShift) - ((piCur[48]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2614     iTemp = ((piOrg[49]+iOffset)>>iShift) - ((piCur[49]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2615     iTemp = ((piOrg[50]+iOffset)>>iShift) - ((piCur[50]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2616     iTemp = ((piOrg[51]+iOffset)>>iShift) - ((piCur[51]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2617     iTemp = ((piOrg[52]+iOffset)>>iShift) - ((piCur[52]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2618     iTemp = ((piOrg[53]+iOffset)>>iShift) - ((piCur[53]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2619     iTemp = ((piOrg[54]+iOffset)>>iShift) - ((piCur[54]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2620     iTemp = ((piOrg[55]+iOffset)>>iShift) - ((piCur[55]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2621     iTemp = ((piOrg[56]+iOffset)>>iShift) - ((piCur[56]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2622     iTemp = ((piOrg[57]+iOffset)>>iShift) - ((piCur[57]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2623     iTemp = ((piOrg[58]+iOffset)>>iShift) - ((piCur[58]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2624     iTemp = ((piOrg[59]+iOffset)>>iShift) - ((piCur[59]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2625     iTemp = ((piOrg[60]+iOffset)>>iShift) - ((piCur[60]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2626     iTemp = ((piOrg[61]+iOffset)>>iShift) - ((piCur[61]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2627     iTemp = ((piOrg[62]+iOffset)>>iShift) - ((piCur[62]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2628     iTemp = ((piOrg[63]+iOffset)>>iShift) - ((piCur[63]+iOffset)>>iShift); uiSum += iTemp * iTemp;
    2629 
    2630     piOrg += iStrideOrg;
    2631     piCur += iStrideCur;
    2632   }
    2633 
    2634   return ( uiSum );
    2635 }
    2636 #else
    2637 UInt TComRdCost::xGetSSE( DistParam* pcDtParam )
    2638 {
    2639   if ( pcDtParam->bApplyWeight )
    2640   {
    2641     return xGetSSEw( pcDtParam );
    2642   }
    2643   Pel* piOrg   = pcDtParam->pOrg;
    2644   Pel* piCur   = pcDtParam->pCur;
    2645   Int  iRows   = pcDtParam->iRows;
    2646   Int  iCols   = pcDtParam->iCols;
    2647   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2648   Int  iStrideCur = pcDtParam->iStrideCur;
    2649  
    2650   UInt uiSum = 0;
    2651   UInt uiShift = g_uiBitIncrement<<1;
    2652  
    2653   Int iTemp;
    2654  
    2655 #if HHI_INTERVIEW_SKIP
    2656   if( pcDtParam->pUsed )
    2657   {
    2658     Pel*  piUsed      = pcDtParam->pUsed;
    2659     Int   iStrideUsed = pcDtParam->iStrideUsed;
    2660   for( ; iRows != 0; iRows-- )
    2661   {
    2662     for (Int n = 0; n < iCols; n++ )
    2663     {
    2664         if( piUsed[n] )
    2665     {
    2666       iTemp = piOrg[n  ] - piCur[n  ];
    2667       uiSum += ( iTemp * iTemp ) >> uiShift;
    2668     }
    2669       }
    2670       piOrg  += iStrideOrg;
    2671       piCur  += iStrideCur;
    2672       piUsed += iStrideUsed;
    2673     }
    2674   }
    2675   else
    2676   {
    2677 #endif
    2678   for( ; iRows != 0; iRows-- )
    2679   {
    2680     for (Int n = 0; n < iCols; n++ )
    2681     {
    2682       iTemp = piOrg[n  ] - piCur[n  ];
    2683       uiSum += ( iTemp * iTemp ) >> uiShift;
    2684     }
    2685     piOrg += iStrideOrg;
    2686     piCur += iStrideCur;
    2687   }
    2688   #if HHI_INTERVIEW_SKIP
    2689   }
    2690 #endif
    2691  
    2692   return ( uiSum );
    2693 }
    2694 
    2695 UInt TComRdCost::xGetSSE4( DistParam* pcDtParam )
    2696 {
    2697   if ( pcDtParam->bApplyWeight )
    2698   {
    2699     assert( pcDtParam->iCols == 4 );
    2700     return xGetSSEw( pcDtParam );
    2701   }
    2702   Pel* piOrg   = pcDtParam->pOrg;
    2703   Pel* piCur   = pcDtParam->pCur;
    2704   Int  iRows   = pcDtParam->iRows;
    2705   Int  iStrideOrg = pcDtParam->iStrideOrg;
    2706   Int  iStrideCur = pcDtParam->iStrideCur;
    2707  
    2708   UInt uiSum = 0;
    2709   UInt uiShift = g_uiBitIncrement<<1;
    2710  
    2711   Int  iTemp;
    2712  
    2713 #if HHI_INTERVIEW_SKIP
    2714   if( pcDtParam->pUsed )
    2715   {
    2716     Pel*  piUsed      = pcDtParam->pUsed;
    2717     Int   iStrideUsed = pcDtParam->iStrideUsed;
    2718     for( ; iRows != 0; iRows-- )
    2719     {
    2720       if( piUsed[0] ) { iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2721       if( piUsed[1] ) { iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2722       if( piUsed[2] ) { iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2723       if( piUsed[3] ) { iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2724 
    2725       piOrg  += iStrideOrg;
    2726       piCur  += iStrideCur;
    2727       piUsed += iStrideUsed;
    2728     }
    2729   }
    2730   else
    2731   {
    2732 #endif
     2450 
    27332451  for( ; iRows != 0; iRows-- )
    27342452  {
     
    27422460    piCur += iStrideCur;
    27432461  }
    2744 #if HHI_INTERVIEW_SKIP
    2745   }
    2746 #endif
    27472462 
    27482463  return ( uiSum );
     
    27632478 
    27642479  UInt uiSum = 0;
    2765   UInt uiShift = g_uiBitIncrement<<1;
     2480  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    27662481 
    27672482  Int  iTemp;
    27682483 
    2769 #if HHI_INTERVIEW_SKIP
    2770   if( pcDtParam->pUsed )
    2771   {
    2772     Pel*  piUsed      = pcDtParam->pUsed;
    2773     Int   iStrideUsed = pcDtParam->iStrideUsed;
    2774     for( ; iRows != 0; iRows-- )
    2775     {
    2776       if( piUsed[0] ) { iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2777       if( piUsed[1] ) { iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2778       if( piUsed[2] ) { iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2779       if( piUsed[3] ) { iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2780       if( piUsed[4] ) { iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2781       if( piUsed[5] ) { iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2782       if( piUsed[6] ) { iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2783       if( piUsed[7] ) { iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2784 
    2785       piOrg  += iStrideOrg;
    2786       piCur  += iStrideCur;
    2787       piUsed += iStrideUsed;
    2788     }
    2789   }
    2790   else
    2791   {
    2792 #endif
    27932484  for( ; iRows != 0; iRows-- )
    27942485  {
     
    28052496    piCur += iStrideCur;
    28062497  }
    2807 #if HHI_INTERVIEW_SKIP
    2808   }
    2809 #endif
    28102498 
    28112499  return ( uiSum );
     
    28262514 
    28272515  UInt uiSum = 0;
    2828   UInt uiShift = g_uiBitIncrement<<1;
     2516  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    28292517 
    28302518  Int  iTemp;
    28312519 
    2832 #if HHI_INTERVIEW_SKIP
    2833   if( pcDtParam->pUsed )
    2834   {
    2835     Pel*  piUsed      = pcDtParam->pUsed;
    2836     Int   iStrideUsed = pcDtParam->iStrideUsed;
    2837     for( ; iRows != 0; iRows-- )
    2838     {
    2839       if( piUsed[ 0] ) { iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2840       if( piUsed[ 1] ) { iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2841       if( piUsed[ 2] ) { iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2842       if( piUsed[ 3] ) { iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2843       if( piUsed[ 4] ) { iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2844       if( piUsed[ 5] ) { iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2845       if( piUsed[ 6] ) { iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2846       if( piUsed[ 7] ) { iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2847       if( piUsed[ 8] ) { iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2848       if( piUsed[ 9] ) { iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2849       if( piUsed[10] ) { iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2850       if( piUsed[11] ) { iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2851       if( piUsed[12] ) { iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2852       if( piUsed[13] ) { iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2853       if( piUsed[14] ) { iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2854       if( piUsed[15] ) { iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2855 
    2856       piOrg  += iStrideOrg;
    2857       piCur  += iStrideCur;
    2858       piUsed += iStrideUsed;
    2859     }
    2860   }
    2861   else
    2862   {
    2863 #endif
    28642520  for( ; iRows != 0; iRows-- )
    28652521  {
     
    28852541    piCur += iStrideCur;
    28862542  }
    2887 #if HHI_INTERVIEW_SKIP
    2888   }
    2889 #endif
    28902543 
    28912544  return ( uiSum );
     
    29062559 
    29072560  UInt uiSum = 0;
    2908   UInt uiShift = g_uiBitIncrement<<1;
     2561  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    29092562  Int  iTemp;
    29102563 
    2911 #if HHI_INTERVIEW_SKIP
    2912   if( pcDtParam->pUsed )
    2913   {
    2914     Pel*  piUsed      = pcDtParam->pUsed;
    2915     Int   iStrideUsed = pcDtParam->iStrideUsed;
    2916     for( ; iRows != 0; iRows-- )
    2917     {
    2918       for (Int n = 0; n < iCols; n+=16 )
    2919       {
    2920         if( piUsed[n+ 0] ) { iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2921         if( piUsed[n+ 1] ) { iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2922         if( piUsed[n+ 2] ) { iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2923         if( piUsed[n+ 3] ) { iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2924         if( piUsed[n+ 4] ) { iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2925         if( piUsed[n+ 5] ) { iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2926         if( piUsed[n+ 6] ) { iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2927         if( piUsed[n+ 7] ) { iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2928         if( piUsed[n+ 8] ) { iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2929         if( piUsed[n+ 9] ) { iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2930         if( piUsed[n+10] ) { iTemp = piOrg[n+10] - piCur[n+10]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2931         if( piUsed[n+11] ) { iTemp = piOrg[n+11] - piCur[n+11]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2932         if( piUsed[n+12] ) { iTemp = piOrg[n+12] - piCur[n+12]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2933         if( piUsed[n+13] ) { iTemp = piOrg[n+13] - piCur[n+13]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2934         if( piUsed[n+14] ) { iTemp = piOrg[n+14] - piCur[n+14]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2935         if( piUsed[n+15] ) { iTemp = piOrg[n+15] - piCur[n+15]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    2936       }
    2937       piOrg  += iStrideOrg;
    2938       piCur  += iStrideCur;
    2939       piUsed += iStrideUsed;
    2940     }
    2941   }
    2942   else
    2943   {
    2944 #endif
    29452564  for( ; iRows != 0; iRows-- )
    29462565  {
     
    29692588    piCur += iStrideCur;
    29702589  }
    2971 #if HHI_INTERVIEW_SKIP
    2972   }
    2973 #endif
    29742590 
    29752591  return ( uiSum );
     
    29902606 
    29912607  UInt uiSum = 0;
    2992   UInt uiShift = g_uiBitIncrement<<1;
     2608  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    29932609  Int  iTemp;
    29942610 
    2995 #if HHI_INTERVIEW_SKIP
    2996   if( pcDtParam->pUsed )
    2997   {
    2998     Pel*  piUsed      = pcDtParam->pUsed;
    2999     Int   iStrideUsed = pcDtParam->iStrideUsed;
    3000     for( ; iRows != 0; iRows-- )
    3001     {
    3002       if( piUsed[ 0] ) { iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3003       if( piUsed[ 1] ) { iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3004       if( piUsed[ 2] ) { iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3005       if( piUsed[ 3] ) { iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3006       if( piUsed[ 4] ) { iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3007       if( piUsed[ 5] ) { iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3008       if( piUsed[ 6] ) { iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3009       if( piUsed[ 7] ) { iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3010       if( piUsed[ 8] ) { iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3011       if( piUsed[ 9] ) { iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3012       if( piUsed[10] ) { iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3013       if( piUsed[11] ) { iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3014       if( piUsed[12] ) { iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3015       if( piUsed[13] ) { iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3016       if( piUsed[14] ) { iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3017       if( piUsed[15] ) { iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3018       if( piUsed[16] ) { iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3019       if( piUsed[17] ) { iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3020       if( piUsed[18] ) { iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3021       if( piUsed[19] ) { iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3022       if( piUsed[20] ) { iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3023       if( piUsed[21] ) { iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3024       if( piUsed[22] ) { iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3025       if( piUsed[23] ) { iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3026       if( piUsed[24] ) { iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3027       if( piUsed[25] ) { iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3028       if( piUsed[26] ) { iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3029       if( piUsed[27] ) { iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3030       if( piUsed[28] ) { iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3031       if( piUsed[29] ) { iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3032       if( piUsed[30] ) { iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3033       if( piUsed[31] ) { iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3034 
    3035       piOrg  += iStrideOrg;
    3036       piCur  += iStrideCur;
    3037       piUsed += iStrideUsed;
    3038     }
    3039   }
    3040   else
    3041   {
    3042 #endif
    30432611  for( ; iRows != 0; iRows-- )
    30442612  {
     
    30802648    piCur += iStrideCur;
    30812649  }
    3082 #if HHI_INTERVIEW_SKIP
    3083   }
    3084 #endif
    30852650 
    30862651  return ( uiSum );
     
    31012666 
    31022667  UInt uiSum = 0;
    3103   UInt uiShift = g_uiBitIncrement<<1;
     2668  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    31042669  Int  iTemp;
    31052670 
    3106 #if HHI_INTERVIEW_SKIP
    3107   if( pcDtParam->pUsed )
    3108   {
    3109     Pel*  piUsed      = pcDtParam->pUsed;
    3110     Int   iStrideUsed = pcDtParam->iStrideUsed;
    3111     for( ; iRows != 0; iRows-- )
    3112     {
    3113       if( piUsed[ 0] ) { iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3114       if( piUsed[ 1] ) { iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3115       if( piUsed[ 2] ) { iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3116       if( piUsed[ 3] ) { iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3117       if( piUsed[ 4] ) { iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3118       if( piUsed[ 5] ) { iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3119       if( piUsed[ 6] ) { iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3120       if( piUsed[ 7] ) { iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3121       if( piUsed[ 8] ) { iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3122       if( piUsed[ 9] ) { iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3123       if( piUsed[10] ) { iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3124       if( piUsed[11] ) { iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3125       if( piUsed[12] ) { iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3126       if( piUsed[13] ) { iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3127       if( piUsed[14] ) { iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3128       if( piUsed[15] ) { iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3129       if( piUsed[16] ) { iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3130       if( piUsed[17] ) { iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3131       if( piUsed[18] ) { iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3132       if( piUsed[19] ) { iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3133       if( piUsed[20] ) { iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3134       if( piUsed[21] ) { iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3135       if( piUsed[22] ) { iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3136       if( piUsed[23] ) { iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3137       if( piUsed[24] ) { iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3138       if( piUsed[25] ) { iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3139       if( piUsed[26] ) { iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3140       if( piUsed[27] ) { iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3141       if( piUsed[28] ) { iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3142       if( piUsed[29] ) { iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3143       if( piUsed[30] ) { iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3144       if( piUsed[31] ) { iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3145       if( piUsed[32] ) { iTemp = piOrg[32] - piCur[32]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3146       if( piUsed[33] ) { iTemp = piOrg[33] - piCur[33]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3147       if( piUsed[34] ) { iTemp = piOrg[34] - piCur[34]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3148       if( piUsed[35] ) { iTemp = piOrg[35] - piCur[35]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3149       if( piUsed[36] ) { iTemp = piOrg[36] - piCur[36]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3150       if( piUsed[37] ) { iTemp = piOrg[37] - piCur[37]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3151       if( piUsed[38] ) { iTemp = piOrg[38] - piCur[38]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3152       if( piUsed[39] ) { iTemp = piOrg[39] - piCur[39]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3153       if( piUsed[40] ) { iTemp = piOrg[40] - piCur[40]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3154       if( piUsed[41] ) { iTemp = piOrg[41] - piCur[41]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3155       if( piUsed[42] ) { iTemp = piOrg[42] - piCur[42]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3156       if( piUsed[43] ) { iTemp = piOrg[43] - piCur[43]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3157       if( piUsed[44] ) { iTemp = piOrg[44] - piCur[44]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3158       if( piUsed[45] ) { iTemp = piOrg[45] - piCur[45]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3159       if( piUsed[46] ) { iTemp = piOrg[46] - piCur[46]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3160       if( piUsed[47] ) { iTemp = piOrg[47] - piCur[47]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3161       if( piUsed[48] ) { iTemp = piOrg[48] - piCur[48]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3162       if( piUsed[49] ) { iTemp = piOrg[49] - piCur[49]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3163       if( piUsed[50] ) { iTemp = piOrg[50] - piCur[50]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3164       if( piUsed[51] ) { iTemp = piOrg[51] - piCur[51]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3165       if( piUsed[52] ) { iTemp = piOrg[52] - piCur[52]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3166       if( piUsed[53] ) { iTemp = piOrg[53] - piCur[53]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3167       if( piUsed[54] ) { iTemp = piOrg[54] - piCur[54]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3168       if( piUsed[55] ) { iTemp = piOrg[55] - piCur[55]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3169       if( piUsed[56] ) { iTemp = piOrg[56] - piCur[56]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3170       if( piUsed[57] ) { iTemp = piOrg[57] - piCur[57]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3171       if( piUsed[58] ) { iTemp = piOrg[58] - piCur[58]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3172       if( piUsed[59] ) { iTemp = piOrg[59] - piCur[59]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3173       if( piUsed[60] ) { iTemp = piOrg[60] - piCur[60]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3174       if( piUsed[61] ) { iTemp = piOrg[61] - piCur[61]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3175       if( piUsed[62] ) { iTemp = piOrg[62] - piCur[62]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3176       if( piUsed[63] ) { iTemp = piOrg[63] - piCur[63]; uiSum += ( iTemp * iTemp ) >> uiShift; }
    3177 
    3178       piOrg  += iStrideOrg;
    3179       piCur  += iStrideCur;
    3180       piUsed += iStrideUsed;
    3181     }
    3182   }
    3183   else
    3184   {
    3185 #endif
    31862671  for( ; iRows != 0; iRows-- )
    31872672  {
     
    32542739    piCur += iStrideCur;
    32552740  }
    3256 #if HHI_INTERVIEW_SKIP
    3257   }
    3258 #endif
    32592741 
    32602742  return ( uiSum );
    32612743}
    3262 #endif
    3263 
    3264 
    3265 #if SAIT_VSO_EST_A0033
     2744#if H_3D_VSO
     2745//SAIT_VSO_EST_A0033
    32662746UInt TComRdCost::getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y )
    32672747{
     
    32692749  Int iTemp;
    32702750
    3271   dD = ( (Double) ( dDM >> g_uiBitIncrement ) ) * m_dDisparityCoeff;
    3272 
    3273   iTemp = (Int) ROUND( 0.5 * fabs(dD) * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) );
     2751  dD = ( (Double) ( dDM >> DISTORTION_PRECISION_ADJUSTMENT( g_bitDepthY - 8 ) ) ) * m_dDisparityCoeff;
     2752
     2753  Double dTemp = ( 0.5 * fabs(dD) * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) );
     2754  iTemp = (Int) (((dTemp) < 0)? (Int)((dTemp) - 0.5) : (Int)((dTemp) + 0.5));
    32742755
    32752756  return (UInt) ( (iTemp*iTemp)>>1 );
     
    32892770
    32902771  UInt uiSum = 0;
    3291   UInt uiShift = g_uiBitIncrement<<1;
     2772  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    32922773
    32932774  Int dDM;
     
    33192800
    33202801  UInt uiSum = 0;
    3321   UInt uiShift = g_uiBitIncrement<<1;
     2802  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    33222803
    33232804  Int dDM;
     
    33492830
    33502831  UInt uiSum = 0;
    3351   UInt uiShift = g_uiBitIncrement<<1;
     2832  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    33522833
    33532834  Int dDM;
     
    33792860
    33802861  UInt uiSum = 0;
    3381   UInt uiShift = g_uiBitIncrement<<1;
     2862  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    33822863
    33832864  Int dDM;
     
    34102891
    34112892  UInt uiSum = 0;
    3412   UInt uiShift = g_uiBitIncrement<<1;
     2893  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    34132894
    34142895  Int dDM;
     
    34432924
    34442925  UInt uiSum = 0;
    3445   UInt uiShift = g_uiBitIncrement<<1;
     2926  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    34462927
    34472928  Int dDM;
     
    34732954
    34742955  UInt uiSum = 0;
    3475   UInt uiShift = g_uiBitIncrement<<1;
     2956  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
    34762957
    34772958  Int dDM;
     
    39813462  }
    39823463 
    3983   return ( uiSum >> g_uiBitIncrement );
     3464  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    39843465}
    39853466
     
    40173498  }
    40183499 
    4019   return ( uiSum >> g_uiBitIncrement );
     3500  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    40203501}
    40213502
     
    40263507    return xGetHADsw( pcDtParam );
    40273508  }
    4028 #if LGE_ILLUCOMP_B0045
    4029   if(pcDtParam->bUseIC)
     3509#if H_3D_IC
     3510  if( pcDtParam->bUseIC )
     3511  {
     3512    return xGetHADsic( pcDtParam );
     3513  }
     3514#endif
     3515#if LGE_INTER_SDC_E0156
     3516  if( pcDtParam->bUseSDCMRSAD )
    40303517  {
    40313518    return xGetHADsic( pcDtParam );
     
    40393526  Int  iStrideOrg = pcDtParam->iStrideOrg;
    40403527  Int  iStep  = pcDtParam->iStep;
    4041 
     3528 
    40423529  Int  x, y;
    4043 
     3530 
    40443531  UInt uiSum = 0;
    4045 
     3532 
    40463533#if NS_HAD
    40473534  if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) )
     
    40963583    Int  iOffsetOrg = iStrideOrg<<2;
    40973584    Int  iOffsetCur = iStrideCur<<2;
    4098 
     3585   
    40993586    for ( y=0; y<iRows; y+= 4 )
    41003587    {
     
    41253612    assert(false);
    41263613  }
    4127 
    4128   return ( uiSum >> g_uiBitIncrement );
    4129 }
    4130 
    4131 #if LGE_ILLUCOMP_B0045
     3614 
     3615  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     3616}
     3617
     3618#if H_3D_IC || LGE_INTER_SDC_E0156
    41323619UInt TComRdCost::xGetHADsic( DistParam* pcDtParam )
    41333620{
     
    41433630  Int  iStrideOrg = pcDtParam->iStrideOrg;
    41443631  Int  iStep  = pcDtParam->iStep;
    4145  
     3632
    41463633  Int  x, y;
    4147  
     3634
    41483635  UInt uiSum = 0;
    4149  
     3636
    41503637  Int  iOrigAvg = 0, iCurAvg = 0;
    41513638  Int  iDeltaC;
     
    42303717    Int  iOffsetOrg = iStrideOrg<<2;
    42313718    Int  iOffsetCur = iStrideCur<<2;
    4232    
     3719
    42333720    for ( y=0; y<iRows; y+= 4 )
    42343721    {
     
    42593746    assert(false);
    42603747  }
    4261  
     3748
    42623749  piOrg   = pcDtParam->pOrg;
    42633750
     
    42713758  }
    42723759
    4273   return ( uiSum >> g_uiBitIncrement );
    4274 }
    4275 #endif
    4276 
    4277 #if HHI_VSO
     3760  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
     3761}
     3762#endif
     3763
     3764#if H_3D_VSO
    42783765Void TComRdCost::setLambdaVSO( Double dLambdaVSO )
    42793766{
     
    42873774{
    42883775  AOT(bSAD);
    4289 #ifdef LGE_VSO_EARLY_SKIP_A0093
     3776#if H_3D_VSO_EARLY_SKIP
    42903777  RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur, piOrg, iOrgStride); 
    42913778#else
     
    42943781
    42953782  RMDist iDistMin = (RMDist) RDO_DIST_MIN;
    4296 #if HHI_VSO_DIST_INT
    42973783  iDistMin = m_bAllowNegDist ? RDO_DIST_MIN : 0;
    4298 #endif
    4299  
    4300   iDist = Min( iDist, (RMDist) RDO_DIST_MAX);
    4301   iDist = Max( iDist, iDistMin);
     3784 
     3785  iDist = std::min( iDist, (RMDist) RDO_DIST_MAX);
     3786  iDist = std::max( iDist, iDistMin);
    43023787  return (Dist) iDist;
    43033788}
    43043789
    43053790
    4306 Dist TComRdCost::getDistVS( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD, UInt uiPlane )
     3791Dist TComRdCost::getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHAD )
    43073792{
    43083793  assert( m_bUseVSO ); 
     
    43133798 
    43143799  pcCU->getPosInPic( uiAbsPartIndex, iPosX, iPosY );
    4315   return (this->*m_fpDistortFuncVSO) ( iPosX, iPosY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight, bSAD ); 
     3800   
     3801  Dist dist = (this->*m_fpDistortFuncVSO) ( iPosX, iPosY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight, bHAD ); 
     3802 
     3803  if ( m_bUseWVSO )   
     3804  {
     3805    Int iDWeight   = m_iDWeight   * m_iDWeight;
     3806    Int iVSOWeight = m_iVSOWeight * m_iVSOWeight;
     3807    Dist distDepth;
     3808   
     3809    if ( !bHAD )
     3810    {
     3811       distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
     3812    }
     3813    else
     3814    {
     3815       distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
     3816    }
     3817   
     3818    dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight);
     3819  }
     3820  return dist;
    43163821};
    43173822
     
    43613866  {
    43623867    // Intra8x8, Intra4x4 Block only...
     3868#if SEQUENCE_LEVEL_LOSSLESS
     3869    dRdCost = (Double)(uiBits);
     3870#else
    43633871    dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda));
     3872#endif
    43643873  }
    43653874  else
     
    43723881    else
    43733882    {
     3883#if SEQUENCE_LEVEL_LOSSLESS
     3884      dRdCost = (Double)(uiBits);
     3885#else
    43743886      dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)));
    43753887      dRdCost = (Double)(Dist)floor(dRdCost);
     3888#endif
    43763889    }
    43773890  }
     
    43913904}
    43923905
    4393 #if HHI_VSO_DIST_INT
    43943906Void TComRdCost::setAllowNegDist( Bool bAllowNegDist )
    43953907{
     
    43983910#endif
    43993911
    4400 #endif
    44013912//! \}
Note: See TracChangeset for help on using the changeset viewer.