Ignore:
Timestamp:
12 Nov 2014, 08:09:17 (10 years ago)
Author:
seregin
Message:

initial porting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-upgrade/source/Lib/TLibCommon/TComRdCost.cpp

    r595 r916  
    5151TComRdCost::~TComRdCost()
    5252{
    53 #if !FIX203
    54   xUninit();
    55 #endif
    5653}
    5754
    5855// Calculate RD functions
    59 Double TComRdCost::calcRdCost( UInt uiBits, UInt uiDistortion, Bool bFlag, DFunc eDFunc )
     56Double TComRdCost::calcRdCost( UInt uiBits, Distortion uiDistortion, Bool bFlag, DFunc eDFunc )
    6057{
    6158  Double dRdCost = 0.0;
     
    6865      break;
    6966    case DF_SAD:
    70       dLambda = (Double)m_uiLambdaMotionSAD;
     67#if RExt__HIGH_BIT_DEPTH_SUPPORT
     68      dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
     69#else
     70      dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
     71#endif
    7172      break;
    7273    case DF_DEFAULT:
     
    8182  }
    8283
    83   if (bFlag)
     84  if (bFlag) //NOTE: this "bFlag" is never true
    8485  {
    8586    // Intra8x8, Intra4x4 Block only...
    86 #if SEQUENCE_LEVEL_LOSSLESS
    87     dRdCost = (Double)(uiBits);
    88 #else
    89     dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda));
    90 #endif
     87    if (m_costMode != COST_STANDARD_LOSSY)
     88    {
     89      dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     90    }
     91    else
     92    {
     93      dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda));
     94    }
    9195  }
    9296  else
     
    9498    if (eDFunc == DF_SAD)
    9599    {
    96       dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16));
    97       dRdCost = (Double)(UInt)floor(dRdCost);
     100      if (m_costMode != COST_STANDARD_LOSSY)
     101      {
     102        dRdCost = ((Double(uiDistortion) * 65536) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     103      }
     104      else
     105      {
     106        dRdCost = floor(Double(uiDistortion) + (floor((Double(uiBits) * dLambda) + 0.5) / 65536.0));
     107      }
    98108    }
    99109    else
    100110    {
    101 #if SEQUENCE_LEVEL_LOSSLESS
    102       dRdCost = (Double)(uiBits);
    103 #else
    104       dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)));
    105       dRdCost = (Double)(UInt)floor(dRdCost);
    106 #endif
     111      if (m_costMode != COST_STANDARD_LOSSY)
     112      {
     113        dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     114      }
     115      else
     116      {
     117        dRdCost = floor(Double(uiDistortion) + (Double(uiBits) * dLambda) + 0.5);
     118      }
    107119    }
    108120  }
     
    122134      break;
    123135    case DF_SAD:
    124       dLambda = (Double)m_uiLambdaMotionSAD;
     136#if RExt__HIGH_BIT_DEPTH_SUPPORT
     137      dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
     138#else
     139      dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
     140#endif
    125141      break;
    126142    case DF_DEFAULT:
     
    135151  }
    136152
    137   if (bFlag)
     153  if (bFlag) //NOTE: this "bFlag" is never true
    138154  {
    139155    // Intra8x8, Intra4x4 Block only...
    140 #if SEQUENCE_LEVEL_LOSSLESS
    141     dRdCost = (Double)(uiBits);
    142 #else
    143     dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda));
    144 #endif
     156    if (m_costMode != COST_STANDARD_LOSSY)
     157    {
     158      dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     159    }
     160    else
     161    {
     162      dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda));
     163    }
    145164  }
    146165  else
     
    148167    if (eDFunc == DF_SAD)
    149168    {
    150       dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5)>>16));
    151       dRdCost = (Double)(UInt)floor(dRdCost);
     169      if (m_costMode != COST_STANDARD_LOSSY)
     170      {
     171        dRdCost = ((Double(uiDistortion) * 65536) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     172      }
     173      else
     174      {
     175        dRdCost = floor(Double(uiDistortion) + (floor((Double(uiBits) * dLambda) + 0.5) / 65536.0));
     176      }
    152177    }
    153178    else
    154179    {
    155 #if SEQUENCE_LEVEL_LOSSLESS
    156       dRdCost = (Double)(uiBits);
    157 #else
    158       dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5)));
    159       dRdCost = (Double)(UInt)floor(dRdCost);
    160 #endif
     180      if (m_costMode != COST_STANDARD_LOSSY)
     181      {
     182        dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     183      }
     184      else
     185      {
     186        dRdCost = floor(Double(uiDistortion) + (Double(uiBits) * dLambda) + 0.5);
     187      }
    161188    }
    162189  }
     
    169196  m_dLambda           = dLambda;
    170197  m_sqrtLambda        = sqrt(m_dLambda);
    171   m_uiLambdaMotionSAD = (UInt)floor(65536.0 * m_sqrtLambda);
    172   m_uiLambdaMotionSSE = (UInt)floor(65536.0 * m_dLambda   );
     198#if RExt__HIGH_BIT_DEPTH_SUPPORT
     199  m_dLambdaMotionSAD[0] = 65536.0 * m_sqrtLambda;
     200  m_dLambdaMotionSSE[0] = 65536.0 * m_dLambda;
     201#if FULL_NBIT
     202  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0));
     203#else
     204  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (g_bitDepth[CHANNEL_TYPE_LUMA] - 8)) / 3.0));
     205#endif
     206  m_dLambdaMotionSAD[1] = 65536.0 * sqrt(dLambda);
     207  m_dLambdaMotionSSE[1] = 65536.0 * dLambda;
     208#else
     209  m_uiLambdaMotionSAD[0] = (UInt)floor(65536.0 * m_sqrtLambda);
     210  m_uiLambdaMotionSSE[0] = (UInt)floor(65536.0 * m_dLambda   );
     211#if FULL_NBIT
     212  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0));
     213#else
     214  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (g_bitDepth[CHANNEL_TYPE_LUMA] - 8)) / 3.0));
     215#endif
     216  m_uiLambdaMotionSAD[1] = (UInt)floor(65536.0 * sqrt(dLambda));
     217  m_uiLambdaMotionSSE[1] = (UInt)floor(65536.0 * dLambda   );
     218#endif
    173219}
    174220
     
    177223Void TComRdCost::init()
    178224{
    179   m_afpDistortFunc[0] = NULL;                  // for DF_DEFAULT
    180 
    181   m_afpDistortFunc[1] = TComRdCost::xGetSSE;
    182   m_afpDistortFunc[2] = TComRdCost::xGetSSE4;
    183   m_afpDistortFunc[3] = TComRdCost::xGetSSE8;
    184   m_afpDistortFunc[4] = TComRdCost::xGetSSE16;
    185   m_afpDistortFunc[5] = TComRdCost::xGetSSE32;
    186   m_afpDistortFunc[6] = TComRdCost::xGetSSE64;
    187   m_afpDistortFunc[7] = TComRdCost::xGetSSE16N;
    188 
    189   m_afpDistortFunc[8] = TComRdCost::xGetSAD;
    190   m_afpDistortFunc[9] = TComRdCost::xGetSAD4;
    191   m_afpDistortFunc[10] = TComRdCost::xGetSAD8;
    192   m_afpDistortFunc[11] = TComRdCost::xGetSAD16;
    193   m_afpDistortFunc[12] = TComRdCost::xGetSAD32;
    194   m_afpDistortFunc[13] = TComRdCost::xGetSAD64;
    195   m_afpDistortFunc[14] = TComRdCost::xGetSAD16N;
    196 
    197   m_afpDistortFunc[15] = TComRdCost::xGetSAD;
    198   m_afpDistortFunc[16] = TComRdCost::xGetSAD4;
    199   m_afpDistortFunc[17] = TComRdCost::xGetSAD8;
    200   m_afpDistortFunc[18] = TComRdCost::xGetSAD16;
    201   m_afpDistortFunc[19] = TComRdCost::xGetSAD32;
    202   m_afpDistortFunc[20] = TComRdCost::xGetSAD64;
    203   m_afpDistortFunc[21] = TComRdCost::xGetSAD16N;
     225  m_afpDistortFunc[DF_DEFAULT] = NULL;                  // for DF_DEFAULT
     226
     227  m_afpDistortFunc[DF_SSE    ] = TComRdCost::xGetSSE;
     228  m_afpDistortFunc[DF_SSE4   ] = TComRdCost::xGetSSE4;
     229  m_afpDistortFunc[DF_SSE8   ] = TComRdCost::xGetSSE8;
     230  m_afpDistortFunc[DF_SSE16  ] = TComRdCost::xGetSSE16;
     231  m_afpDistortFunc[DF_SSE32  ] = TComRdCost::xGetSSE32;
     232  m_afpDistortFunc[DF_SSE64  ] = TComRdCost::xGetSSE64;
     233  m_afpDistortFunc[DF_SSE16N ] = TComRdCost::xGetSSE16N;
     234
     235  m_afpDistortFunc[DF_SAD    ] = TComRdCost::xGetSAD;
     236  m_afpDistortFunc[DF_SAD4   ] = TComRdCost::xGetSAD4;
     237  m_afpDistortFunc[DF_SAD8   ] = TComRdCost::xGetSAD8;
     238  m_afpDistortFunc[DF_SAD16  ] = TComRdCost::xGetSAD16;
     239  m_afpDistortFunc[DF_SAD32  ] = TComRdCost::xGetSAD32;
     240  m_afpDistortFunc[DF_SAD64  ] = TComRdCost::xGetSAD64;
     241  m_afpDistortFunc[DF_SAD16N ] = TComRdCost::xGetSAD16N;
     242
     243  m_afpDistortFunc[DF_SADS   ] = TComRdCost::xGetSAD;
     244  m_afpDistortFunc[DF_SADS4  ] = TComRdCost::xGetSAD4;
     245  m_afpDistortFunc[DF_SADS8  ] = TComRdCost::xGetSAD8;
     246  m_afpDistortFunc[DF_SADS16 ] = TComRdCost::xGetSAD16;
     247  m_afpDistortFunc[DF_SADS32 ] = TComRdCost::xGetSAD32;
     248  m_afpDistortFunc[DF_SADS64 ] = TComRdCost::xGetSAD64;
     249  m_afpDistortFunc[DF_SADS16N] = TComRdCost::xGetSAD16N;
    204250
    205251#if AMP_SAD
    206   m_afpDistortFunc[43] = TComRdCost::xGetSAD12;
    207   m_afpDistortFunc[44] = TComRdCost::xGetSAD24;
    208   m_afpDistortFunc[45] = TComRdCost::xGetSAD48;
    209 
    210   m_afpDistortFunc[46] = TComRdCost::xGetSAD12;
    211   m_afpDistortFunc[47] = TComRdCost::xGetSAD24;
    212   m_afpDistortFunc[48] = TComRdCost::xGetSAD48;
     252  m_afpDistortFunc[DF_SAD12  ] = TComRdCost::xGetSAD12;
     253  m_afpDistortFunc[DF_SAD24  ] = TComRdCost::xGetSAD24;
     254  m_afpDistortFunc[DF_SAD48  ] = TComRdCost::xGetSAD48;
     255
     256  m_afpDistortFunc[DF_SADS12 ] = TComRdCost::xGetSAD12;
     257  m_afpDistortFunc[DF_SADS24 ] = TComRdCost::xGetSAD24;
     258  m_afpDistortFunc[DF_SADS48 ] = TComRdCost::xGetSAD48;
    213259#endif
    214   m_afpDistortFunc[22] = TComRdCost::xGetHADs;
    215   m_afpDistortFunc[23] = TComRdCost::xGetHADs;
    216   m_afpDistortFunc[24] = TComRdCost::xGetHADs;
    217   m_afpDistortFunc[25] = TComRdCost::xGetHADs;
    218   m_afpDistortFunc[26] = TComRdCost::xGetHADs;
    219   m_afpDistortFunc[27] = TComRdCost::xGetHADs;
    220   m_afpDistortFunc[28] = TComRdCost::xGetHADs;
    221 
    222 #if !FIX203
    223   m_puiComponentCostOriginP = NULL;
    224   m_puiComponentCost        = NULL;
    225   m_puiVerCost              = NULL;
    226   m_puiHorCost              = NULL;
     260  m_afpDistortFunc[DF_HADS   ] = TComRdCost::xGetHADs;
     261  m_afpDistortFunc[DF_HADS4  ] = TComRdCost::xGetHADs;
     262  m_afpDistortFunc[DF_HADS8  ] = TComRdCost::xGetHADs;
     263  m_afpDistortFunc[DF_HADS16 ] = TComRdCost::xGetHADs;
     264  m_afpDistortFunc[DF_HADS32 ] = TComRdCost::xGetHADs;
     265  m_afpDistortFunc[DF_HADS64 ] = TComRdCost::xGetHADs;
     266  m_afpDistortFunc[DF_HADS16N] = TComRdCost::xGetHADs;
     267
     268  m_costMode                   = COST_STANDARD_LOSSY;
     269
     270#if RExt__HIGH_BIT_DEPTH_SUPPORT
     271  m_dCost                      = 0;
     272#else
     273  m_uiCost                     = 0;
    227274#endif
    228   m_uiCost                  = 0;
    229   m_iCostScale              = 0;
    230 #if !FIX203
    231   m_iSearchLimit            = 0xdeaddead;
    232 #endif
    233 }
    234 
    235 #if !FIX203
    236 Void TComRdCost::initRateDistortionModel( Int iSubPelSearchLimit )
    237 {
    238   // make it larger
    239   iSubPelSearchLimit += 4;
    240   iSubPelSearchLimit *= 8;
    241 
    242   if( m_iSearchLimit != iSubPelSearchLimit )
    243   {
    244     xUninit();
    245 
    246     m_iSearchLimit = iSubPelSearchLimit;
    247 
    248     m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ];
    249     iSubPelSearchLimit *= 2;
    250 
    251     m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit;
    252 
    253     for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++)
    254     {
    255       m_puiComponentCost[n] = xGetComponentBits( n );
    256     }
    257   }
    258 }
    259 
    260 Void TComRdCost::xUninit()
    261 {
    262   if( NULL != m_puiComponentCostOriginP )
    263   {
    264     delete [] m_puiComponentCostOriginP;
    265     m_puiComponentCostOriginP = NULL;
    266   }
    267 }
    268 #endif
     275  m_iCostScale                 = 0;
     276}
    269277
    270278UInt TComRdCost::xGetComponentBits( Int iVal )
     
    313321  if (rcDistParam.iCols == 12)
    314322  {
    315     rcDistParam.DistFunc = m_afpDistortFunc[43 ];
     323    rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD12];
    316324  }
    317325  else if (rcDistParam.iCols == 24)
    318326  {
    319     rcDistParam.DistFunc = m_afpDistortFunc[44 ];
     327    rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD24];
    320328  }
    321329  else if (rcDistParam.iCols == 48)
    322330  {
    323     rcDistParam.DistFunc = m_afpDistortFunc[45 ];
     331    rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD48];
    324332  }
    325333#endif
     
    334342#if O0194_WEIGHTED_PREDICTION_CGS
    335343  // Bug fix: The correct bit depth has not been used for weighted cost calculation
    336   rcDistParam.bitDepth = g_bitDepthY;
     344  rcDistParam.bitDepth = g_bitDepth[CHANNEL_TYPE_LUMA];
    337345#endif
    338346  // set Original & Curr Pointer / Stride
     
    357365    if (rcDistParam.iCols == 12)
    358366    {
    359       rcDistParam.DistFunc = m_afpDistortFunc[46 ];
     367      rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS12];
    360368    }
    361369    else if (rcDistParam.iCols == 24)
    362370    {
    363       rcDistParam.DistFunc = m_afpDistortFunc[47 ];
     371      rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS24];
    364372    }
    365373    else if (rcDistParam.iCols == 48)
    366374    {
    367       rcDistParam.DistFunc = m_afpDistortFunc[48 ];
     375      rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS48];
    368376    }
    369377#endif
     
    378386}
    379387
    380 Void
    381 TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard )
     388Void TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard )
    382389{
    383390  rcDP.pOrg       = p1;
     
    393400}
    394401
    395 UInt TComRdCost::calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight )
    396 {
    397   UInt uiSum = 0;
     402Distortion TComRdCost::calcHAD( Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight )
     403{
     404  Distortion uiSum = 0;
    398405  Int x, y;
    399406
     
    412419  else
    413420  {
    414     assert(iWidth % 4 == 0 && iHeight % 4 == 0);
    415    
     421    assert ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) );
     422
    416423    for ( y=0; y<iHeight; y+= 4 )
    417424    {
     
    425432  }
    426433
    427   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8);
    428 
    429 }
    430 
    431 UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText, DFunc eDFunc)
     434  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8) );
     435}
     436
     437Distortion TComRdCost::getDistPart( Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc )
    432438{
    433439  DistParam cDtParam;
     
    440446
    441447  cDtParam.bApplyWeight = false;
    442   cDtParam.uiComp       = 255;    // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed.
    443   cDtParam.bitDepth = bitDepth;
    444 
    445   if (eText == TEXT_CHROMA_U)
    446   {
    447    return ((Int) (m_cbDistortionWeight * cDtParam.DistFunc( &cDtParam )));
    448   }
    449   else if (eText == TEXT_CHROMA_V)
    450   {
    451    return ((Int) (m_crDistortionWeight * cDtParam.DistFunc( &cDtParam )));
     448  cDtParam.compIdx      = MAX_NUM_COMPONENT; // just for assert: to be sure it was set before use
     449  cDtParam.bitDepth     = bitDepth;
     450
     451  if (isChroma(compID))
     452  {
     453    return ((Distortion) (m_distortionWeight[compID] * cDtParam.DistFunc( &cDtParam )));
    452454  }
    453455  else
     
    465467// --------------------------------------------------------------------------------------------------------------------
    466468
    467 UInt TComRdCost::xGetSAD( DistParam* pcDtParam )
     469Distortion TComRdCost::xGetSAD( DistParam* pcDtParam )
    468470{
    469471  if ( pcDtParam->bApplyWeight )
    470472  {
    471     return xGetSADw( pcDtParam );
    472   }
    473   Pel* piOrg   = pcDtParam->pOrg;
    474   Pel* piCur   = pcDtParam->pCur;
     473    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     474  }
     475  const Pel* piOrg   = pcDtParam->pOrg;
     476  const Pel* piCur   = pcDtParam->pCur;
    475477  Int  iRows   = pcDtParam->iRows;
    476478  Int  iCols   = pcDtParam->iCols;
     
    478480  Int  iStrideOrg = pcDtParam->iStrideOrg;
    479481
    480   UInt uiSum = 0;
     482  Distortion uiSum = 0;
    481483
    482484  for( ; iRows != 0; iRows-- )
     
    490492  }
    491493
    492   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    493 }
    494 
    495 UInt TComRdCost::xGetSAD4( DistParam* pcDtParam )
     494  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     495}
     496
     497Distortion TComRdCost::xGetSAD4( DistParam* pcDtParam )
    496498{
    497499  if ( pcDtParam->bApplyWeight )
    498500  {
    499     return xGetSADw( pcDtParam );
    500   }
    501   Pel* piOrg   = pcDtParam->pOrg;
    502   Pel* piCur   = pcDtParam->pCur;
     501    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     502  }
     503  const Pel* piOrg   = pcDtParam->pOrg;
     504  const Pel* piCur   = pcDtParam->pCur;
    503505  Int  iRows   = pcDtParam->iRows;
    504506  Int  iSubShift  = pcDtParam->iSubShift;
     
    507509  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    508510
    509   UInt uiSum = 0;
     511  Distortion uiSum = 0;
    510512
    511513  for( ; iRows != 0; iRows-=iSubStep )
     
    521523
    522524  uiSum <<= iSubShift;
    523   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    524 }
    525 
    526 UInt TComRdCost::xGetSAD8( DistParam* pcDtParam )
     525  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     526}
     527
     528Distortion TComRdCost::xGetSAD8( DistParam* pcDtParam )
    527529{
    528530  if ( pcDtParam->bApplyWeight )
    529531  {
    530     return xGetSADw( pcDtParam );
    531   }
    532   Pel* piOrg      = pcDtParam->pOrg;
    533   Pel* piCur      = pcDtParam->pCur;
     532    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     533  }
     534  const Pel* piOrg      = pcDtParam->pOrg;
     535  const Pel* piCur      = pcDtParam->pCur;
    534536  Int  iRows      = pcDtParam->iRows;
    535537  Int  iSubShift  = pcDtParam->iSubShift;
     
    538540  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    539541
    540   UInt uiSum = 0;
     542  Distortion uiSum = 0;
    541543
    542544  for( ; iRows != 0; iRows-=iSubStep )
     
    556558
    557559  uiSum <<= iSubShift;
    558   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    559 }
    560 
    561 UInt TComRdCost::xGetSAD16( DistParam* pcDtParam )
     560  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     561}
     562
     563Distortion TComRdCost::xGetSAD16( DistParam* pcDtParam )
    562564{
    563565  if ( pcDtParam->bApplyWeight )
    564566  {
    565     return xGetSADw( pcDtParam );
    566   }
    567   Pel* piOrg   = pcDtParam->pOrg;
    568   Pel* piCur   = pcDtParam->pCur;
     567    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     568  }
     569  const Pel* piOrg   = pcDtParam->pOrg;
     570  const Pel* piCur   = pcDtParam->pCur;
    569571  Int  iRows   = pcDtParam->iRows;
    570572  Int  iSubShift  = pcDtParam->iSubShift;
     
    573575  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    574576
    575   UInt uiSum = 0;
     577  Distortion uiSum = 0;
    576578
    577579  for( ; iRows != 0; iRows-=iSubStep )
     
    599601
    600602  uiSum <<= iSubShift;
    601   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     603  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
    602604}
    603605
    604606#if AMP_SAD
    605 UInt TComRdCost::xGetSAD12( DistParam* pcDtParam )
     607Distortion TComRdCost::xGetSAD12( DistParam* pcDtParam )
    606608{
    607609  if ( pcDtParam->bApplyWeight )
    608610  {
    609     return xGetSADw( pcDtParam );
    610   }
    611   Pel* piOrg   = pcDtParam->pOrg;
    612   Pel* piCur   = pcDtParam->pCur;
     611    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     612  }
     613  const Pel* piOrg   = pcDtParam->pOrg;
     614  const Pel* piCur   = pcDtParam->pCur;
    613615  Int  iRows   = pcDtParam->iRows;
    614616  Int  iSubShift  = pcDtParam->iSubShift;
     
    617619  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    618620
    619   UInt uiSum = 0;
     621  Distortion uiSum = 0;
    620622
    621623  for( ; iRows != 0; iRows-=iSubStep )
     
    639641
    640642  uiSum <<= iSubShift;
    641   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     643  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
    642644}
    643645#endif
    644646
    645 UInt TComRdCost::xGetSAD16N( DistParam* pcDtParam )
    646 {
    647   Pel* piOrg   = pcDtParam->pOrg;
    648   Pel* piCur   = pcDtParam->pCur;
     647Distortion TComRdCost::xGetSAD16N( DistParam* pcDtParam )
     648{
     649  const Pel* piOrg   = pcDtParam->pOrg;
     650  const Pel* piCur   = pcDtParam->pCur;
    649651  Int  iRows   = pcDtParam->iRows;
    650652  Int  iCols   = pcDtParam->iCols;
     
    654656  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    655657
    656   UInt uiSum = 0;
     658  Distortion uiSum = 0;
    657659
    658660  for( ; iRows != 0; iRows-=iSubStep )
     
    682684
    683685  uiSum <<= iSubShift;
    684   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    685 }
    686 
    687 UInt TComRdCost::xGetSAD32( DistParam* pcDtParam )
     686  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     687}
     688
     689Distortion TComRdCost::xGetSAD32( DistParam* pcDtParam )
    688690{
    689691  if ( pcDtParam->bApplyWeight )
    690692  {
    691     return xGetSADw( pcDtParam );
    692   }
    693   Pel* piOrg   = pcDtParam->pOrg;
    694   Pel* piCur   = pcDtParam->pCur;
     693    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     694  }
     695  const Pel* piOrg   = pcDtParam->pOrg;
     696  const Pel* piCur   = pcDtParam->pCur;
    695697  Int  iRows   = pcDtParam->iRows;
    696698  Int  iSubShift  = pcDtParam->iSubShift;
     
    699701  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    700702
    701   UInt uiSum = 0;
     703  Distortion uiSum = 0;
    702704
    703705  for( ; iRows != 0; iRows-=iSubStep )
     
    741743
    742744  uiSum <<= iSubShift;
    743   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     745  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
    744746}
    745747
    746748#if AMP_SAD
    747 UInt TComRdCost::xGetSAD24( DistParam* pcDtParam )
     749Distortion TComRdCost::xGetSAD24( DistParam* pcDtParam )
    748750{
    749751  if ( pcDtParam->bApplyWeight )
    750752  {
    751     return xGetSADw( pcDtParam );
    752   }
    753   Pel* piOrg   = pcDtParam->pOrg;
    754   Pel* piCur   = pcDtParam->pCur;
     753    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     754  }
     755  const Pel* piOrg   = pcDtParam->pOrg;
     756  const Pel* piCur   = pcDtParam->pCur;
    755757  Int  iRows   = pcDtParam->iRows;
    756758  Int  iSubShift  = pcDtParam->iSubShift;
     
    759761  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    760762
    761   UInt uiSum = 0;
     763  Distortion uiSum = 0;
    762764
    763765  for( ; iRows != 0; iRows-=iSubStep )
     
    793795
    794796  uiSum <<= iSubShift;
    795   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     797  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
    796798}
    797799
    798800#endif
    799801
    800 UInt TComRdCost::xGetSAD64( DistParam* pcDtParam )
     802Distortion TComRdCost::xGetSAD64( DistParam* pcDtParam )
    801803{
    802804  if ( pcDtParam->bApplyWeight )
    803805  {
    804     return xGetSADw( pcDtParam );
    805   }
    806   Pel* piOrg   = pcDtParam->pOrg;
    807   Pel* piCur   = pcDtParam->pCur;
     806    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     807  }
     808  const Pel* piOrg   = pcDtParam->pOrg;
     809  const Pel* piCur   = pcDtParam->pCur;
    808810  Int  iRows   = pcDtParam->iRows;
    809811  Int  iSubShift  = pcDtParam->iSubShift;
     
    812814  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    813815
    814   UInt uiSum = 0;
     816  Distortion uiSum = 0;
    815817
    816818  for( ; iRows != 0; iRows-=iSubStep )
     
    886888
    887889  uiSum <<= iSubShift;
    888   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     890  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
    889891}
    890892
    891893#if AMP_SAD
    892 UInt TComRdCost::xGetSAD48( DistParam* pcDtParam )
     894Distortion TComRdCost::xGetSAD48( DistParam* pcDtParam )
    893895{
    894896  if ( pcDtParam->bApplyWeight )
    895897  {
    896     return xGetSADw( pcDtParam );
    897   }
    898   Pel* piOrg   = pcDtParam->pOrg;
    899   Pel* piCur   = pcDtParam->pCur;
     898    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     899  }
     900  const Pel* piOrg   = pcDtParam->pOrg;
     901  const Pel* piCur   = pcDtParam->pCur;
    900902  Int  iRows   = pcDtParam->iRows;
    901903  Int  iSubShift  = pcDtParam->iSubShift;
     
    904906  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    905907
    906   UInt uiSum = 0;
     908  Distortion uiSum = 0;
    907909
    908910  for( ; iRows != 0; iRows-=iSubStep )
     
    962964
    963965  uiSum <<= iSubShift;
    964   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     966  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
    965967}
    966968#endif
     
    970972// --------------------------------------------------------------------------------------------------------------------
    971973
    972 UInt TComRdCost::xGetSSE( DistParam* pcDtParam )
     974Distortion TComRdCost::xGetSSE( DistParam* pcDtParam )
    973975{
    974976  if ( pcDtParam->bApplyWeight )
    975977  {
    976     return xGetSSEw( pcDtParam );
    977   }
    978   Pel* piOrg   = pcDtParam->pOrg;
    979   Pel* piCur   = pcDtParam->pCur;
     978    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     979  }
     980  const Pel* piOrg   = pcDtParam->pOrg;
     981  const Pel* piCur   = pcDtParam->pCur;
    980982  Int  iRows   = pcDtParam->iRows;
    981983  Int  iCols   = pcDtParam->iCols;
     
    983985  Int  iStrideCur = pcDtParam->iStrideCur;
    984986
    985   UInt uiSum = 0;
    986   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    987 
    988   Int iTemp;
     987  Distortion uiSum  = 0;
     988  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     989
     990  Intermediate_Int iTemp;
    989991
    990992  for( ; iRows != 0; iRows-- )
     
    993995    {
    994996      iTemp = piOrg[n  ] - piCur[n  ];
    995       uiSum += ( iTemp * iTemp ) >> uiShift;
     997      uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
    996998    }
    997999    piOrg += iStrideOrg;
     
    10021004}
    10031005
    1004 UInt TComRdCost::xGetSSE4( DistParam* pcDtParam )
     1006Distortion TComRdCost::xGetSSE4( DistParam* pcDtParam )
    10051007{
    10061008  if ( pcDtParam->bApplyWeight )
    10071009  {
    10081010    assert( pcDtParam->iCols == 4 );
    1009     return xGetSSEw( pcDtParam );
    1010   }
    1011   Pel* piOrg   = pcDtParam->pOrg;
    1012   Pel* piCur   = pcDtParam->pCur;
     1011    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     1012  }
     1013  const Pel* piOrg   = pcDtParam->pOrg;
     1014  const Pel* piCur   = pcDtParam->pCur;
    10131015  Int  iRows   = pcDtParam->iRows;
    10141016  Int  iStrideOrg = pcDtParam->iStrideOrg;
    10151017  Int  iStrideCur = pcDtParam->iStrideCur;
    10161018
    1017   UInt uiSum = 0;
    1018   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    1019 
    1020   Int  iTemp;
     1019  Distortion uiSum  = 0;
     1020  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     1021
     1022  Intermediate_Int  iTemp;
    10211023
    10221024  for( ; iRows != 0; iRows-- )
    10231025  {
    10241026
    1025     iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1026     iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1027     iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1028     iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift;
     1027    iTemp = piOrg[0] - piCur[0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1028    iTemp = piOrg[1] - piCur[1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1029    iTemp = piOrg[2] - piCur[2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1030    iTemp = piOrg[3] - piCur[3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
    10291031
    10301032    piOrg += iStrideOrg;
     
    10351037}
    10361038
    1037 UInt TComRdCost::xGetSSE8( DistParam* pcDtParam )
     1039Distortion TComRdCost::xGetSSE8( DistParam* pcDtParam )
    10381040{
    10391041  if ( pcDtParam->bApplyWeight )
    10401042  {
    10411043    assert( pcDtParam->iCols == 8 );
    1042     return xGetSSEw( pcDtParam );
    1043   }
    1044   Pel* piOrg   = pcDtParam->pOrg;
    1045   Pel* piCur   = pcDtParam->pCur;
     1044    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     1045  }
     1046  const Pel* piOrg   = pcDtParam->pOrg;
     1047  const Pel* piCur   = pcDtParam->pCur;
    10461048  Int  iRows   = pcDtParam->iRows;
    10471049  Int  iStrideOrg = pcDtParam->iStrideOrg;
    10481050  Int  iStrideCur = pcDtParam->iStrideCur;
    10491051
    1050   UInt uiSum = 0;
    1051   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    1052 
    1053   Int  iTemp;
     1052  Distortion uiSum  = 0;
     1053  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     1054
     1055  Intermediate_Int  iTemp;
    10541056
    10551057  for( ; iRows != 0; iRows-- )
    10561058  {
    1057     iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1058     iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1059     iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1060     iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1061     iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1062     iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1063     iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1064     iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift;
     1059    iTemp = piOrg[0] - piCur[0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1060    iTemp = piOrg[1] - piCur[1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1061    iTemp = piOrg[2] - piCur[2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1062    iTemp = piOrg[3] - piCur[3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1063    iTemp = piOrg[4] - piCur[4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1064    iTemp = piOrg[5] - piCur[5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1065    iTemp = piOrg[6] - piCur[6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1066    iTemp = piOrg[7] - piCur[7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
    10651067
    10661068    piOrg += iStrideOrg;
     
    10711073}
    10721074
    1073 UInt TComRdCost::xGetSSE16( DistParam* pcDtParam )
     1075Distortion TComRdCost::xGetSSE16( DistParam* pcDtParam )
    10741076{
    10751077  if ( pcDtParam->bApplyWeight )
    10761078  {
    10771079    assert( pcDtParam->iCols == 16 );
    1078     return xGetSSEw( pcDtParam );
    1079   }
    1080   Pel* piOrg   = pcDtParam->pOrg;
    1081   Pel* piCur   = pcDtParam->pCur;
     1080    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     1081  }
     1082  const Pel* piOrg   = pcDtParam->pOrg;
     1083  const Pel* piCur   = pcDtParam->pCur;
    10821084  Int  iRows   = pcDtParam->iRows;
    10831085  Int  iStrideOrg = pcDtParam->iStrideOrg;
    10841086  Int  iStrideCur = pcDtParam->iStrideCur;
    10851087
    1086   UInt uiSum = 0;
    1087   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    1088 
    1089   Int  iTemp;
     1088  Distortion uiSum  = 0;
     1089  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     1090
     1091  Intermediate_Int  iTemp;
    10901092
    10911093  for( ; iRows != 0; iRows-- )
    10921094  {
    10931095
    1094     iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1095     iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1096     iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1097     iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1098     iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1099     iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1100     iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1101     iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1102     iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1103     iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1104     iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1105     iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1106     iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1107     iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1108     iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1109     iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift;
     1096    iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1097    iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1098    iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1099    iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1100    iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1101    iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1102    iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1103    iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1104    iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1105    iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1106    iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1107    iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1108    iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1109    iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1110    iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1111    iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
    11101112
    11111113    piOrg += iStrideOrg;
     
    11161118}
    11171119
    1118 UInt TComRdCost::xGetSSE16N( DistParam* pcDtParam )
     1120Distortion TComRdCost::xGetSSE16N( DistParam* pcDtParam )
    11191121{
    11201122  if ( pcDtParam->bApplyWeight )
    11211123  {
    1122     return xGetSSEw( pcDtParam );
    1123   }
    1124   Pel* piOrg   = pcDtParam->pOrg;
    1125   Pel* piCur   = pcDtParam->pCur;
     1124    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     1125  }
     1126  const Pel* piOrg   = pcDtParam->pOrg;
     1127  const Pel* piCur   = pcDtParam->pCur;
    11261128  Int  iRows   = pcDtParam->iRows;
    11271129  Int  iCols   = pcDtParam->iCols;
     
    11291131  Int  iStrideCur = pcDtParam->iStrideCur;
    11301132
    1131   UInt uiSum = 0;
    1132   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    1133   Int  iTemp;
     1133  Distortion uiSum   = 0;
     1134  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     1135
     1136  Intermediate_Int  iTemp;
    11341137
    11351138  for( ; iRows != 0; iRows-- )
     
    11381141    {
    11391142
    1140       iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1141       iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1142       iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1143       iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1144       iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1145       iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1146       iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1147       iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1148       iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1149       iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1150       iTemp = piOrg[n+10] - piCur[n+10]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1151       iTemp = piOrg[n+11] - piCur[n+11]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1152       iTemp = piOrg[n+12] - piCur[n+12]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1153       iTemp = piOrg[n+13] - piCur[n+13]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1154       iTemp = piOrg[n+14] - piCur[n+14]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1155       iTemp = piOrg[n+15] - piCur[n+15]; uiSum += ( iTemp * iTemp ) >> uiShift;
     1143      iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1144      iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1145      iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1146      iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1147      iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1148      iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1149      iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1150      iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1151      iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1152      iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1153      iTemp = piOrg[n+10] - piCur[n+10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1154      iTemp = piOrg[n+11] - piCur[n+11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1155      iTemp = piOrg[n+12] - piCur[n+12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1156      iTemp = piOrg[n+13] - piCur[n+13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1157      iTemp = piOrg[n+14] - piCur[n+14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1158      iTemp = piOrg[n+15] - piCur[n+15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
    11561159
    11571160    }
     
    11631166}
    11641167
    1165 UInt TComRdCost::xGetSSE32( DistParam* pcDtParam )
     1168Distortion TComRdCost::xGetSSE32( DistParam* pcDtParam )
    11661169{
    11671170  if ( pcDtParam->bApplyWeight )
    11681171  {
    11691172    assert( pcDtParam->iCols == 32 );
    1170     return xGetSSEw( pcDtParam );
    1171   }
    1172   Pel* piOrg   = pcDtParam->pOrg;
    1173   Pel* piCur   = pcDtParam->pCur;
     1173    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     1174  }
     1175  const Pel* piOrg   = pcDtParam->pOrg;
     1176  const Pel* piCur   = pcDtParam->pCur;
    11741177  Int  iRows   = pcDtParam->iRows;
    11751178  Int  iStrideOrg = pcDtParam->iStrideOrg;
    11761179  Int  iStrideCur = pcDtParam->iStrideCur;
    11771180
    1178   UInt uiSum = 0;
    1179   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    1180   Int  iTemp;
     1181  Distortion uiSum   = 0;
     1182  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     1183
     1184  Intermediate_Int  iTemp;
    11811185
    11821186  for( ; iRows != 0; iRows-- )
    11831187  {
    11841188
    1185     iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1186     iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1187     iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1188     iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1189     iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1190     iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1191     iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1192     iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1193     iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1194     iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1195     iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1196     iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1197     iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1198     iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1199     iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1200     iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1201     iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1202     iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1203     iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1204     iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1205     iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1206     iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1207     iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1208     iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1209     iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1210     iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1211     iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1212     iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1213     iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1214     iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1215     iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1216     iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift;
     1189    iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1190    iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1191    iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1192    iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1193    iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1194    iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1195    iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1196    iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1197    iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1198    iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1199    iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1200    iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1201    iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1202    iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1203    iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1204    iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1205    iTemp = piOrg[16] - piCur[16]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1206    iTemp = piOrg[17] - piCur[17]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1207    iTemp = piOrg[18] - piCur[18]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1208    iTemp = piOrg[19] - piCur[19]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1209    iTemp = piOrg[20] - piCur[20]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1210    iTemp = piOrg[21] - piCur[21]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1211    iTemp = piOrg[22] - piCur[22]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1212    iTemp = piOrg[23] - piCur[23]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1213    iTemp = piOrg[24] - piCur[24]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1214    iTemp = piOrg[25] - piCur[25]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1215    iTemp = piOrg[26] - piCur[26]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1216    iTemp = piOrg[27] - piCur[27]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1217    iTemp = piOrg[28] - piCur[28]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1218    iTemp = piOrg[29] - piCur[29]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1219    iTemp = piOrg[30] - piCur[30]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1220    iTemp = piOrg[31] - piCur[31]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
    12171221
    12181222    piOrg += iStrideOrg;
     
    12231227}
    12241228
    1225 UInt TComRdCost::xGetSSE64( DistParam* pcDtParam )
     1229Distortion TComRdCost::xGetSSE64( DistParam* pcDtParam )
    12261230{
    12271231  if ( pcDtParam->bApplyWeight )
    12281232  {
    12291233    assert( pcDtParam->iCols == 64 );
    1230     return xGetSSEw( pcDtParam );
    1231   }
    1232   Pel* piOrg   = pcDtParam->pOrg;
    1233   Pel* piCur   = pcDtParam->pCur;
     1234    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     1235  }
     1236  const Pel* piOrg   = pcDtParam->pOrg;
     1237  const Pel* piCur   = pcDtParam->pCur;
    12341238  Int  iRows   = pcDtParam->iRows;
    12351239  Int  iStrideOrg = pcDtParam->iStrideOrg;
    12361240  Int  iStrideCur = pcDtParam->iStrideCur;
    12371241
    1238   UInt uiSum = 0;
    1239   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    1240   Int  iTemp;
     1242  Distortion uiSum   = 0;
     1243  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     1244
     1245  Intermediate_Int  iTemp;
    12411246
    12421247  for( ; iRows != 0; iRows-- )
    12431248  {
    1244     iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1245     iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1246     iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1247     iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1248     iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1249     iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1250     iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1251     iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1252     iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1253     iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1254     iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1255     iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1256     iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1257     iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1258     iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1259     iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1260     iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1261     iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1262     iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1263     iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1264     iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1265     iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1266     iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1267     iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1268     iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1269     iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1270     iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1271     iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1272     iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1273     iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1274     iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1275     iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1276     iTemp = piOrg[32] - piCur[32]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1277     iTemp = piOrg[33] - piCur[33]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1278     iTemp = piOrg[34] - piCur[34]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1279     iTemp = piOrg[35] - piCur[35]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1280     iTemp = piOrg[36] - piCur[36]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1281     iTemp = piOrg[37] - piCur[37]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1282     iTemp = piOrg[38] - piCur[38]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1283     iTemp = piOrg[39] - piCur[39]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1284     iTemp = piOrg[40] - piCur[40]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1285     iTemp = piOrg[41] - piCur[41]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1286     iTemp = piOrg[42] - piCur[42]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1287     iTemp = piOrg[43] - piCur[43]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1288     iTemp = piOrg[44] - piCur[44]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1289     iTemp = piOrg[45] - piCur[45]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1290     iTemp = piOrg[46] - piCur[46]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1291     iTemp = piOrg[47] - piCur[47]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1292     iTemp = piOrg[48] - piCur[48]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1293     iTemp = piOrg[49] - piCur[49]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1294     iTemp = piOrg[50] - piCur[50]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1295     iTemp = piOrg[51] - piCur[51]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1296     iTemp = piOrg[52] - piCur[52]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1297     iTemp = piOrg[53] - piCur[53]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1298     iTemp = piOrg[54] - piCur[54]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1299     iTemp = piOrg[55] - piCur[55]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1300     iTemp = piOrg[56] - piCur[56]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1301     iTemp = piOrg[57] - piCur[57]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1302     iTemp = piOrg[58] - piCur[58]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1303     iTemp = piOrg[59] - piCur[59]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1304     iTemp = piOrg[60] - piCur[60]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1305     iTemp = piOrg[61] - piCur[61]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1306     iTemp = piOrg[62] - piCur[62]; uiSum += ( iTemp * iTemp ) >> uiShift;
    1307     iTemp = piOrg[63] - piCur[63]; uiSum += ( iTemp * iTemp ) >> uiShift;
     1249    iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1250    iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1251    iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1252    iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1253    iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1254    iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1255    iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1256    iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1257    iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1258    iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1259    iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1260    iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1261    iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1262    iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1263    iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1264    iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1265    iTemp = piOrg[16] - piCur[16]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1266    iTemp = piOrg[17] - piCur[17]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1267    iTemp = piOrg[18] - piCur[18]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1268    iTemp = piOrg[19] - piCur[19]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1269    iTemp = piOrg[20] - piCur[20]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1270    iTemp = piOrg[21] - piCur[21]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1271    iTemp = piOrg[22] - piCur[22]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1272    iTemp = piOrg[23] - piCur[23]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1273    iTemp = piOrg[24] - piCur[24]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1274    iTemp = piOrg[25] - piCur[25]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1275    iTemp = piOrg[26] - piCur[26]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1276    iTemp = piOrg[27] - piCur[27]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1277    iTemp = piOrg[28] - piCur[28]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1278    iTemp = piOrg[29] - piCur[29]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1279    iTemp = piOrg[30] - piCur[30]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1280    iTemp = piOrg[31] - piCur[31]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1281    iTemp = piOrg[32] - piCur[32]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1282    iTemp = piOrg[33] - piCur[33]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1283    iTemp = piOrg[34] - piCur[34]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1284    iTemp = piOrg[35] - piCur[35]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1285    iTemp = piOrg[36] - piCur[36]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1286    iTemp = piOrg[37] - piCur[37]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1287    iTemp = piOrg[38] - piCur[38]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1288    iTemp = piOrg[39] - piCur[39]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1289    iTemp = piOrg[40] - piCur[40]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1290    iTemp = piOrg[41] - piCur[41]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1291    iTemp = piOrg[42] - piCur[42]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1292    iTemp = piOrg[43] - piCur[43]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1293    iTemp = piOrg[44] - piCur[44]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1294    iTemp = piOrg[45] - piCur[45]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1295    iTemp = piOrg[46] - piCur[46]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1296    iTemp = piOrg[47] - piCur[47]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1297    iTemp = piOrg[48] - piCur[48]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1298    iTemp = piOrg[49] - piCur[49]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1299    iTemp = piOrg[50] - piCur[50]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1300    iTemp = piOrg[51] - piCur[51]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1301    iTemp = piOrg[52] - piCur[52]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1302    iTemp = piOrg[53] - piCur[53]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1303    iTemp = piOrg[54] - piCur[54]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1304    iTemp = piOrg[55] - piCur[55]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1305    iTemp = piOrg[56] - piCur[56]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1306    iTemp = piOrg[57] - piCur[57]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1307    iTemp = piOrg[58] - piCur[58]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1308    iTemp = piOrg[59] - piCur[59]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1309    iTemp = piOrg[60] - piCur[60]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1310    iTemp = piOrg[61] - piCur[61]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1311    iTemp = piOrg[62] - piCur[62]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     1312    iTemp = piOrg[63] - piCur[63]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
    13081313
    13091314    piOrg += iStrideOrg;
     
    13181323// --------------------------------------------------------------------------------------------------------------------
    13191324
    1320 UInt TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    1321 {
    1322   Int satd = 0, diff[4], m[4];
     1325Distortion TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     1326{
     1327  Distortion satd = 0;
     1328  TCoeff diff[4], m[4];
    13231329  assert( iStep == 1 );
    13241330  diff[0] = piOrg[0             ] - piCur[0];
     
    13391345}
    13401346
    1341 UInt TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    1342 {
    1343   Int k, satd = 0, diff[16], m[16], d[16];
     1347Distortion TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     1348{
     1349  Int k;
     1350  Distortion satd = 0;
     1351  TCoeff diff[16], m[16], d[16];
    13441352
    13451353  assert( iStep == 1 );
     
    14331441}
    14341442
    1435 UInt TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    1436 {
    1437   Int k, i, j, jj, sad=0;
    1438   Int diff[64], m1[8][8], m2[8][8], m3[8][8];
     1443Distortion TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     1444{
     1445  Int k, i, j, jj;
     1446  Distortion sad = 0;
     1447  TCoeff diff[64], m1[8][8], m2[8][8], m3[8][8];
    14391448  assert( iStep == 1 );
    14401449  for( k = 0; k < 64; k += 8 )
     
    15291538}
    15301539
    1531 UInt TComRdCost::xGetHADs4( DistParam* pcDtParam )
     1540
     1541Distortion TComRdCost::xGetHADs( DistParam* pcDtParam )
    15321542{
    15331543  if ( pcDtParam->bApplyWeight )
    15341544  {
    1535     return xGetHADs4w( pcDtParam );
    1536   }
    1537   Pel* piOrg   = pcDtParam->pOrg;
    1538   Pel* piCur   = pcDtParam->pCur;
    1539   Int  iRows   = pcDtParam->iRows;
    1540   Int  iStrideCur = pcDtParam->iStrideCur;
    1541   Int  iStrideOrg = pcDtParam->iStrideOrg;
    1542   Int  iStep  = pcDtParam->iStep;
    1543   Int  y;
    1544   Int  iOffsetOrg = iStrideOrg<<2;
    1545   Int  iOffsetCur = iStrideCur<<2;
    1546 
    1547   UInt uiSum = 0;
    1548 
    1549   for ( y=0; y<iRows; y+= 4 )
    1550   {
    1551     uiSum += xCalcHADs4x4( piOrg, piCur, iStrideOrg, iStrideCur, iStep );
    1552     piOrg += iOffsetOrg;
    1553     piCur += iOffsetCur;
    1554   }
    1555 
    1556   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    1557 }
    1558 
    1559 UInt TComRdCost::xGetHADs8( DistParam* pcDtParam )
    1560 {
    1561   if ( pcDtParam->bApplyWeight )
    1562   {
    1563     return xGetHADs8w( pcDtParam );
    1564   }
    1565   Pel* piOrg   = pcDtParam->pOrg;
    1566   Pel* piCur   = pcDtParam->pCur;
    1567   Int  iRows   = pcDtParam->iRows;
    1568   Int  iStrideCur = pcDtParam->iStrideCur;
    1569   Int  iStrideOrg = pcDtParam->iStrideOrg;
    1570   Int  iStep  = pcDtParam->iStep;
    1571   Int  y;
    1572 
    1573   UInt uiSum = 0;
    1574 
    1575   if ( iRows == 4 )
    1576   {
    1577     uiSum += xCalcHADs4x4( piOrg+0, piCur        , iStrideOrg, iStrideCur, iStep );
    1578     uiSum += xCalcHADs4x4( piOrg+4, piCur+4*iStep, iStrideOrg, iStrideCur, iStep );
    1579   }
    1580   else
    1581   {
    1582     Int  iOffsetOrg = iStrideOrg<<3;
    1583     Int  iOffsetCur = iStrideCur<<3;
    1584     for ( y=0; y<iRows; y+= 8 )
    1585     {
    1586       uiSum += xCalcHADs8x8( piOrg, piCur, iStrideOrg, iStrideCur, iStep );
    1587       piOrg += iOffsetOrg;
    1588       piCur += iOffsetCur;
    1589     }
    1590   }
    1591 
    1592   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    1593 }
    1594 
    1595 UInt TComRdCost::xGetHADs( DistParam* pcDtParam )
    1596 {
    1597   if ( pcDtParam->bApplyWeight )
    1598   {
    1599     return xGetHADsw( pcDtParam );
     1545    return TComRdCostWeightPrediction::xGetHADsw( pcDtParam );
    16001546  }
    16011547  Pel* piOrg   = pcDtParam->pOrg;
     
    16091555  Int  x, y;
    16101556
    1611   UInt uiSum = 0;
     1557  Distortion uiSum = 0;
    16121558
    16131559  if( ( iRows % 8 == 0) && (iCols % 8 == 0) )
     
    16591605  }
    16601606
    1661   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
     1607  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
    16621608}
    16631609
Note: See TracChangeset for help on using the changeset viewer.