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


Ignore:
Timestamp:
13 Aug 2015, 17:38:13 (9 years ago)
Author:
tech
Message:

Merged 14.1-update-dev1@1312.

File:
1 edited

Legend:

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

    r1196 r1313  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3838#include <math.h>
    3939#include <assert.h>
     40#include <limits>
    4041#include "TComRom.h"
    4142#include "TComRdCost.h"
    42 #if H_3D
     43#if NH_3D
    4344#include "TComDataCU.h"
     45#include "TComRectangle.h"
    4446#endif
    4547
     
    4749//! \{
    4850
    49 #if H_3D_VSO
     51#if NH_3D_VSO
    5052// SAIT_VSO_EST_A0033
    5153Double TComRdCost::m_dDisparityCoeff = 1.0;
     
    5860TComRdCost::~TComRdCost()
    5961{
    60 #if !FIX203
    61   xUninit();
    62 #endif
    6362}
    6463
    6564// Calculate RD functions
    66 #if H_3D_VSO
     65#if NH_3D_VSO
    6766Double TComRdCost::calcRdCost( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc )
    6867#else
    69 Double TComRdCost::calcRdCost( UInt uiBits, UInt uiDistortion, Bool bFlag, DFunc eDFunc )
     68Double TComRdCost::calcRdCost( UInt uiBits, Distortion uiDistortion, Bool bFlag, DFunc eDFunc )
    7069#endif
    7170{
    7271  Double dRdCost = 0.0;
    7372  Double dLambda = 0.0;
    74  
     73
    7574  switch ( eDFunc )
    7675  {
     
    7978      break;
    8079    case DF_SAD:
    81       dLambda = (Double)m_uiLambdaMotionSAD;
     80#if RExt__HIGH_BIT_DEPTH_SUPPORT
     81      dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
     82#else
     83      dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
     84#endif
    8285      break;
    8386    case DF_DEFAULT:
     
    9194      break;
    9295  }
    93  
    94   if (bFlag)
     96
     97  if (bFlag) //NOTE: this "bFlag" is never true
    9598  {
    9699    // Intra8x8, Intra4x4 Block only...
    97 #if SEQUENCE_LEVEL_LOSSLESS
    98     dRdCost = (Double)(uiBits);
    99 #else
    100     dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda));
    101 #endif
     100    if (m_costMode != COST_STANDARD_LOSSY)
     101    {
     102      dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     103    }
     104    else
     105    {
     106      dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda));
     107    }
    102108  }
    103109  else
     
    105111    if (eDFunc == DF_SAD)
    106112    {
    107       dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16));
    108       dRdCost = (Double)(UInt)floor(dRdCost);
     113      if (m_costMode != COST_STANDARD_LOSSY)
     114      {
     115        dRdCost = ((Double(uiDistortion) * 65536) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     116      }
     117      else
     118      {
     119        dRdCost = floor(Double(uiDistortion) + (floor((Double(uiBits) * dLambda) + 0.5) / 65536.0));
     120      }
    109121    }
    110122    else
    111123    {
    112 #if SEQUENCE_LEVEL_LOSSLESS
    113       dRdCost = (Double)(uiBits);
    114 #else
    115       dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)));
    116       dRdCost = (Double)(UInt)floor(dRdCost);
    117 #endif
    118     }
    119   }
    120  
     124      if (m_costMode != COST_STANDARD_LOSSY)
     125      {
     126        dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     127      }
     128      else
     129      {
     130        dRdCost = floor(Double(uiDistortion) + (Double(uiBits) * dLambda) + 0.5);
     131      }
     132    }
     133  }
     134
     135  D_PRINT_INDENT( g_traceRDCost,  "Dist: " + n2s(uiDistortion) + " Bits: " + n2s(uiBits) + " RD Cost: " + n2s(dRdCost));
    121136  return dRdCost;
    122137}
    123138
    124 #if H_3D_VSO
     139#if NH_3D_VSO
    125140Double TComRdCost::calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag, DFunc eDFunc )
    126141#else
     
    130145  Double dRdCost = 0.0;
    131146  Double dLambda = 0.0;
    132  
     147
    133148  switch ( eDFunc )
    134149  {
     
    137152      break;
    138153    case DF_SAD:
    139       dLambda = (Double)m_uiLambdaMotionSAD;
     154#if RExt__HIGH_BIT_DEPTH_SUPPORT
     155      dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
     156#else
     157      dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate.
     158#endif
    140159      break;
    141160    case DF_DEFAULT:
     
    149168      break;
    150169  }
    151  
    152   if (bFlag)
     170
     171  if (bFlag) //NOTE: this "bFlag" is never true
    153172  {
    154173    // Intra8x8, Intra4x4 Block only...
    155 #if SEQUENCE_LEVEL_LOSSLESS
    156     dRdCost = (Double)(uiBits);
    157 #else
    158     dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda));
    159 #endif
     174    if (m_costMode != COST_STANDARD_LOSSY)
     175    {
     176      dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     177    }
     178    else
     179    {
     180      dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda));
     181    }
    160182  }
    161183  else
     
    163185    if (eDFunc == DF_SAD)
    164186    {
    165       dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5)>>16));
    166       dRdCost = (Double)(UInt)floor(dRdCost);
     187      if (m_costMode != COST_STANDARD_LOSSY)
     188      {
     189        dRdCost = ((Double(uiDistortion) * 65536) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     190      }
     191      else
     192      {
     193        dRdCost = floor(Double(uiDistortion) + (floor((Double(uiBits) * dLambda) + 0.5) / 65536.0));
     194      }
    167195    }
    168196    else
    169197    {
    170 #if SEQUENCE_LEVEL_LOSSLESS
    171       dRdCost = (Double)(uiBits);
    172 #else
    173       dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5)));
    174       dRdCost = (Double)(UInt)floor(dRdCost);
    175 #endif
    176     }
    177   }
    178  
     198      if (m_costMode != COST_STANDARD_LOSSY)
     199      {
     200        dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.
     201      }
     202      else
     203      {
     204        dRdCost = floor(Double(uiDistortion) + (Double(uiBits) * dLambda) + 0.5);
     205      }
     206    }
     207  }
     208
    179209  return dRdCost;
    180210}
    181211
    182 Void TComRdCost::setLambda( Double dLambda )
     212Void TComRdCost::setLambda( Double dLambda, const BitDepths &bitDepths )
    183213{
    184214  m_dLambda           = dLambda;
    185215  m_sqrtLambda        = sqrt(m_dLambda);
    186   m_uiLambdaMotionSAD = (UInt)floor(65536.0 * m_sqrtLambda);
    187   m_uiLambdaMotionSSE = (UInt)floor(65536.0 * m_dLambda   );
     216#if RExt__HIGH_BIT_DEPTH_SUPPORT
     217  m_dLambdaMotionSAD[0] = 65536.0 * m_sqrtLambda;
     218  m_dLambdaMotionSSE[0] = 65536.0 * m_dLambda;
     219#if FULL_NBIT
     220  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0));
     221#else
     222  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (bitDepths.recon[CHANNEL_TYPE_LUMA] - 8)) / 3.0));
     223#endif
     224  m_dLambdaMotionSAD[1] = 65536.0 * sqrt(dLambda);
     225  m_dLambdaMotionSSE[1] = 65536.0 * dLambda;
     226#else
     227  m_uiLambdaMotionSAD[0] = (UInt)floor(65536.0 * m_sqrtLambda);
     228  m_uiLambdaMotionSSE[0] = (UInt)floor(65536.0 * m_dLambda   );
     229#if FULL_NBIT
     230  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0));
     231#else
     232  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (bitDepths.recon[CHANNEL_TYPE_LUMA] - 8)) / 3.0));
     233#endif
     234  m_uiLambdaMotionSAD[1] = (UInt)floor(65536.0 * sqrt(dLambda));
     235  m_uiLambdaMotionSSE[1] = (UInt)floor(65536.0 * dLambda   );
     236#endif
    188237}
    189238
     
    192241Void TComRdCost::init()
    193242{
    194   m_afpDistortFunc[0]  = NULL;                  // for DF_DEFAULT
    195  
    196   m_afpDistortFunc[1]  = TComRdCost::xGetSSE;
    197   m_afpDistortFunc[2]  = TComRdCost::xGetSSE4;
    198   m_afpDistortFunc[3]  = TComRdCost::xGetSSE8;
    199   m_afpDistortFunc[4]  = TComRdCost::xGetSSE16;
    200   m_afpDistortFunc[5]  = TComRdCost::xGetSSE32;
    201   m_afpDistortFunc[6]  = TComRdCost::xGetSSE64;
    202   m_afpDistortFunc[7]  = TComRdCost::xGetSSE16N;
    203  
    204   m_afpDistortFunc[8]  = TComRdCost::xGetSAD;
    205   m_afpDistortFunc[9]  = TComRdCost::xGetSAD4;
    206   m_afpDistortFunc[10] = TComRdCost::xGetSAD8;
    207   m_afpDistortFunc[11] = TComRdCost::xGetSAD16;
    208   m_afpDistortFunc[12] = TComRdCost::xGetSAD32;
    209   m_afpDistortFunc[13] = TComRdCost::xGetSAD64;
    210   m_afpDistortFunc[14] = TComRdCost::xGetSAD16N;
    211  
    212   m_afpDistortFunc[15] = TComRdCost::xGetSAD;
    213   m_afpDistortFunc[16] = TComRdCost::xGetSAD4;
    214   m_afpDistortFunc[17] = TComRdCost::xGetSAD8;
    215   m_afpDistortFunc[18] = TComRdCost::xGetSAD16;
    216   m_afpDistortFunc[19] = TComRdCost::xGetSAD32;
    217   m_afpDistortFunc[20] = TComRdCost::xGetSAD64;
    218   m_afpDistortFunc[21] = TComRdCost::xGetSAD16N;
    219  
    220 #if AMP_SAD
    221   m_afpDistortFunc[43] = TComRdCost::xGetSAD12;
    222   m_afpDistortFunc[44] = TComRdCost::xGetSAD24;
    223   m_afpDistortFunc[45] = TComRdCost::xGetSAD48;
    224 
    225   m_afpDistortFunc[46] = TComRdCost::xGetSAD12;
    226   m_afpDistortFunc[47] = TComRdCost::xGetSAD24;
    227   m_afpDistortFunc[48] = TComRdCost::xGetSAD48;
    228 #endif
    229   m_afpDistortFunc[22] = TComRdCost::xGetHADs;
    230   m_afpDistortFunc[23] = TComRdCost::xGetHADs;
    231   m_afpDistortFunc[24] = TComRdCost::xGetHADs;
    232   m_afpDistortFunc[25] = TComRdCost::xGetHADs;
    233   m_afpDistortFunc[26] = TComRdCost::xGetHADs;
    234   m_afpDistortFunc[27] = TComRdCost::xGetHADs;
    235   m_afpDistortFunc[28] = TComRdCost::xGetHADs;
    236 
    237 #if H_3D_VSO
     243  m_afpDistortFunc[DF_DEFAULT] = NULL;                  // for DF_DEFAULT
     244
     245  m_afpDistortFunc[DF_SSE    ] = TComRdCost::xGetSSE;
     246  m_afpDistortFunc[DF_SSE4   ] = TComRdCost::xGetSSE4;
     247  m_afpDistortFunc[DF_SSE8   ] = TComRdCost::xGetSSE8;
     248  m_afpDistortFunc[DF_SSE16  ] = TComRdCost::xGetSSE16;
     249  m_afpDistortFunc[DF_SSE32  ] = TComRdCost::xGetSSE32;
     250  m_afpDistortFunc[DF_SSE64  ] = TComRdCost::xGetSSE64;
     251  m_afpDistortFunc[DF_SSE16N ] = TComRdCost::xGetSSE16N;
     252
     253  m_afpDistortFunc[DF_SAD    ] = TComRdCost::xGetSAD;
     254  m_afpDistortFunc[DF_SAD4   ] = TComRdCost::xGetSAD4;
     255  m_afpDistortFunc[DF_SAD8   ] = TComRdCost::xGetSAD8;
     256  m_afpDistortFunc[DF_SAD16  ] = TComRdCost::xGetSAD16;
     257  m_afpDistortFunc[DF_SAD32  ] = TComRdCost::xGetSAD32;
     258  m_afpDistortFunc[DF_SAD64  ] = TComRdCost::xGetSAD64;
     259  m_afpDistortFunc[DF_SAD16N ] = TComRdCost::xGetSAD16N;
     260
     261  m_afpDistortFunc[DF_SADS   ] = TComRdCost::xGetSAD;
     262  m_afpDistortFunc[DF_SADS4  ] = TComRdCost::xGetSAD4;
     263  m_afpDistortFunc[DF_SADS8  ] = TComRdCost::xGetSAD8;
     264  m_afpDistortFunc[DF_SADS16 ] = TComRdCost::xGetSAD16;
     265  m_afpDistortFunc[DF_SADS32 ] = TComRdCost::xGetSAD32;
     266  m_afpDistortFunc[DF_SADS64 ] = TComRdCost::xGetSAD64;
     267  m_afpDistortFunc[DF_SADS16N] = TComRdCost::xGetSAD16N;
     268
     269  m_afpDistortFunc[DF_SAD12  ] = TComRdCost::xGetSAD12;
     270  m_afpDistortFunc[DF_SAD24  ] = TComRdCost::xGetSAD24;
     271  m_afpDistortFunc[DF_SAD48  ] = TComRdCost::xGetSAD48;
     272
     273  m_afpDistortFunc[DF_SADS12 ] = TComRdCost::xGetSAD12;
     274  m_afpDistortFunc[DF_SADS24 ] = TComRdCost::xGetSAD24;
     275  m_afpDistortFunc[DF_SADS48 ] = TComRdCost::xGetSAD48;
     276
     277  m_afpDistortFunc[DF_HADS   ] = TComRdCost::xGetHADs;
     278  m_afpDistortFunc[DF_HADS4  ] = TComRdCost::xGetHADs;
     279  m_afpDistortFunc[DF_HADS8  ] = TComRdCost::xGetHADs;
     280  m_afpDistortFunc[DF_HADS16 ] = TComRdCost::xGetHADs;
     281  m_afpDistortFunc[DF_HADS32 ] = TComRdCost::xGetHADs;
     282  m_afpDistortFunc[DF_HADS64 ] = TComRdCost::xGetHADs;
     283  m_afpDistortFunc[DF_HADS16N] = TComRdCost::xGetHADs;
     284
     285#if NH_3D_VSO
    238286  // SAIT_VSO_EST_A0033
    239287  m_afpDistortFunc[29]  = TComRdCost::xGetVSD;
     
    245293  m_afpDistortFunc[35]  = TComRdCost::xGetVSD16N;
    246294#endif
    247 #if !FIX203
    248   m_puiComponentCostOriginP = NULL;
    249   m_puiComponentCost        = NULL;
    250   m_puiVerCost              = NULL;
    251   m_puiHorCost              = NULL;
    252 #endif
    253   m_uiCost                  = 0;
    254   m_iCostScale              = 0;
    255 #if !FIX203
    256   m_iSearchLimit            = 0xdeaddead;
    257 #endif
    258 #if H_3D_VSO
     295
     296  m_costMode                   = COST_STANDARD_LOSSY;
     297
     298#if RExt__HIGH_BIT_DEPTH_SUPPORT
     299  m_dCost                      = 0;
     300#else
     301  m_uiCost                     = 0;
     302#endif
     303  m_iCostScale                 = 0;
     304
     305#if NH_3D_VSO
    259306  m_bUseVSO                 = false;
    260307  m_uiVSOMode               = 0;
     
    265312  m_bUseEstimatedVSD        = false;
    266313#endif
    267 #if H_3D_DBBP
     314#if NH_3D_DBBP
    268315  m_bUseMask                = false;
    269316#endif
    270 }
    271 
    272 #if !FIX203
    273 Void TComRdCost::initRateDistortionModel( Int iSubPelSearchLimit )
    274 {
    275   // make it larger
    276   iSubPelSearchLimit += 4;
    277   iSubPelSearchLimit *= 8;
    278  
    279   if( m_iSearchLimit != iSubPelSearchLimit )
    280   {
    281     xUninit();
    282    
    283     m_iSearchLimit = iSubPelSearchLimit;
    284    
    285     m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ];
    286     iSubPelSearchLimit *= 2;
    287    
    288     m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit;
    289    
    290     for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++)
    291     {
    292       m_puiComponentCost[n] = xGetComponentBits( n );
    293     }
    294   }
    295 }
    296 
    297 Void TComRdCost::xUninit()
    298 {
    299   if( NULL != m_puiComponentCostOriginP )
    300   {
    301     delete [] m_puiComponentCostOriginP;
    302     m_puiComponentCostOriginP = NULL;
    303   }
    304 }
    305 #endif
    306 
    307 UInt TComRdCost::xGetComponentBits( Int iVal )
    308 {
     317
     318}
     319
     320// Static member function
     321UInt TComRdCost::xGetExpGolombNumberOfBits( Int iVal )
     322{
     323  assert(iVal != std::numeric_limits<Int>::min());
    309324  UInt uiLength = 1;
    310   UInt uiTemp   = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1);
    311  
    312   assert ( uiTemp );
    313  
     325  UInt uiTemp   = ( iVal <= 0) ? (UInt(-iVal)<<1)+1: UInt(iVal<<1);
     326
    314327  while ( 1 != uiTemp )
    315328  {
     
    317330    uiLength += 2;
    318331  }
    319  
     332
    320333  return uiLength;
    321334}
     
    327340  rcDistParam.iRows    = uiBlkHeight;
    328341  rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
    329  
    330 #if H_3D_DBBP
     342
     343#if NH_3D_DBBP
    331344  if( m_bUseMask )
    332345  {
     
    363376  rcDistParam.pOrg = pcPatternKey->getROIY();
    364377  rcDistParam.pCur = piRefY;
    365  
     378
    366379  rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride();
    367380  rcDistParam.iStrideCur = iRefStride;
    368  
     381
    369382  // set Block Width / Height
    370383  rcDistParam.iCols    = pcPatternKey->getROIYWidth();
    371384  rcDistParam.iRows    = pcPatternKey->getROIYHeight();
    372385  rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
    373  
    374 #if AMP_SAD
     386
    375387  if (rcDistParam.iCols == 12)
    376388  {
    377     rcDistParam.DistFunc = m_afpDistortFunc[43 ];
     389    rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD12];
    378390  }
    379391  else if (rcDistParam.iCols == 24)
    380392  {
    381     rcDistParam.DistFunc = m_afpDistortFunc[44 ];
     393    rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD24];
    382394  }
    383395  else if (rcDistParam.iCols == 48)
    384396  {
    385     rcDistParam.DistFunc = m_afpDistortFunc[45 ];
    386   }
    387 #endif
    388  
    389 #if H_3D_DBBP
     397    rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD48];
     398  }
     399
     400#if NH_3D_DBBP
    390401  if( m_bUseMask )
    391402  {
     
    403414  rcDistParam.pOrg = pcPatternKey->getROIY();
    404415  rcDistParam.pCur = piRefY;
    405  
     416
    406417  rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride();
    407418  rcDistParam.iStrideCur = iRefStride * iStep;
    408  
     419
    409420  // set Step for interpolated buffer
    410421  rcDistParam.iStep = iStep;
    411  
     422
    412423  // set Block Width / Height
    413424  rcDistParam.iCols    = pcPatternKey->getROIYWidth();
    414425  rcDistParam.iRows    = pcPatternKey->getROIYHeight();
    415  
     426
    416427  // set distortion function
    417428  if ( !bHADME )
    418429  {
    419430    rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
    420 #if AMP_SAD
    421431    if (rcDistParam.iCols == 12)
    422432    {
    423       rcDistParam.DistFunc = m_afpDistortFunc[46 ];
     433      rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS12];
    424434    }
    425435    else if (rcDistParam.iCols == 24)
    426436    {
    427       rcDistParam.DistFunc = m_afpDistortFunc[47 ];
     437      rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS24];
    428438    }
    429439    else if (rcDistParam.iCols == 48)
    430440    {
    431       rcDistParam.DistFunc = m_afpDistortFunc[48 ];
    432     }
    433 #endif
     441      rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS48];
     442    }
    434443  }
    435444  else
     
    437446    rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
    438447  }
    439  
    440 #if H_3D_DBBP
     448
     449#if NH_3D_DBBP
    441450  if( m_bUseMask )
    442451  {
     
    448457}
    449458
    450 Void
    451 TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard )
     459Void TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard )
    452460{
    453461  rcDP.pOrg       = p1;
     
    461469  rcDP.bitDepth   = bitDepth;
    462470  rcDP.DistFunc   = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ];
    463 #if H_3D_DBBP
     471#if NH_3D_DBBP
    464472  if( m_bUseMask )
    465473  {
     
    469477}
    470478
    471 UInt TComRdCost::calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight )
    472 {
    473   UInt uiSum = 0;
     479Distortion TComRdCost::calcHAD( Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight )
     480{
     481  Distortion uiSum = 0;
    474482  Int x, y;
    475  
     483
    476484  if ( ( (iWidth % 8) == 0 ) && ( (iHeight % 8) == 0 ) )
    477485  {
     
    488496  else
    489497  {
    490     assert(iWidth % 4 == 0 && iHeight % 4 == 0);
    491    
     498    assert ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) );
     499
    492500    for ( y=0; y<iHeight; y+= 4 )
    493501    {
     
    500508    }
    501509  }
    502  
    503   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8);
    504 
    505 }
    506 
    507 #if H_3D_FAST_DEPTH_INTRA
    508 
    509 UInt TComRdCost::calcVAR (Pel* pi0, Int stride, Int width, Int height, Int cuDepth)
     510
     511  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8) );
     512}
     513
     514#if NH_3D_ENC_DEPTH
     515UInt TComRdCost::calcVAR (Pel* pi0, Int stride, Int width, Int height, Int cuDepth, UInt maxCuWidth)
    510516{
    511517  Int temp = 0;
     
    519525  }
    520526
    521   Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2;
     527  Int cuMaxLog2Size = g_aucConvertToBit[maxCuWidth]+2;
    522528 
    523529  if ( width == 4 )
     
    542548
    543549
    544 UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText, DFunc eDFunc)
     550Distortion TComRdCost::getDistPart( Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc )
    545551{
    546552  DistParam cDtParam;
     
    553559
    554560  cDtParam.bApplyWeight = false;
    555   cDtParam.uiComp       = 255;    // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed.
    556   cDtParam.bitDepth = bitDepth;
    557 
    558 #if H_3D_IC
     561  cDtParam.compIdx      = MAX_NUM_COMPONENT; // just for assert: to be sure it was set before use
     562  cDtParam.bitDepth     = bitDepth;
     563
     564#if NH_3D_IC
    559565  cDtParam.bUseIC       = false;
    560566#endif
    561 #if H_3D_INTER_SDC
     567#if NH_3D_SDC_INTER
    562568  cDtParam.bUseSDCMRSAD = false;
    563569#endif
    564   if (eText == TEXT_CHROMA_U)
    565   {
    566    return ((Int) (m_cbDistortionWeight * cDtParam.DistFunc( &cDtParam )));
    567   }
    568   else if (eText == TEXT_CHROMA_V)
    569   {
    570    return ((Int) (m_crDistortionWeight * cDtParam.DistFunc( &cDtParam )));
     570
     571  if (isChroma(compID))
     572  {
     573    return ((Distortion) (m_distortionWeight[compID] * cDtParam.DistFunc( &cDtParam )));
    571574  }
    572575  else
     
    575578  }
    576579}
    577 #if H_3D_VSO
     580#if NH_3D_VSO
    578581// SAIT_VSO_EST_A0033
    579 UInt TComRdCost::getDistPartVSD( TComDataCU* pcCU, UInt uiPartOffset, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight,  Bool bHAD, DFunc eDFunc )
     582UInt TComRdCost::getDistPartVSD( TComDataCU* pcCU, UInt uiPartOffset, Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight,  Bool bHAD, DFunc eDFunc )
    580583{
    581584  AOT( ( m_dDisparityCoeff <= 0 ) || ( m_dDisparityCoeff > 10 ) );
    582585
    583   Pel* piVirRec  = m_pcVideoRecPicYuv->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset);
    584   Pel* piVirOrg  = m_pcDepthPicYuv   ->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset);
    585   Int iVirStride = m_pcVideoRecPicYuv->getStride();   
     586  Pel* piVirRec  = m_pcVideoRecPicYuv->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr( ), pcCU->getZorderIdxInCtu()+uiPartOffset );
     587  Pel* piVirOrg  = m_pcDepthPicYuv   ->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr( ), pcCU->getZorderIdxInCtu()+uiPartOffset );
     588  Int iVirStride = m_pcVideoRecPicYuv->getStride( COMPONENT_Y );   
    586589
    587590  DistParam cDtParam;
     
    596599  cDtParam.iStep      = 1;
    597600
    598   cDtParam.bApplyWeight = false;
    599   cDtParam.uiComp       = 255;    // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed.
    600 
    601   cDtParam.bitDepth   = g_bitDepthY;
     601  cDtParam.bApplyWeight = false; 
     602
     603  cDtParam.bitDepth   = bitDepth;
     604
     605#if NH_3D_IC_FIX
     606  cDtParam.bUseIC       = false;
     607#endif
     608#if NH_3D_SDC_INTER
     609  cDtParam.bUseSDCMRSAD = false;
     610#endif
    602611
    603612  Dist dist = cDtParam.DistFunc( &cDtParam );
     
    611620    if ( !bHAD )
    612621    {
    613       distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
     622      distDepth = (Dist) getDistPart( bitDepth, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight, COMPONENT_Y);
    614623    }
    615624    else
    616625    {
    617       distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
     626      distDepth = (Dist) calcHAD( bitDepth, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
    618627    }
    619628
     
    647656// ====================================================================================================================
    648657
    649 #if H_3D_DBBP
     658#if NH_3D_DBBP
    650659// --------------------------------------------------------------------------------------------------------------------
    651660// Masked distortion functions
     
    688697 
    689698  AOF(!pcDtParam->bApplyWeight);
    690 #if H_3D_IC
     699#if NH_3D_IC
    691700  AOF(!pcDtParam->bUseIC);
    692701#endif
     
    756765// --------------------------------------------------------------------------------------------------------------------
    757766
    758 UInt TComRdCost::xGetSAD( DistParam* pcDtParam )
     767Distortion TComRdCost::xGetSAD( DistParam* pcDtParam )
    759768{
    760769  if ( pcDtParam->bApplyWeight )
    761770  {
    762     return xGetSADw( pcDtParam );
    763   }
    764 #if H_3D_IC
     771    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     772  }
     773#if NH_3D_IC
    765774  if( pcDtParam->bUseIC )
    766775  {
     
    768777  }
    769778#endif
    770 #if H_3D_INTER_SDC
     779#if NH_3D_SDC_INTER
    771780  if( pcDtParam->bUseSDCMRSAD )
    772781  {
     
    774783  }
    775784#endif
    776   Pel* piOrg   = pcDtParam->pOrg;
    777   Pel* piCur   = pcDtParam->pCur;
     785
     786  const Pel* piOrg   = pcDtParam->pOrg;
     787  const Pel* piCur   = pcDtParam->pCur;
    778788  Int  iRows   = pcDtParam->iRows;
    779789  Int  iCols   = pcDtParam->iCols;
    780790  Int  iStrideCur = pcDtParam->iStrideCur;
    781791  Int  iStrideOrg = pcDtParam->iStrideOrg;
    782  
    783   UInt uiSum = 0;
    784  
     792
     793  Distortion uiSum = 0;
     794
    785795  for( ; iRows != 0; iRows-- )
    786796  {
     
    792802    piCur += iStrideCur;
    793803  }
    794  
    795   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    796 }
    797 
    798 UInt TComRdCost::xGetSAD4( DistParam* pcDtParam )
    799 {
    800   if ( pcDtParam->bApplyWeight )
    801   {
    802     return xGetSADw( pcDtParam );
    803   }
    804 #if H_3D_IC
     804
     805  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     806}
     807
     808Distortion TComRdCost::xGetSAD4( DistParam* pcDtParam )
     809{
     810  if ( pcDtParam->bApplyWeight )
     811  {
     812    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     813  }
     814
     815#if NH_3D_IC
    805816  if( pcDtParam->bUseIC )
    806817  {
     
    808819  }
    809820#endif
    810 #if H_3D_INTER_SDC
     821#if NH_3D_SDC_INTER
    811822  if( pcDtParam->bUseSDCMRSAD )
    812823  {
     
    814825  }
    815826#endif
    816   Pel* piOrg   = pcDtParam->pOrg;
    817   Pel* piCur   = pcDtParam->pCur;
     827
     828  const Pel* piOrg   = pcDtParam->pOrg;
     829  const Pel* piCur   = pcDtParam->pCur;
    818830  Int  iRows   = pcDtParam->iRows;
    819831  Int  iSubShift  = pcDtParam->iSubShift;
     
    821833  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    822834  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    823  
    824   UInt uiSum = 0;
    825  
     835
     836  Distortion uiSum = 0;
     837
    826838  for( ; iRows != 0; iRows-=iSubStep )
    827839  {
     
    830842    uiSum += abs( piOrg[2] - piCur[2] );
    831843    uiSum += abs( piOrg[3] - piCur[3] );
    832    
    833     piOrg += iStrideOrg;
    834     piCur += iStrideCur;
    835   }
    836  
     844
     845    piOrg += iStrideOrg;
     846    piCur += iStrideCur;
     847  }
     848
    837849  uiSum <<= iSubShift;
    838   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    839 }
    840 
    841 UInt TComRdCost::xGetSAD8( DistParam* pcDtParam )
     850  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     851}
     852
     853Distortion TComRdCost::xGetSAD8( DistParam* pcDtParam )
    842854{
    843855  if ( pcDtParam->bApplyWeight )
    844856  {
    845     return xGetSADw( pcDtParam );
    846   }
    847 #if H_3D_IC
     857    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     858  }
     859
     860#if NH_3D_IC
    848861  if( pcDtParam->bUseIC )
    849862  {
     
    851864  }
    852865#endif
    853 #if H_3D_INTER_SDC
     866#if NH_3D_SDC_INTER
    854867  if( pcDtParam->bUseSDCMRSAD )
    855868  {
     
    857870  }
    858871#endif
    859   Pel* piOrg      = pcDtParam->pOrg;
    860   Pel* piCur      = pcDtParam->pCur;
     872
     873  const Pel* piOrg      = pcDtParam->pOrg;
     874  const Pel* piCur      = pcDtParam->pCur;
    861875  Int  iRows      = pcDtParam->iRows;
    862876  Int  iSubShift  = pcDtParam->iSubShift;
     
    864878  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    865879  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    866  
    867   UInt uiSum = 0;
    868  
     880
     881  Distortion uiSum = 0;
     882
    869883  for( ; iRows != 0; iRows-=iSubStep )
    870884  {
     
    877891    uiSum += abs( piOrg[6] - piCur[6] );
    878892    uiSum += abs( piOrg[7] - piCur[7] );
    879    
    880     piOrg += iStrideOrg;
    881     piCur += iStrideCur;
    882   }
    883  
     893
     894    piOrg += iStrideOrg;
     895    piCur += iStrideCur;
     896  }
     897
    884898  uiSum <<= iSubShift;
    885   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    886 }
    887 
    888 UInt TComRdCost::xGetSAD16( DistParam* pcDtParam )
     899  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     900}
     901
     902Distortion TComRdCost::xGetSAD16( DistParam* pcDtParam )
    889903{
    890904  if ( pcDtParam->bApplyWeight )
    891905  {
    892     return xGetSADw( pcDtParam );
    893   }
    894 #if H_3D_IC
     906    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     907  }
     908
     909#if NH_3D_IC
    895910  if( pcDtParam->bUseIC )
    896911  {
     
    898913  }
    899914#endif
    900 #if H_3D_INTER_SDC
     915#if NH_3D_SDC_INTER
    901916  if( pcDtParam->bUseSDCMRSAD )
    902917  {
     
    904919  }
    905920#endif
    906   Pel* piOrg   = pcDtParam->pOrg;
    907   Pel* piCur   = pcDtParam->pCur;
     921
     922  const Pel* piOrg   = pcDtParam->pOrg;
     923  const Pel* piCur   = pcDtParam->pCur;
    908924  Int  iRows   = pcDtParam->iRows;
    909925  Int  iSubShift  = pcDtParam->iSubShift;
     
    911927  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    912928  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    913  
    914   UInt uiSum = 0;
    915  
     929
     930  Distortion uiSum = 0;
     931
    916932  for( ; iRows != 0; iRows-=iSubStep )
    917933  {
     
    932948    uiSum += abs( piOrg[14] - piCur[14] );
    933949    uiSum += abs( piOrg[15] - piCur[15] );
    934    
    935     piOrg += iStrideOrg;
    936     piCur += iStrideCur;
    937   }
    938  
     950
     951    piOrg += iStrideOrg;
     952    piCur += iStrideCur;
     953  }
     954
    939955  uiSum <<= iSubShift;
    940   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    941 }
    942 
    943 #if AMP_SAD
    944 UInt TComRdCost::xGetSAD12( DistParam* pcDtParam )
     956  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     957}
     958
     959Distortion TComRdCost::xGetSAD12( DistParam* pcDtParam )
    945960{
    946961  if ( pcDtParam->bApplyWeight )
    947962  {
    948     return xGetSADw( pcDtParam );
    949   }
    950 #if H_3D_IC
     963    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     964  }
     965#if NH_3D_IC
    951966  if( pcDtParam->bUseIC )
    952967  {
     
    954969  }
    955970#endif
    956 #if H_3D_INTER_SDC
     971#if NH_3D_SDC_INTER
    957972  if( pcDtParam->bUseSDCMRSAD )
    958973  {
     
    960975  }
    961976#endif
    962   Pel* piOrg   = pcDtParam->pOrg;
    963   Pel* piCur   = pcDtParam->pCur;
     977
     978  const Pel* piOrg   = pcDtParam->pOrg;
     979  const Pel* piCur   = pcDtParam->pCur;
    964980  Int  iRows   = pcDtParam->iRows;
    965981  Int  iSubShift  = pcDtParam->iSubShift;
     
    967983  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    968984  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    969  
    970   UInt uiSum = 0;
    971  
     985
     986  Distortion uiSum = 0;
     987
    972988  for( ; iRows != 0; iRows-=iSubStep )
    973989  {
     
    9841000    uiSum += abs( piOrg[10] - piCur[10] );
    9851001    uiSum += abs( piOrg[11] - piCur[11] );
    986    
    987     piOrg += iStrideOrg;
    988     piCur += iStrideCur;
    989   }
    990  
     1002
     1003    piOrg += iStrideOrg;
     1004    piCur += iStrideCur;
     1005  }
     1006
    9911007  uiSum <<= iSubShift;
    992   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    993 }
    994 #endif
    995 
    996 UInt TComRdCost::xGetSAD16N( DistParam* pcDtParam )
    997 {
    998 #if H_3D_IC
     1008  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     1009}
     1010
     1011Distortion TComRdCost::xGetSAD16N( DistParam* pcDtParam )
     1012{
     1013#if NH_3D_IC
    9991014  if( pcDtParam->bUseIC )
    10001015  {
     
    10021017  }
    10031018#endif
    1004 #if H_3D_INTER_SDC
     1019#if NH_3D_SDC_INTER
    10051020  if( pcDtParam->bUseSDCMRSAD )
    10061021  {
     
    10081023  }
    10091024#endif
    1010   Pel* piOrg   = pcDtParam->pOrg;
    1011   Pel* piCur   = pcDtParam->pCur;
     1025
     1026  const Pel* piOrg   = pcDtParam->pOrg;
     1027  const Pel* piCur   = pcDtParam->pCur;
    10121028  Int  iRows   = pcDtParam->iRows;
    10131029  Int  iCols   = pcDtParam->iCols;
     
    10161032  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    10171033  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1018  
    1019   UInt uiSum = 0;
    1020  
     1034
     1035  Distortion uiSum = 0;
     1036
    10211037  for( ; iRows != 0; iRows-=iSubStep )
    10221038  {
     
    10431059    piCur += iStrideCur;
    10441060  }
    1045  
     1061
    10461062  uiSum <<= iSubShift;
    1047   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    1048 }
    1049 
    1050 UInt TComRdCost::xGetSAD32( DistParam* pcDtParam )
     1063  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     1064}
     1065
     1066Distortion TComRdCost::xGetSAD32( DistParam* pcDtParam )
    10511067{
    10521068  if ( pcDtParam->bApplyWeight )
    10531069  {
    1054     return xGetSADw( pcDtParam );
    1055   }
    1056 #if H_3D_IC
     1070    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     1071  }
     1072
     1073#if NH_3D_IC
    10571074  if( pcDtParam->bUseIC )
    10581075  {
     
    10601077  }
    10611078#endif
    1062 #if H_3D_INTER_SDC
     1079#if NH_3D_SDC_INTER
    10631080  if( pcDtParam->bUseSDCMRSAD )
    10641081  {
     
    10661083  }
    10671084#endif
    1068   Pel* piOrg   = pcDtParam->pOrg;
    1069   Pel* piCur   = pcDtParam->pCur;
     1085
     1086  const Pel* piOrg   = pcDtParam->pOrg;
     1087  const Pel* piCur   = pcDtParam->pCur;
    10701088  Int  iRows   = pcDtParam->iRows;
    10711089  Int  iSubShift  = pcDtParam->iSubShift;
     
    10731091  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    10741092  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1075  
    1076   UInt uiSum = 0;
    1077  
     1093
     1094  Distortion uiSum = 0;
     1095
    10781096  for( ; iRows != 0; iRows-=iSubStep )
    10791097  {
     
    11101128    uiSum += abs( piOrg[30] - piCur[30] );
    11111129    uiSum += abs( piOrg[31] - piCur[31] );
    1112    
    1113     piOrg += iStrideOrg;
    1114     piCur += iStrideCur;
    1115   }
    1116  
     1130
     1131    piOrg += iStrideOrg;
     1132    piCur += iStrideCur;
     1133  }
     1134
    11171135  uiSum <<= iSubShift;
    1118   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    1119 }
    1120 
    1121 #if AMP_SAD
    1122 UInt TComRdCost::xGetSAD24( DistParam* pcDtParam )
     1136  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     1137}
     1138
     1139Distortion TComRdCost::xGetSAD24( DistParam* pcDtParam )
    11231140{
    11241141  if ( pcDtParam->bApplyWeight )
    11251142  {
    1126     return xGetSADw( pcDtParam );
    1127   }
    1128 #if H_3D_IC
     1143    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     1144  }
     1145
     1146#if NH_3D_IC
    11291147  if( pcDtParam->bUseIC )
    11301148  {
     
    11321150  }
    11331151#endif
    1134 #if H_3D_INTER_SDC
     1152#if NH_3D_SDC_INTER
    11351153  if( pcDtParam->bUseSDCMRSAD )
    11361154  {
     
    11381156  }
    11391157#endif
    1140   Pel* piOrg   = pcDtParam->pOrg;
    1141   Pel* piCur   = pcDtParam->pCur;
     1158
     1159  const Pel* piOrg   = pcDtParam->pOrg;
     1160  const Pel* piCur   = pcDtParam->pCur;
    11421161  Int  iRows   = pcDtParam->iRows;
    11431162  Int  iSubShift  = pcDtParam->iSubShift;
     
    11451164  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    11461165  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1147  
    1148   UInt uiSum = 0;
    1149  
     1166
     1167  Distortion uiSum = 0;
     1168
    11501169  for( ; iRows != 0; iRows-=iSubStep )
    11511170  {
     
    11741193    uiSum += abs( piOrg[22] - piCur[22] );
    11751194    uiSum += abs( piOrg[23] - piCur[23] );
    1176    
    1177     piOrg += iStrideOrg;
    1178     piCur += iStrideCur;
    1179   }
    1180  
     1195
     1196    piOrg += iStrideOrg;
     1197    piCur += iStrideCur;
     1198  }
     1199
    11811200  uiSum <<= iSubShift;
    1182   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    1183 }
    1184 
    1185 #endif
    1186 
    1187 UInt TComRdCost::xGetSAD64( DistParam* pcDtParam )
     1201  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     1202}
     1203
     1204Distortion TComRdCost::xGetSAD64( DistParam* pcDtParam )
    11881205{
    11891206  if ( pcDtParam->bApplyWeight )
    11901207  {
    1191     return xGetSADw( pcDtParam );
    1192   }
    1193 #if H_3D_IC
     1208    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     1209  }
     1210
     1211#if NH_3D_IC
    11941212  if( pcDtParam->bUseIC )
    11951213  {
     
    11971215  }
    11981216#endif
    1199 #if H_3D_INTER_SDC
     1217#if NH_3D_SDC_INTER
    12001218  if( pcDtParam->bUseSDCMRSAD )
    12011219  {
     
    12031221  }
    12041222#endif
    1205   Pel* piOrg   = pcDtParam->pOrg;
    1206   Pel* piCur   = pcDtParam->pCur;
     1223
     1224  const Pel* piOrg   = pcDtParam->pOrg;
     1225  const Pel* piCur   = pcDtParam->pCur;
    12071226  Int  iRows   = pcDtParam->iRows;
    12081227  Int  iSubShift  = pcDtParam->iSubShift;
     
    12101229  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    12111230  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1212  
    1213   UInt uiSum = 0;
    1214  
     1231
     1232  Distortion uiSum = 0;
     1233
    12151234  for( ; iRows != 0; iRows-=iSubStep )
    12161235  {
     
    12791298    uiSum += abs( piOrg[62] - piCur[62] );
    12801299    uiSum += abs( piOrg[63] - piCur[63] );
    1281    
    1282     piOrg += iStrideOrg;
    1283     piCur += iStrideCur;
    1284   }
    1285  
     1300
     1301    piOrg += iStrideOrg;
     1302    piCur += iStrideCur;
     1303  }
     1304
    12861305  uiSum <<= iSubShift;
    1287   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    1288 }
    1289 
    1290 #if AMP_SAD
    1291 UInt TComRdCost::xGetSAD48( DistParam* pcDtParam )
     1306  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     1307}
     1308
     1309Distortion TComRdCost::xGetSAD48( DistParam* pcDtParam )
    12921310{
    12931311  if ( pcDtParam->bApplyWeight )
    12941312  {
    1295     return xGetSADw( pcDtParam );
    1296   }
    1297 #if H_3D_IC
     1313    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
     1314  }
     1315#if NH_3D_IC
    12981316  if( pcDtParam->bUseIC )
    12991317  {
     
    13011319  }
    13021320#endif
    1303 #if H_3D_INTER_SDC
     1321#if NH_3D_SDC_INTER
    13041322  if( pcDtParam->bUseSDCMRSAD )
    13051323  {
     
    13071325  }
    13081326#endif
    1309   Pel* piOrg   = pcDtParam->pOrg;
    1310   Pel* piCur   = pcDtParam->pCur;
     1327
     1328  const Pel* piOrg   = pcDtParam->pOrg;
     1329  const Pel* piCur   = pcDtParam->pCur;
    13111330  Int  iRows   = pcDtParam->iRows;
    13121331  Int  iSubShift  = pcDtParam->iSubShift;
     
    13141333  Int  iStrideCur = pcDtParam->iStrideCur*iSubStep;
    13151334  Int  iStrideOrg = pcDtParam->iStrideOrg*iSubStep;
    1316  
    1317   UInt uiSum = 0;
    1318  
     1335
     1336  Distortion uiSum = 0;
     1337
    13191338  for( ; iRows != 0; iRows-=iSubStep )
    13201339  {
     
    13671386    uiSum += abs( piOrg[46] - piCur[46] );
    13681387    uiSum += abs( piOrg[47] - piCur[47] );
    1369    
    1370     piOrg += iStrideOrg;
    1371     piCur += iStrideCur;
    1372   }
    1373  
     1388
     1389    piOrg += iStrideOrg;
     1390    piCur += iStrideCur;
     1391  }
     1392
    13741393  uiSum <<= iSubShift;
    1375   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    1376 }
    1377 #endif
    1378 
    1379 #if H_3D_IC || H_3D_INTER_SDC
     1394  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     1395}
     1396
     1397
     1398#if NH_3D_IC || NH_3D_SDC_INTER
    13801399UInt TComRdCost::xGetSADic( DistParam* pcDtParam )
    13811400{
    13821401  if ( pcDtParam->bApplyWeight )
    13831402  {
    1384     return xGetSADw( pcDtParam );
     1403    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    13851404  }
    13861405  Pel* piOrg   = pcDtParam->pOrg;
     
    14301449  if ( pcDtParam->bApplyWeight )
    14311450  {
    1432     return xGetSADw( pcDtParam );
     1451    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    14331452  }
    14341453  Pel* piOrg   = pcDtParam->pOrg;
     
    14871506  if ( pcDtParam->bApplyWeight )
    14881507  {
    1489     return xGetSADw( pcDtParam );
     1508    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    14901509  }
    14911510  Pel* piOrg      = pcDtParam->pOrg;
     
    15561575  if ( pcDtParam->bApplyWeight )
    15571576  {
    1558     return xGetSADw( pcDtParam );
     1577    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    15591578  }
    15601579  Pel* piOrg   = pcDtParam->pOrg;
     
    16451664}
    16461665
    1647 #if AMP_SAD
    16481666UInt TComRdCost::xGetSAD12ic( DistParam* pcDtParam )
    16491667{
    16501668  if ( pcDtParam->bApplyWeight )
    16511669  {
    1652     return xGetSADw( pcDtParam );
     1670    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    16531671  }
    16541672  Pel* piOrg   = pcDtParam->pOrg;
     
    17261744  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    17271745}
    1728 #endif
     1746
    17291747
    17301748UInt TComRdCost::xGetSAD16Nic( DistParam* pcDtParam )
     
    18251843  if ( pcDtParam->bApplyWeight )
    18261844  {
    1827     return xGetSADw( pcDtParam );
     1845    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    18281846  }
    18291847  Pel* piOrg   = pcDtParam->pOrg;
     
    19621980}
    19631981
    1964 #if AMP_SAD
     1982
    19651983UInt TComRdCost::xGetSAD24ic( DistParam* pcDtParam )
    19661984{
    19671985  if ( pcDtParam->bApplyWeight )
    19681986  {
    1969     return xGetSADw( pcDtParam );
     1987    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    19701988  }
    19711989  Pel* piOrg   = pcDtParam->pOrg;
     
    20792097  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) );
    20802098}
    2081 #endif
    20822099
    20832100UInt TComRdCost::xGetSAD64ic( DistParam* pcDtParam )
     
    20852102  if ( pcDtParam->bApplyWeight )
    20862103  {
    2087     return xGetSADw( pcDtParam );
     2104    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    20882105  }
    20892106  Pel* piOrg   = pcDtParam->pOrg;
     
    23182335}
    23192336
    2320 #if AMP_SAD
     2337
    23212338UInt TComRdCost::xGetSAD48ic( DistParam* pcDtParam )
    23222339{
    23232340  if ( pcDtParam->bApplyWeight )
    23242341  {
    2325     return xGetSADw( pcDtParam );
     2342    return TComRdCostWeightPrediction::xGetSADw( pcDtParam );
    23262343  }
    23272344
     
    25092526}
    25102527#endif
    2511 
    2512 #endif
    25132528// --------------------------------------------------------------------------------------------------------------------
    25142529// SSE
    25152530// --------------------------------------------------------------------------------------------------------------------
    25162531
    2517 UInt TComRdCost::xGetSSE( DistParam* pcDtParam )
     2532Distortion TComRdCost::xGetSSE( DistParam* pcDtParam )
    25182533{
    25192534  if ( pcDtParam->bApplyWeight )
    25202535  {
    2521     return xGetSSEw( pcDtParam );
    2522   }
    2523   Pel* piOrg   = pcDtParam->pOrg;
    2524   Pel* piCur   = pcDtParam->pCur;
     2536    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     2537  }
     2538  const Pel* piOrg   = pcDtParam->pOrg;
     2539  const Pel* piCur   = pcDtParam->pCur;
    25252540  Int  iRows   = pcDtParam->iRows;
    25262541  Int  iCols   = pcDtParam->iCols;
    25272542  Int  iStrideOrg = pcDtParam->iStrideOrg;
    25282543  Int  iStrideCur = pcDtParam->iStrideCur;
    2529  
    2530   UInt uiSum = 0;
    2531   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    2532  
    2533   Int iTemp;
    2534  
     2544
     2545  Distortion uiSum  = 0;
     2546  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     2547
     2548  Intermediate_Int iTemp;
     2549
    25352550  for( ; iRows != 0; iRows-- )
    25362551  {
     
    25382553    {
    25392554      iTemp = piOrg[n  ] - piCur[n  ];
    2540       uiSum += ( iTemp * iTemp ) >> uiShift;
    2541     }
    2542     piOrg += iStrideOrg;
    2543     piCur += iStrideCur;
    2544   }
    2545  
     2555      uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2556    }
     2557    piOrg += iStrideOrg;
     2558    piCur += iStrideCur;
     2559  }
     2560
    25462561  return ( uiSum );
    25472562}
    25482563
    2549 UInt TComRdCost::xGetSSE4( DistParam* pcDtParam )
     2564Distortion TComRdCost::xGetSSE4( DistParam* pcDtParam )
    25502565{
    25512566  if ( pcDtParam->bApplyWeight )
    25522567  {
    25532568    assert( pcDtParam->iCols == 4 );
    2554     return xGetSSEw( pcDtParam );
    2555   }
    2556   Pel* piOrg   = pcDtParam->pOrg;
    2557   Pel* piCur   = pcDtParam->pCur;
     2569    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     2570  }
     2571  const Pel* piOrg   = pcDtParam->pOrg;
     2572  const Pel* piCur   = pcDtParam->pCur;
    25582573  Int  iRows   = pcDtParam->iRows;
    25592574  Int  iStrideOrg = pcDtParam->iStrideOrg;
    25602575  Int  iStrideCur = pcDtParam->iStrideCur;
    2561  
    2562   UInt uiSum = 0;
    2563   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    2564  
    2565   Int  iTemp;
    2566  
     2576
     2577  Distortion uiSum  = 0;
     2578  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     2579
     2580  Intermediate_Int  iTemp;
     2581
    25672582  for( ; iRows != 0; iRows-- )
    25682583  {
    2569    
    2570     iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2571     iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2572     iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2573     iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2574    
    2575     piOrg += iStrideOrg;
    2576     piCur += iStrideCur;
    2577   }
    2578  
     2584
     2585    iTemp = piOrg[0] - piCur[0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2586    iTemp = piOrg[1] - piCur[1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2587    iTemp = piOrg[2] - piCur[2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2588    iTemp = piOrg[3] - piCur[3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2589
     2590    piOrg += iStrideOrg;
     2591    piCur += iStrideCur;
     2592  }
     2593
    25792594  return ( uiSum );
    25802595}
    25812596
    2582 UInt TComRdCost::xGetSSE8( DistParam* pcDtParam )
     2597Distortion TComRdCost::xGetSSE8( DistParam* pcDtParam )
    25832598{
    25842599  if ( pcDtParam->bApplyWeight )
    25852600  {
    25862601    assert( pcDtParam->iCols == 8 );
    2587     return xGetSSEw( pcDtParam );
    2588   }
    2589   Pel* piOrg   = pcDtParam->pOrg;
    2590   Pel* piCur   = pcDtParam->pCur;
     2602    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     2603  }
     2604  const Pel* piOrg   = pcDtParam->pOrg;
     2605  const Pel* piCur   = pcDtParam->pCur;
    25912606  Int  iRows   = pcDtParam->iRows;
    25922607  Int  iStrideOrg = pcDtParam->iStrideOrg;
    25932608  Int  iStrideCur = pcDtParam->iStrideCur;
    2594  
    2595   UInt uiSum = 0;
    2596   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    2597  
    2598   Int  iTemp;
    2599  
     2609
     2610  Distortion uiSum  = 0;
     2611  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     2612
     2613  Intermediate_Int  iTemp;
     2614
    26002615  for( ; iRows != 0; iRows-- )
    26012616  {
    2602     iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2603     iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2604     iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2605     iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2606     iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2607     iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2608     iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2609     iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2610    
    2611     piOrg += iStrideOrg;
    2612     piCur += iStrideCur;
    2613   }
    2614  
     2617    iTemp = piOrg[0] - piCur[0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2618    iTemp = piOrg[1] - piCur[1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2619    iTemp = piOrg[2] - piCur[2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2620    iTemp = piOrg[3] - piCur[3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2621    iTemp = piOrg[4] - piCur[4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2622    iTemp = piOrg[5] - piCur[5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2623    iTemp = piOrg[6] - piCur[6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2624    iTemp = piOrg[7] - piCur[7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2625
     2626    piOrg += iStrideOrg;
     2627    piCur += iStrideCur;
     2628  }
     2629
    26152630  return ( uiSum );
    26162631}
    26172632
    2618 UInt TComRdCost::xGetSSE16( DistParam* pcDtParam )
     2633Distortion TComRdCost::xGetSSE16( DistParam* pcDtParam )
    26192634{
    26202635  if ( pcDtParam->bApplyWeight )
    26212636  {
    26222637    assert( pcDtParam->iCols == 16 );
    2623     return xGetSSEw( pcDtParam );
    2624   }
    2625   Pel* piOrg   = pcDtParam->pOrg;
    2626   Pel* piCur   = pcDtParam->pCur;
     2638    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     2639  }
     2640  const Pel* piOrg   = pcDtParam->pOrg;
     2641  const Pel* piCur   = pcDtParam->pCur;
    26272642  Int  iRows   = pcDtParam->iRows;
    26282643  Int  iStrideOrg = pcDtParam->iStrideOrg;
    26292644  Int  iStrideCur = pcDtParam->iStrideCur;
    2630  
    2631   UInt uiSum = 0;
    2632   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    2633  
    2634   Int  iTemp;
    2635  
     2645
     2646  Distortion uiSum  = 0;
     2647  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     2648
     2649  Intermediate_Int  iTemp;
     2650
    26362651  for( ; iRows != 0; iRows-- )
    26372652  {
    2638    
    2639     iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2640     iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2641     iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2642     iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2643     iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2644     iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2645     iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2646     iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2647     iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2648     iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2649     iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2650     iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2651     iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2652     iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2653     iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2654     iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2655    
    2656     piOrg += iStrideOrg;
    2657     piCur += iStrideCur;
    2658   }
    2659  
     2653
     2654    iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2655    iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2656    iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2657    iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2658    iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2659    iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2660    iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2661    iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2662    iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2663    iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2664    iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2665    iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2666    iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2667    iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2668    iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2669    iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2670
     2671    piOrg += iStrideOrg;
     2672    piCur += iStrideCur;
     2673  }
     2674
    26602675  return ( uiSum );
    26612676}
    26622677
    2663 UInt TComRdCost::xGetSSE16N( DistParam* pcDtParam )
     2678Distortion TComRdCost::xGetSSE16N( DistParam* pcDtParam )
    26642679{
    26652680  if ( pcDtParam->bApplyWeight )
    26662681  {
    2667     return xGetSSEw( pcDtParam );
    2668   }
    2669   Pel* piOrg   = pcDtParam->pOrg;
    2670   Pel* piCur   = pcDtParam->pCur;
     2682    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     2683  }
     2684  const Pel* piOrg   = pcDtParam->pOrg;
     2685  const Pel* piCur   = pcDtParam->pCur;
    26712686  Int  iRows   = pcDtParam->iRows;
    26722687  Int  iCols   = pcDtParam->iCols;
    26732688  Int  iStrideOrg = pcDtParam->iStrideOrg;
    26742689  Int  iStrideCur = pcDtParam->iStrideCur;
    2675  
    2676   UInt uiSum = 0;
    2677   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    2678   Int  iTemp;
    2679  
     2690
     2691  Distortion uiSum   = 0;
     2692  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     2693
     2694  Intermediate_Int  iTemp;
     2695
    26802696  for( ; iRows != 0; iRows-- )
    26812697  {
    26822698    for (Int n = 0; n < iCols; n+=16 )
    26832699    {
    2684      
    2685       iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2686       iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2687       iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2688       iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2689       iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2690       iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2691       iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2692       iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2693       iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2694       iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2695       iTemp = piOrg[n+10] - piCur[n+10]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2696       iTemp = piOrg[n+11] - piCur[n+11]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2697       iTemp = piOrg[n+12] - piCur[n+12]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2698       iTemp = piOrg[n+13] - piCur[n+13]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2699       iTemp = piOrg[n+14] - piCur[n+14]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2700       iTemp = piOrg[n+15] - piCur[n+15]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2701      
    2702     }
    2703     piOrg += iStrideOrg;
    2704     piCur += iStrideCur;
    2705   }
    2706  
     2700
     2701      iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2702      iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2703      iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2704      iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2705      iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2706      iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2707      iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2708      iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2709      iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2710      iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2711      iTemp = piOrg[n+10] - piCur[n+10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2712      iTemp = piOrg[n+11] - piCur[n+11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2713      iTemp = piOrg[n+12] - piCur[n+12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2714      iTemp = piOrg[n+13] - piCur[n+13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2715      iTemp = piOrg[n+14] - piCur[n+14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2716      iTemp = piOrg[n+15] - piCur[n+15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2717
     2718    }
     2719    piOrg += iStrideOrg;
     2720    piCur += iStrideCur;
     2721  }
     2722
    27072723  return ( uiSum );
    27082724}
    27092725
    2710 UInt TComRdCost::xGetSSE32( DistParam* pcDtParam )
     2726Distortion TComRdCost::xGetSSE32( DistParam* pcDtParam )
    27112727{
    27122728  if ( pcDtParam->bApplyWeight )
    27132729  {
    27142730    assert( pcDtParam->iCols == 32 );
    2715     return xGetSSEw( pcDtParam );
    2716   }
    2717   Pel* piOrg   = pcDtParam->pOrg;
    2718   Pel* piCur   = pcDtParam->pCur;
     2731    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     2732  }
     2733  const Pel* piOrg   = pcDtParam->pOrg;
     2734  const Pel* piCur   = pcDtParam->pCur;
    27192735  Int  iRows   = pcDtParam->iRows;
    27202736  Int  iStrideOrg = pcDtParam->iStrideOrg;
    27212737  Int  iStrideCur = pcDtParam->iStrideCur;
    2722  
    2723   UInt uiSum = 0;
    2724   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    2725   Int  iTemp;
    2726  
     2738
     2739  Distortion uiSum   = 0;
     2740  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     2741
     2742  Intermediate_Int  iTemp;
     2743
    27272744  for( ; iRows != 0; iRows-- )
    27282745  {
    2729    
    2730     iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2731     iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2732     iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2733     iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2734     iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2735     iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2736     iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2737     iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2738     iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2739     iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2740     iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2741     iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2742     iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2743     iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2744     iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2745     iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2746     iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2747     iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2748     iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2749     iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2750     iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2751     iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2752     iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2753     iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2754     iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2755     iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2756     iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2757     iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2758     iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2759     iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2760     iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2761     iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2762    
    2763     piOrg += iStrideOrg;
    2764     piCur += iStrideCur;
    2765   }
    2766  
     2746
     2747    iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2748    iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2749    iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2750    iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2751    iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2752    iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2753    iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2754    iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2755    iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2756    iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2757    iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2758    iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2759    iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2760    iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2761    iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2762    iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2763    iTemp = piOrg[16] - piCur[16]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2764    iTemp = piOrg[17] - piCur[17]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2765    iTemp = piOrg[18] - piCur[18]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2766    iTemp = piOrg[19] - piCur[19]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2767    iTemp = piOrg[20] - piCur[20]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2768    iTemp = piOrg[21] - piCur[21]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2769    iTemp = piOrg[22] - piCur[22]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2770    iTemp = piOrg[23] - piCur[23]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2771    iTemp = piOrg[24] - piCur[24]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2772    iTemp = piOrg[25] - piCur[25]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2773    iTemp = piOrg[26] - piCur[26]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2774    iTemp = piOrg[27] - piCur[27]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2775    iTemp = piOrg[28] - piCur[28]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2776    iTemp = piOrg[29] - piCur[29]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2777    iTemp = piOrg[30] - piCur[30]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2778    iTemp = piOrg[31] - piCur[31]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2779
     2780    piOrg += iStrideOrg;
     2781    piCur += iStrideCur;
     2782  }
     2783
    27672784  return ( uiSum );
    27682785}
    27692786
    2770 UInt TComRdCost::xGetSSE64( DistParam* pcDtParam )
     2787Distortion TComRdCost::xGetSSE64( DistParam* pcDtParam )
    27712788{
    27722789  if ( pcDtParam->bApplyWeight )
    27732790  {
    27742791    assert( pcDtParam->iCols == 64 );
    2775     return xGetSSEw( pcDtParam );
    2776   }
    2777   Pel* piOrg   = pcDtParam->pOrg;
    2778   Pel* piCur   = pcDtParam->pCur;
     2792    return TComRdCostWeightPrediction::xGetSSEw( pcDtParam );
     2793  }
     2794  const Pel* piOrg   = pcDtParam->pOrg;
     2795  const Pel* piCur   = pcDtParam->pCur;
    27792796  Int  iRows   = pcDtParam->iRows;
    27802797  Int  iStrideOrg = pcDtParam->iStrideOrg;
    27812798  Int  iStrideCur = pcDtParam->iStrideCur;
    2782  
    2783   UInt uiSum = 0;
    2784   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    2785   Int  iTemp;
    2786  
     2799
     2800  Distortion uiSum   = 0;
     2801  UInt       uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     2802
     2803  Intermediate_Int  iTemp;
     2804
    27872805  for( ; iRows != 0; iRows-- )
    27882806  {
    2789     iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2790     iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2791     iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2792     iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2793     iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2794     iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2795     iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2796     iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2797     iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2798     iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2799     iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2800     iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2801     iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2802     iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2803     iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2804     iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2805     iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2806     iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2807     iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2808     iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2809     iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2810     iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2811     iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2812     iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2813     iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2814     iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2815     iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2816     iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2817     iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2818     iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2819     iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2820     iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2821     iTemp = piOrg[32] - piCur[32]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2822     iTemp = piOrg[33] - piCur[33]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2823     iTemp = piOrg[34] - piCur[34]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2824     iTemp = piOrg[35] - piCur[35]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2825     iTemp = piOrg[36] - piCur[36]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2826     iTemp = piOrg[37] - piCur[37]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2827     iTemp = piOrg[38] - piCur[38]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2828     iTemp = piOrg[39] - piCur[39]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2829     iTemp = piOrg[40] - piCur[40]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2830     iTemp = piOrg[41] - piCur[41]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2831     iTemp = piOrg[42] - piCur[42]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2832     iTemp = piOrg[43] - piCur[43]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2833     iTemp = piOrg[44] - piCur[44]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2834     iTemp = piOrg[45] - piCur[45]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2835     iTemp = piOrg[46] - piCur[46]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2836     iTemp = piOrg[47] - piCur[47]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2837     iTemp = piOrg[48] - piCur[48]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2838     iTemp = piOrg[49] - piCur[49]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2839     iTemp = piOrg[50] - piCur[50]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2840     iTemp = piOrg[51] - piCur[51]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2841     iTemp = piOrg[52] - piCur[52]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2842     iTemp = piOrg[53] - piCur[53]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2843     iTemp = piOrg[54] - piCur[54]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2844     iTemp = piOrg[55] - piCur[55]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2845     iTemp = piOrg[56] - piCur[56]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2846     iTemp = piOrg[57] - piCur[57]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2847     iTemp = piOrg[58] - piCur[58]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2848     iTemp = piOrg[59] - piCur[59]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2849     iTemp = piOrg[60] - piCur[60]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2850     iTemp = piOrg[61] - piCur[61]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2851     iTemp = piOrg[62] - piCur[62]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2852     iTemp = piOrg[63] - piCur[63]; uiSum += ( iTemp * iTemp ) >> uiShift;
    2853    
    2854     piOrg += iStrideOrg;
    2855     piCur += iStrideCur;
    2856   }
    2857  
     2807    iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2808    iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2809    iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2810    iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2811    iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2812    iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2813    iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2814    iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2815    iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2816    iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2817    iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2818    iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2819    iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2820    iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2821    iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2822    iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2823    iTemp = piOrg[16] - piCur[16]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2824    iTemp = piOrg[17] - piCur[17]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2825    iTemp = piOrg[18] - piCur[18]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2826    iTemp = piOrg[19] - piCur[19]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2827    iTemp = piOrg[20] - piCur[20]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2828    iTemp = piOrg[21] - piCur[21]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2829    iTemp = piOrg[22] - piCur[22]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2830    iTemp = piOrg[23] - piCur[23]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2831    iTemp = piOrg[24] - piCur[24]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2832    iTemp = piOrg[25] - piCur[25]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2833    iTemp = piOrg[26] - piCur[26]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2834    iTemp = piOrg[27] - piCur[27]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2835    iTemp = piOrg[28] - piCur[28]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2836    iTemp = piOrg[29] - piCur[29]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2837    iTemp = piOrg[30] - piCur[30]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2838    iTemp = piOrg[31] - piCur[31]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2839    iTemp = piOrg[32] - piCur[32]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2840    iTemp = piOrg[33] - piCur[33]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2841    iTemp = piOrg[34] - piCur[34]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2842    iTemp = piOrg[35] - piCur[35]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2843    iTemp = piOrg[36] - piCur[36]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2844    iTemp = piOrg[37] - piCur[37]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2845    iTemp = piOrg[38] - piCur[38]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2846    iTemp = piOrg[39] - piCur[39]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2847    iTemp = piOrg[40] - piCur[40]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2848    iTemp = piOrg[41] - piCur[41]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2849    iTemp = piOrg[42] - piCur[42]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2850    iTemp = piOrg[43] - piCur[43]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2851    iTemp = piOrg[44] - piCur[44]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2852    iTemp = piOrg[45] - piCur[45]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2853    iTemp = piOrg[46] - piCur[46]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2854    iTemp = piOrg[47] - piCur[47]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2855    iTemp = piOrg[48] - piCur[48]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2856    iTemp = piOrg[49] - piCur[49]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2857    iTemp = piOrg[50] - piCur[50]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2858    iTemp = piOrg[51] - piCur[51]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2859    iTemp = piOrg[52] - piCur[52]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2860    iTemp = piOrg[53] - piCur[53]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2861    iTemp = piOrg[54] - piCur[54]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2862    iTemp = piOrg[55] - piCur[55]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2863    iTemp = piOrg[56] - piCur[56]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2864    iTemp = piOrg[57] - piCur[57]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2865    iTemp = piOrg[58] - piCur[58]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2866    iTemp = piOrg[59] - piCur[59]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2867    iTemp = piOrg[60] - piCur[60]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2868    iTemp = piOrg[61] - piCur[61]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2869    iTemp = piOrg[62] - piCur[62]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2870    iTemp = piOrg[63] - piCur[63]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift);
     2871
     2872    piOrg += iStrideOrg;
     2873    piCur += iStrideCur;
     2874  }
     2875
    28582876  return ( uiSum );
    28592877}
    2860 #if H_3D_VSO
     2878
     2879#if NH_3D_VSO
    28612880//SAIT_VSO_EST_A0033
    28622881UInt TComRdCost::getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y )
    2863 {
    2864   Double  dD = ( (Double) ( dDM >> DISTORTION_PRECISION_ADJUSTMENT( g_bitDepthY - 8 ) ) ) * m_dDisparityCoeff;
    2865 
    2866   Double dDepthWeight = ( pOrg[x] >=  ( (1<<(g_bitDepthY - 3)) + (1<<(g_bitDepthY - 2)) ) ? 4 : pOrg[x] > ((1<<g_bitDepthY) >> 4) ? (Float)(pOrg[x] - ((1<<g_bitDepthY) >> 4))/(Float)((1<<g_bitDepthY) >> 3) + 1 : 1.0 );
     2882{
     2883  // change to use bit depth from DistParam struct
     2884  Double  dD = ( (Double) ( dDM >> ( ENC_INTERNAL_BIT_DEPTH - 8 ) ) ) * m_dDisparityCoeff;
     2885
     2886  Double dDepthWeight = ( pOrg[x] >=  ( (1<<(REN_BIT_DEPTH - 3)) + (1<<(REN_BIT_DEPTH - 2)) ) ? 4 : pOrg[x] > ((1<<REN_BIT_DEPTH) >> 4) ? (Float)(pOrg[x] - ((1<<REN_BIT_DEPTH) >> 4))/(Float)((1<<REN_BIT_DEPTH) >> 3) + 1 : 1.0 );
     2887
    28672888  Double dTemp = ( 0.5 * fabs(dD) * dDepthWeight * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) );
    28682889  Int iTemp = (Int) (((dTemp) < 0)? (Int)((dTemp) - 0.5) : (Int)((dTemp) + 0.5));
     
    30923113// --------------------------------------------------------------------------------------------------------------------
    30933114
    3094 UInt TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    3095 {
    3096   Int satd = 0, diff[4], m[4];
     3115Distortion TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     3116{
     3117  Distortion satd = 0;
     3118  TCoeff diff[4], m[4];
    30973119  assert( iStep == 1 );
    30983120  diff[0] = piOrg[0             ] - piCur[0];
     
    31043126  m[2] = diff[0] - diff[2];
    31053127  m[3] = diff[1] - diff[3];
    3106  
     3128
    31073129  satd += abs(m[0] + m[1]);
    31083130  satd += abs(m[0] - m[1]);
    31093131  satd += abs(m[2] + m[3]);
    31103132  satd += abs(m[2] - m[3]);
    3111  
     3133
    31123134  return satd;
    31133135}
    31143136
    3115 UInt TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    3116 {
    3117   Int k, satd = 0, diff[16], m[16], d[16];
    3118  
     3137Distortion TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     3138{
     3139  Int k;
     3140  Distortion satd = 0;
     3141  TCoeff diff[16], m[16], d[16];
     3142
    31193143  assert( iStep == 1 );
    31203144  for( k = 0; k < 16; k+=4 )
     
    31243148    diff[k+2] = piOrg[2] - piCur[2];
    31253149    diff[k+3] = piOrg[3] - piCur[3];
    3126    
    3127     piCur += iStrideCur;
    3128     piOrg += iStrideOrg;
    3129   }
    3130  
     3150
     3151    piCur += iStrideCur;
     3152    piOrg += iStrideOrg;
     3153  }
     3154
    31313155  /*===== hadamard transform =====*/
    31323156  m[ 0] = diff[ 0] + diff[12];
     
    31463170  m[14] = diff[ 2] - diff[14];
    31473171  m[15] = diff[ 3] - diff[15];
    3148  
     3172
    31493173  d[ 0] = m[ 0] + m[ 4];
    31503174  d[ 1] = m[ 1] + m[ 5];
     
    31633187  d[14] = m[14] - m[10];
    31643188  d[15] = m[15] - m[11];
    3165  
     3189
    31663190  m[ 0] = d[ 0] + d[ 3];
    31673191  m[ 1] = d[ 1] + d[ 2];
     
    31803204  m[14] = d[13] - d[14];
    31813205  m[15] = d[12] - d[15];
    3182  
     3206
    31833207  d[ 0] = m[ 0] + m[ 1];
    31843208  d[ 1] = m[ 0] - m[ 1];
     
    31973221  d[14] = m[14] + m[15];
    31983222  d[15] = m[15] - m[14];
    3199  
     3223
    32003224  for (k=0; k<16; ++k)
    32013225  {
     
    32033227  }
    32043228  satd = ((satd+1)>>1);
    3205  
     3229
    32063230  return satd;
    32073231}
    32083232
    3209 UInt TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    3210 {
    3211   Int k, i, j, jj, sad=0;
    3212   Int diff[64], m1[8][8], m2[8][8], m3[8][8];
     3233Distortion TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     3234{
     3235  Int k, i, j, jj;
     3236  Distortion sad = 0;
     3237  TCoeff diff[64], m1[8][8], m2[8][8], m3[8][8];
    32133238  assert( iStep == 1 );
    32143239  for( k = 0; k < 64; k += 8 )
     
    32223247    diff[k+6] = piOrg[6] - piCur[6];
    32233248    diff[k+7] = piOrg[7] - piCur[7];
    3224    
    3225     piCur += iStrideCur;
    3226     piOrg += iStrideOrg;
    3227   }
    3228  
     3249
     3250    piCur += iStrideCur;
     3251    piOrg += iStrideOrg;
     3252  }
     3253
    32293254  //horizontal
    32303255  for (j=0; j < 8; j++)
     
    32393264    m2[j][6] = diff[jj+2] - diff[jj+6];
    32403265    m2[j][7] = diff[jj+3] - diff[jj+7];
    3241    
     3266
    32423267    m1[j][0] = m2[j][0] + m2[j][2];
    32433268    m1[j][1] = m2[j][1] + m2[j][3];
     
    32483273    m1[j][6] = m2[j][4] - m2[j][6];
    32493274    m1[j][7] = m2[j][5] - m2[j][7];
    3250    
     3275
    32513276    m2[j][0] = m1[j][0] + m1[j][1];
    32523277    m2[j][1] = m1[j][0] - m1[j][1];
     
    32583283    m2[j][7] = m1[j][6] - m1[j][7];
    32593284  }
    3260  
     3285
    32613286  //vertical
    32623287  for (i=0; i < 8; i++)
     
    32703295    m3[6][i] = m2[2][i] - m2[6][i];
    32713296    m3[7][i] = m2[3][i] - m2[7][i];
    3272    
     3297
    32733298    m1[0][i] = m3[0][i] + m3[2][i];
    32743299    m1[1][i] = m3[1][i] + m3[3][i];
     
    32793304    m1[6][i] = m3[4][i] - m3[6][i];
    32803305    m1[7][i] = m3[5][i] - m3[7][i];
    3281    
     3306
    32823307    m2[0][i] = m1[0][i] + m1[1][i];
    32833308    m2[1][i] = m1[0][i] - m1[1][i];
     
    32893314    m2[7][i] = m1[6][i] - m1[7][i];
    32903315  }
    3291  
     3316
    32923317  for (i = 0; i < 8; i++)
    32933318  {
     
    32973322    }
    32983323  }
    3299  
     3324
    33003325  sad=((sad+2)>>2);
    3301  
     3326
    33023327  return sad;
    33033328}
    33043329
    3305 UInt TComRdCost::xGetHADs4( DistParam* pcDtParam )
     3330
     3331Distortion TComRdCost::xGetHADs( DistParam* pcDtParam )
    33063332{
    33073333  if ( pcDtParam->bApplyWeight )
    33083334  {
    3309     return xGetHADs4w( pcDtParam );
    3310   }
    3311   Pel* piOrg   = pcDtParam->pOrg;
    3312   Pel* piCur   = pcDtParam->pCur;
    3313   Int  iRows   = pcDtParam->iRows;
    3314   Int  iStrideCur = pcDtParam->iStrideCur;
    3315   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3316   Int  iStep  = pcDtParam->iStep;
    3317   Int  y;
    3318   Int  iOffsetOrg = iStrideOrg<<2;
    3319   Int  iOffsetCur = iStrideCur<<2;
    3320  
    3321   UInt uiSum = 0;
    3322  
    3323   for ( y=0; y<iRows; y+= 4 )
    3324   {
    3325     uiSum += xCalcHADs4x4( piOrg, piCur, iStrideOrg, iStrideCur, iStep );
    3326     piOrg += iOffsetOrg;
    3327     piCur += iOffsetCur;
    3328   }
    3329  
    3330   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    3331 }
    3332 
    3333 UInt TComRdCost::xGetHADs8( DistParam* pcDtParam )
    3334 {
    3335   if ( pcDtParam->bApplyWeight )
    3336   {
    3337     return xGetHADs8w( pcDtParam );
    3338   }
    3339   Pel* piOrg   = pcDtParam->pOrg;
    3340   Pel* piCur   = pcDtParam->pCur;
    3341   Int  iRows   = pcDtParam->iRows;
    3342   Int  iStrideCur = pcDtParam->iStrideCur;
    3343   Int  iStrideOrg = pcDtParam->iStrideOrg;
    3344   Int  iStep  = pcDtParam->iStep;
    3345   Int  y;
    3346  
    3347   UInt uiSum = 0;
    3348  
    3349   if ( iRows == 4 )
    3350   {
    3351     uiSum += xCalcHADs4x4( piOrg+0, piCur        , iStrideOrg, iStrideCur, iStep );
    3352     uiSum += xCalcHADs4x4( piOrg+4, piCur+4*iStep, iStrideOrg, iStrideCur, iStep );
    3353   }
    3354   else
    3355   {
    3356     Int  iOffsetOrg = iStrideOrg<<3;
    3357     Int  iOffsetCur = iStrideCur<<3;
    3358     for ( y=0; y<iRows; y+= 8 )
    3359     {
    3360       uiSum += xCalcHADs8x8( piOrg, piCur, iStrideOrg, iStrideCur, iStep );
    3361       piOrg += iOffsetOrg;
    3362       piCur += iOffsetCur;
    3363     }
    3364   }
    3365  
    3366   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    3367 }
    3368 
    3369 UInt TComRdCost::xGetHADs( DistParam* pcDtParam )
    3370 {
    3371   if ( pcDtParam->bApplyWeight )
    3372   {
    3373     return xGetHADsw( pcDtParam );
    3374   }
    3375 #if H_3D_IC
     3335    return TComRdCostWeightPrediction::xGetHADsw( pcDtParam );
     3336  }
     3337#if NH_3D_IC
    33763338  if( pcDtParam->bUseIC )
    33773339  {
     
    33793341  }
    33803342#endif
    3381 #if H_3D_INTER_SDC
     3343#if NH_3D_SDC_INTER
    33823344  if( pcDtParam->bUseSDCMRSAD )
    33833345  {
     
    33853347  }
    33863348#endif
     3349
    33873350  Pel* piOrg   = pcDtParam->pOrg;
    33883351  Pel* piCur   = pcDtParam->pCur;
     
    33923355  Int  iStrideOrg = pcDtParam->iStrideOrg;
    33933356  Int  iStep  = pcDtParam->iStep;
    3394  
     3357
    33953358  Int  x, y;
    3396  
    3397   UInt uiSum = 0;
    3398  
     3359
     3360  Distortion uiSum = 0;
     3361
    33993362  if( ( iRows % 8 == 0) && (iCols % 8 == 0) )
    34003363  {
     
    34153378    Int  iOffsetOrg = iStrideOrg<<2;
    34163379    Int  iOffsetCur = iStrideCur<<2;
    3417    
     3380
    34183381    for ( y=0; y<iRows; y+= 4 )
    34193382    {
     
    34443407    assert(false);
    34453408  }
    3446  
    3447   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    3448 }
    3449 
    3450 #if H_3D_IC || H_3D_INTER_SDC
     3409
     3410  return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) );
     3411}
     3412
     3413#if NH_3D_IC || NH_3D_SDC_INTER
    34513414UInt TComRdCost::xGetHADsic( DistParam* pcDtParam )
    34523415{
    34533416  if ( pcDtParam->bApplyWeight )
    34543417  {
    3455     return xGetHADsw( pcDtParam );
     3418    return TComRdCostWeightPrediction::xGetHADsw( pcDtParam );
    34563419  }
    34573420  Pel* piOrg   = pcDtParam->pOrg;
     
    35933556}
    35943557#endif
    3595 
    3596 #if H_3D_VSO
     3558#if NH_3D_VSO
    35973559Void TComRdCost::setLambdaVSO( Double dLambdaVSO )
    35983560{
     
    36023564  m_uiLambdaMotionSSEVSO = (UInt)floor(65536.0 *       m_dLambdaVSO    );
    36033565}
    3604 
     3566#endif
     3567#if NH_3D_VSO
    36053568Dist TComRdCost::xGetDistVSOMode4( Int iStartPosX, Int iStartPosY, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD )
    36063569{
     
    36213584
    36223585
    3623 Dist TComRdCost::getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHAD )
     3586Dist TComRdCost::getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHAD )
    36243587{
    36253588  assert( m_bUseVSO ); 
     
    36353598  if ( m_bUseWVSO )   
    36363599  {
    3637     Int iDWeight   = m_iDWeight   * m_iDWeight;
     3600    Int iDWeight   = m_iDWeight   * m_iDWeight  ;
    36383601    Int iVSOWeight = m_iVSOWeight * m_iVSOWeight;
    36393602    Dist distDepth;
     
    36413604    if ( !bHAD )
    36423605    {
    3643        distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
     3606       distDepth = (Dist) getDistPart( bitDepth, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight, COMPONENT_Y);
    36443607    }
    36453608    else
    36463609    {
    3647        distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
     3610       distDepth = (Dist) calcHAD    ( bitDepth, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight);
    36483611    }
    36493612   
     
    37223685  }
    37233686
     3687  D_PRINT_INDENT( g_traceRDCost, "VSO Dist: " + n2s(uiDistortion) + " Bits: " + n2s(uiBits) + " RD Cost: " + n2s(dRdCost));
     3688
    37243689  return dRdCost;
    37253690}
    37263691
    3727 Void TComRdCost::setRenModelData( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight )
     3692Void TComRdCost::setRenModelData( const TComDataCU* pcCU, UInt uiAbsPartIndex, const TComYuv* pcYuv, const TComTURecurse* tuRecurseWithPU )
     3693{
     3694  const TComRectangle &puRect=tuRecurseWithPU->getRect(COMPONENT_Y);
     3695  const UInt  uiCompWidth   = puRect.width;
     3696  const UInt  uiCompHeight  = puRect.height;
     3697
     3698  const Pel*  piSrc         = pcYuv->getAddr( COMPONENT_Y, uiAbsPartIndex );
     3699  const UInt  uiSrcStride   = pcYuv->getStride( COMPONENT_Y);
     3700  setRenModelData( pcCU, uiAbsPartIndex, piSrc, uiSrcStride, uiCompWidth, uiCompHeight );
     3701}
     3702
     3703Void TComRdCost::setRenModelData( const TComDataCU* pcCU, UInt uiAbsPartIndex, const Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight )
    37283704{
    37293705  UInt iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]];
Note: See TracChangeset for help on using the changeset viewer.