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/TComRdCostWeightPrediction.cpp

    r1179 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 *
     
    4141#include "TComRdCostWeightPrediction.h"
    4242
    43 Int   TComRdCostWeightPrediction::m_w0        = 0;
    44 Int   TComRdCostWeightPrediction::m_w1        = 0;
    45 Int   TComRdCostWeightPrediction::m_shift     = 0;
    46 Int   TComRdCostWeightPrediction::m_offset    = 0;
    47 Int   TComRdCostWeightPrediction::m_round     = 0;
    48 Bool  TComRdCostWeightPrediction::m_xSetDone  = false;
    49 
    50 // ====================================================================================================================
    51 // Distortion functions
    52 // ====================================================================================================================
    53 
    54 TComRdCostWeightPrediction::TComRdCostWeightPrediction()
    55 {
    56 }
    57 
    58 TComRdCostWeightPrediction::~TComRdCostWeightPrediction()
    59 {
    60 }
     43static Distortion xCalcHADs2x2w( const WPScalingParam &wpCur, const Pel *piOrg, const Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
     44static Distortion xCalcHADs4x4w( const WPScalingParam &wpCur, const Pel *piOrg, const Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
     45static Distortion xCalcHADs8x8w( const WPScalingParam &wpCur, const Pel *piOrg, const Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
     46
    6147
    6248// --------------------------------------------------------------------------------------------------------------------
     
    6551/** get weighted SAD cost
    6652 * \param pcDtParam
    67  * \returns UInt
     53 * \returns Distortion
    6854 */
    69 UInt TComRdCostWeightPrediction::xGetSADw( DistParam* pcDtParam )
    70 {
    71   Pel  pred;
    72   Pel* piOrg   = pcDtParam->pOrg;
    73   Pel* piCur   = pcDtParam->pCur;
    74   Int  iRows   = pcDtParam->iRows;
    75   Int  iCols   = pcDtParam->iCols;
    76   Int  iStrideCur = pcDtParam->iStrideCur;
    77   Int  iStrideOrg = pcDtParam->iStrideOrg;
    78 
    79   UInt            uiComp    = pcDtParam->uiComp;
    80   assert(uiComp<3);
    81   wpScalingParam  *wpCur    = &(pcDtParam->wpCur[uiComp]);
    82   Int   w0      = wpCur->w,
    83         offset  = wpCur->offset,
    84         shift   = wpCur->shift,
    85         round   = wpCur->round;
    86  
    87   UInt uiSum = 0;
    88  
    89   for( ; iRows != 0; iRows-- )
     55Distortion TComRdCostWeightPrediction::xGetSADw( DistParam* pcDtParam )
     56{
     57  const Pel            *piOrg      = pcDtParam->pOrg;
     58  const Pel            *piCur      = pcDtParam->pCur;
     59  const Int             iCols      = pcDtParam->iCols;
     60  const Int             iStrideCur = pcDtParam->iStrideCur;
     61  const Int             iStrideOrg = pcDtParam->iStrideOrg;
     62  const ComponentID     compID     = pcDtParam->compIdx;
     63
     64  assert(compID<MAX_NUM_COMPONENT);
     65
     66  const WPScalingParam &wpCur      = pcDtParam->wpCur[compID];
     67
     68  const Int             w0         = wpCur.w;
     69  const Int             offset     = wpCur.offset;
     70  const Int             shift      = wpCur.shift;
     71  const Int             round      = wpCur.round;
     72
     73  Distortion uiSum = 0;
     74
     75  for(Int iRows = pcDtParam->iRows; iRows != 0; iRows-- )
    9076  {
    9177    for (Int n = 0; n < iCols; n++ )
    9278    {
    93       pred = ( (w0*piCur[n] + round) >> shift ) + offset ;
    94      
     79      const Pel pred = ( (w0*piCur[n] + round) >> shift ) + offset ;
     80
    9581      uiSum += abs( piOrg[n] - pred );
    9682    }
     
    9884    piCur += iStrideCur;
    9985  }
    100  
    101   pcDtParam->uiComp = 255;  // reset for DEBUG (assert test)
     86
     87  pcDtParam->compIdx = MAX_NUM_COMPONENT;  // reset for DEBUG (assert test)
    10288
    10389  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    10490}
     91
    10592
    10693// --------------------------------------------------------------------------------------------------------------------
     
    10996/** get weighted SSD cost
    11097 * \param pcDtParam
    111  * \returns UInt
     98 * \returns Distortion
    11299 */
    113 UInt TComRdCostWeightPrediction::xGetSSEw( DistParam* pcDtParam )
    114 {
    115   Pel* piOrg   = pcDtParam->pOrg;
    116   Pel* piCur   = pcDtParam->pCur;
    117   Pel  pred;
    118   Int  iRows   = pcDtParam->iRows;
    119   Int  iCols   = pcDtParam->iCols;
    120   Int  iStrideOrg = pcDtParam->iStrideOrg;
    121   Int  iStrideCur = pcDtParam->iStrideCur;
    122 
    123   assert( pcDtParam->iSubShift == 0 );
    124 
    125   UInt            uiComp    = pcDtParam->uiComp;
    126   assert(uiComp<3);
    127   wpScalingParam  *wpCur    = &(pcDtParam->wpCur[uiComp]);
    128   Int   w0      = wpCur->w,
    129         offset  = wpCur->offset,
    130         shift   = wpCur->shift,
    131         round   = wpCur->round;
    132  
    133   UInt uiSum = 0;
    134   UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
    135  
    136   Int iTemp;
    137  
    138   for( ; iRows != 0; iRows-- )
     100Distortion TComRdCostWeightPrediction::xGetSSEw( DistParam* pcDtParam )
     101{
     102  const Pel            *piOrg           = pcDtParam->pOrg;
     103  const Pel            *piCur           = pcDtParam->pCur;
     104  const Int             iCols           = pcDtParam->iCols;
     105  const Int             iStrideOrg      = pcDtParam->iStrideOrg;
     106  const Int             iStrideCur      = pcDtParam->iStrideCur;
     107  const ComponentID     compIdx         = pcDtParam->compIdx;
     108
     109  assert( pcDtParam->iSubShift == 0 ); // NOTE: what is this protecting?
     110
     111  assert(compIdx<MAX_NUM_COMPONENT);
     112  const WPScalingParam &wpCur           = pcDtParam->wpCur[compIdx];
     113  const Int             w0              = wpCur.w;
     114  const Int             offset          = wpCur.offset;
     115  const Int             shift           = wpCur.shift;
     116  const Int             round           = wpCur.round;
     117  const UInt            distortionShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
     118
     119  Distortion sum = 0;
     120
     121  for(Int iRows = pcDtParam->iRows ; iRows != 0; iRows-- )
    139122  {
    140123    for (Int n = 0; n < iCols; n++ )
    141124    {
    142       pred = ( (w0*piCur[n] + round) >> shift ) + offset ;
    143 
    144       iTemp = piOrg[n  ] - pred;
    145       uiSum += ( iTemp * iTemp ) >> uiShift;
     125      const Pel pred     = ( (w0*piCur[n] + round) >> shift ) + offset ;
     126      const Pel residual = piOrg[n] - pred;
     127      sum += ( Distortion(residual) * Distortion(residual) ) >> distortionShift;
    146128    }
    147129    piOrg += iStrideOrg;
    148130    piCur += iStrideCur;
    149131  }
    150  
    151   pcDtParam->uiComp = 255;  // reset for DEBUG (assert test)
    152 
    153   return ( uiSum );
    154 }
     132
     133  pcDtParam->compIdx = MAX_NUM_COMPONENT; // reset for DEBUG (assert test)
     134
     135  return sum;
     136}
     137
    155138
    156139// --------------------------------------------------------------------------------------------------------------------
    157140// HADAMARD with step (used in fractional search)
    158141// --------------------------------------------------------------------------------------------------------------------
    159 /** get weighted Hadamard cost for 2x2 block
    160  * \param *piOrg
    161  * \param *piCur
    162  * \param iStrideOrg
    163  * \param iStrideCur
    164  * \param iStep
    165  * \returns UInt
    166  */
    167 UInt TComRdCostWeightPrediction::xCalcHADs2x2w( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    168 {
    169   Int satd = 0, diff[4], m[4];
    170  
    171   assert( m_xSetDone );
     142//! get weighted Hadamard cost for 2x2 block
     143Distortion xCalcHADs2x2w( const WPScalingParam &wpCur, const Pel *piOrg, const Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     144{
     145  const Int round  = wpCur.round;
     146  const Int shift  = wpCur.shift;
     147  const Int offset = wpCur.offset;
     148  const Int w0     = wpCur.w;
     149
     150  Distortion satd  = 0;
     151  TCoeff     diff[4];
     152  TCoeff     m[4];
     153
    172154  Pel   pred;
    173155
    174   pred    = ( (m_w0*piCur[0*iStep             ] + m_round) >> m_shift ) + m_offset ;
     156  pred    = ( (w0*piCur[0*iStep             ] + round) >> shift ) + offset ;
    175157  diff[0] = piOrg[0             ] - pred;
    176   pred    = ( (m_w0*piCur[1*iStep             ] + m_round) >> m_shift ) + m_offset ;
     158  pred    = ( (w0*piCur[1*iStep             ] + round) >> shift ) + offset ;
    177159  diff[1] = piOrg[1             ] - pred;
    178   pred    = ( (m_w0*piCur[0*iStep + iStrideCur] + m_round) >> m_shift ) + m_offset ;
     160  pred    = ( (w0*piCur[0*iStep + iStrideCur] + round) >> shift ) + offset ;
    179161  diff[2] = piOrg[iStrideOrg    ] - pred;
    180   pred    = ( (m_w0*piCur[1*iStep + iStrideCur] + m_round) >> m_shift ) + m_offset ;
     162  pred    = ( (w0*piCur[1*iStep + iStrideCur] + round) >> shift ) + offset ;
    181163  diff[3] = piOrg[iStrideOrg + 1] - pred;
    182164
     
    185167  m[2] = diff[0] - diff[2];
    186168  m[3] = diff[1] - diff[3];
    187  
     169
    188170  satd += abs(m[0] + m[1]);
    189171  satd += abs(m[0] - m[1]);
    190172  satd += abs(m[2] + m[3]);
    191173  satd += abs(m[2] - m[3]);
    192  
     174
    193175  return satd;
    194176}
    195177
    196 /** get weighted Hadamard cost for 4x4 block
    197  * \param *piOrg
    198  * \param *piCur
    199  * \param iStrideOrg
    200  * \param iStrideCur
    201  * \param iStep
    202  * \returns UInt
    203  */
    204 UInt TComRdCostWeightPrediction::xCalcHADs4x4w( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    205 {
    206   Int k, satd = 0, diff[16], m[16], d[16];
    207  
    208   assert( m_xSetDone );
    209   Pel   pred;
    210 
    211   for( k = 0; k < 16; k+=4 )
    212   {
    213     pred      = ( (m_w0*piCur[0*iStep] + m_round) >> m_shift ) + m_offset ;
     178
     179//! get weighted Hadamard cost for 4x4 block
     180Distortion xCalcHADs4x4w( const WPScalingParam &wpCur, const Pel *piOrg, const Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     181{
     182  const Int round  = wpCur.round;
     183  const Int shift  = wpCur.shift;
     184  const Int offset = wpCur.offset;
     185  const Int w0     = wpCur.w;
     186
     187  Distortion satd = 0;
     188  TCoeff     diff[16];
     189  TCoeff     m[16];
     190  TCoeff     d[16];
     191
     192
     193  for(Int k = 0; k < 16; k+=4 )
     194  {
     195    Pel pred;
     196    pred      = ( (w0*piCur[0*iStep] + round) >> shift ) + offset ;
    214197    diff[k+0] = piOrg[0] - pred;
    215     pred      = ( (m_w0*piCur[1*iStep] + m_round) >> m_shift ) + m_offset ;
     198    pred      = ( (w0*piCur[1*iStep] + round) >> shift ) + offset ;
    216199    diff[k+1] = piOrg[1] - pred;
    217     pred      = ( (m_w0*piCur[2*iStep] + m_round) >> m_shift ) + m_offset ;
     200    pred      = ( (w0*piCur[2*iStep] + round) >> shift ) + offset ;
    218201    diff[k+2] = piOrg[2] - pred;
    219     pred      = ( (m_w0*piCur[3*iStep] + m_round) >> m_shift ) + m_offset ;
     202    pred      = ( (w0*piCur[3*iStep] + round) >> shift ) + offset ;
    220203    diff[k+3] = piOrg[3] - pred;
    221204
     
    223206    piOrg += iStrideOrg;
    224207  }
    225  
     208
    226209  /*===== hadamard transform =====*/
    227210  m[ 0] = diff[ 0] + diff[12];
     
    241224  m[14] = diff[ 2] - diff[14];
    242225  m[15] = diff[ 3] - diff[15];
    243  
     226
    244227  d[ 0] = m[ 0] + m[ 4];
    245228  d[ 1] = m[ 1] + m[ 5];
     
    258241  d[14] = m[14] - m[10];
    259242  d[15] = m[15] - m[11];
    260  
     243
    261244  m[ 0] = d[ 0] + d[ 3];
    262245  m[ 1] = d[ 1] + d[ 2];
     
    275258  m[14] = d[13] - d[14];
    276259  m[15] = d[12] - d[15];
    277  
     260
    278261  d[ 0] = m[ 0] + m[ 1];
    279262  d[ 1] = m[ 0] - m[ 1];
     
    292275  d[14] = m[14] + m[15];
    293276  d[15] = m[15] - m[14];
    294  
    295   for (k=0; k<16; ++k)
     277
     278  for (Int k=0; k<16; ++k)
    296279  {
    297280    satd += abs(d[k]);
    298281  }
    299282  satd = ((satd+1)>>1);
    300  
     283
    301284  return satd;
    302285}
    303286
    304 /** get weighted Hadamard cost for 8x8 block
    305  * \param *piOrg
    306  * \param *piCur
    307  * \param iStrideOrg
    308  * \param iStrideCur
    309  * \param iStep
    310  * \returns UInt
    311  */
    312 UInt TComRdCostWeightPrediction::xCalcHADs8x8w( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    313 {
    314   Int k, i, j, jj, sad=0;
    315   Int diff[64], m1[8][8], m2[8][8], m3[8][8];
     287
     288//! get weighted Hadamard cost for 8x8 block
     289Distortion xCalcHADs8x8w( const WPScalingParam &wpCur, const Pel *piOrg, const Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
     290{
     291  Distortion sad=0;
     292  TCoeff diff[64], m1[8][8], m2[8][8], m3[8][8];
    316293  Int iStep2 = iStep<<1;
    317294  Int iStep3 = iStep2 + iStep;
     
    320297  Int iStep6 = iStep5 + iStep;
    321298  Int iStep7 = iStep6 + iStep;
    322  
    323   assert( m_xSetDone );
     299  const Int round  = wpCur.round;
     300  const Int shift  = wpCur.shift;
     301  const Int offset = wpCur.offset;
     302  const Int w0     = wpCur.w;
     303
    324304  Pel   pred;
    325305
    326   for( k = 0; k < 64; k+=8 )
    327   {
    328     pred      = ( (m_w0*piCur[     0] + m_round) >> m_shift ) + m_offset ;
     306  for(Int k = 0; k < 64; k+=8 )
     307  {
     308    pred      = ( (w0*piCur[     0] + round) >> shift ) + offset ;
    329309    diff[k+0] = piOrg[0] - pred;
    330     pred      = ( (m_w0*piCur[iStep ] + m_round) >> m_shift ) + m_offset ;
     310    pred      = ( (w0*piCur[iStep ] + round) >> shift ) + offset ;
    331311    diff[k+1] = piOrg[1] - pred;
    332     pred      = ( (m_w0*piCur[iStep2] + m_round) >> m_shift ) + m_offset ;
     312    pred      = ( (w0*piCur[iStep2] + round) >> shift ) + offset ;
    333313    diff[k+2] = piOrg[2] - pred;
    334     pred      = ( (m_w0*piCur[iStep3] + m_round) >> m_shift ) + m_offset ;
     314    pred      = ( (w0*piCur[iStep3] + round) >> shift ) + offset ;
    335315    diff[k+3] = piOrg[3] - pred;
    336     pred      = ( (m_w0*piCur[iStep4] + m_round) >> m_shift ) + m_offset ;
     316    pred      = ( (w0*piCur[iStep4] + round) >> shift ) + offset ;
    337317    diff[k+4] = piOrg[4] - pred;
    338     pred      = ( (m_w0*piCur[iStep5] + m_round) >> m_shift ) + m_offset ;
     318    pred      = ( (w0*piCur[iStep5] + round) >> shift ) + offset ;
    339319    diff[k+5] = piOrg[5] - pred;
    340     pred      = ( (m_w0*piCur[iStep6] + m_round) >> m_shift ) + m_offset ;
     320    pred      = ( (w0*piCur[iStep6] + round) >> shift ) + offset ;
    341321    diff[k+6] = piOrg[6] - pred;
    342     pred      = ( (m_w0*piCur[iStep7] + m_round) >> m_shift ) + m_offset ;
     322    pred      = ( (w0*piCur[iStep7] + round) >> shift ) + offset ;
    343323    diff[k+7] = piOrg[7] - pred;
    344    
     324
    345325    piCur += iStrideCur;
    346326    piOrg += iStrideOrg;
    347327  }
    348  
     328
    349329  //horizontal
    350   for (j=0; j < 8; j++)
    351   {
    352     jj = j << 3;
     330  for (Int j=0; j < 8; j++)
     331  {
     332    const Int jj = j << 3;
    353333    m2[j][0] = diff[jj  ] + diff[jj+4];
    354334    m2[j][1] = diff[jj+1] + diff[jj+5];
     
    359339    m2[j][6] = diff[jj+2] - diff[jj+6];
    360340    m2[j][7] = diff[jj+3] - diff[jj+7];
    361    
     341
    362342    m1[j][0] = m2[j][0] + m2[j][2];
    363343    m1[j][1] = m2[j][1] + m2[j][3];
     
    368348    m1[j][6] = m2[j][4] - m2[j][6];
    369349    m1[j][7] = m2[j][5] - m2[j][7];
    370    
     350
    371351    m2[j][0] = m1[j][0] + m1[j][1];
    372352    m2[j][1] = m1[j][0] - m1[j][1];
     
    378358    m2[j][7] = m1[j][6] - m1[j][7];
    379359  }
    380  
     360
    381361  //vertical
    382   for (i=0; i < 8; i++)
     362  for (Int i=0; i < 8; i++)
    383363  {
    384364    m3[0][i] = m2[0][i] + m2[4][i];
     
    390370    m3[6][i] = m2[2][i] - m2[6][i];
    391371    m3[7][i] = m2[3][i] - m2[7][i];
    392    
     372
    393373    m1[0][i] = m3[0][i] + m3[2][i];
    394374    m1[1][i] = m3[1][i] + m3[3][i];
     
    399379    m1[6][i] = m3[4][i] - m3[6][i];
    400380    m1[7][i] = m3[5][i] - m3[7][i];
    401    
     381
    402382    m2[0][i] = m1[0][i] + m1[1][i];
    403383    m2[1][i] = m1[0][i] - m1[1][i];
     
    409389    m2[7][i] = m1[6][i] - m1[7][i];
    410390  }
    411  
    412   for (j=0; j < 8; j++)
    413   {
    414     for (i=0; i < 8; i++)
     391
     392  for (Int j=0; j < 8; j++)
     393  {
     394    for (Int i=0; i < 8; i++)
    415395    {
    416396      sad += (abs(m2[j][i]));
    417397    }
    418398  }
    419  
     399
    420400  sad=((sad+2)>>2);
    421  
     401
    422402  return sad;
    423403}
    424404
    425 /** get weighted Hadamard cost
    426  * \param *pcDtParam
    427  * \returns UInt
    428  */
    429 UInt TComRdCostWeightPrediction::xGetHADs4w( DistParam* pcDtParam )
    430 {
    431   Pel* piOrg   = pcDtParam->pOrg;
    432   Pel* piCur   = pcDtParam->pCur;
    433   Int  iRows   = pcDtParam->iRows;
    434   Int  iStrideCur = pcDtParam->iStrideCur;
    435   Int  iStrideOrg = pcDtParam->iStrideOrg;
    436   Int  iStep  = pcDtParam->iStep;
    437   Int  y;
    438   Int  iOffsetOrg = iStrideOrg<<2;
    439   Int  iOffsetCur = iStrideCur<<2;
    440  
    441   UInt uiSum = 0;
    442  
    443   for ( y=0; y<iRows; y+= 4 )
    444   {
    445     uiSum += xCalcHADs4x4w( piOrg, piCur, iStrideOrg, iStrideCur, iStep );
    446     piOrg += iOffsetOrg;
    447     piCur += iOffsetCur;
    448   }
    449  
    450   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    451 }
    452 
    453 /** get weighted Hadamard cost
    454  * \param *pcDtParam
    455  * \returns UInt
    456  */
    457 UInt TComRdCostWeightPrediction::xGetHADs8w( DistParam* pcDtParam )
    458 {
    459   Pel* piOrg   = pcDtParam->pOrg;
    460   Pel* piCur   = pcDtParam->pCur;
    461   Int  iRows   = pcDtParam->iRows;
    462   Int  iStrideCur = pcDtParam->iStrideCur;
    463   Int  iStrideOrg = pcDtParam->iStrideOrg;
    464   Int  iStep  = pcDtParam->iStep;
    465   Int  y;
    466  
    467   UInt uiSum = 0;
    468  
    469   if ( iRows == 4 )
    470   {
    471     uiSum += xCalcHADs4x4w( piOrg+0, piCur        , iStrideOrg, iStrideCur, iStep );
    472     uiSum += xCalcHADs4x4w( piOrg+4, piCur+4*iStep, iStrideOrg, iStrideCur, iStep );
    473   }
    474   else
    475   {
    476     Int  iOffsetOrg = iStrideOrg<<3;
    477     Int  iOffsetCur = iStrideCur<<3;
    478     for ( y=0; y<iRows; y+= 8 )
    479     {
    480       uiSum += xCalcHADs8x8w( piOrg, piCur, iStrideOrg, iStrideCur, iStep );
    481       piOrg += iOffsetOrg;
    482       piCur += iOffsetCur;
    483     }
    484   }
    485  
    486   return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
    487 }
    488 
    489 /** get weighted Hadamard cost
    490  * \param *pcDtParam
    491  * \returns UInt
    492  */
    493 UInt TComRdCostWeightPrediction::xGetHADsw( DistParam* pcDtParam )
    494 {
    495   Pel* piOrg   = pcDtParam->pOrg;
    496   Pel* piCur   = pcDtParam->pCur;
    497   Int  iRows   = pcDtParam->iRows;
    498   Int  iCols   = pcDtParam->iCols;
    499   Int  iStrideCur = pcDtParam->iStrideCur;
    500   Int  iStrideOrg = pcDtParam->iStrideOrg;
    501   Int  iStep  = pcDtParam->iStep;
    502  
    503   Int  x, y;
    504  
    505   UInt            uiComp    = pcDtParam->uiComp;
    506   assert(uiComp<3);
    507   wpScalingParam  *wpCur    = &(pcDtParam->wpCur[uiComp]);
    508 
    509   xSetWPscale(wpCur->w, 0, wpCur->shift, wpCur->offset, wpCur->round);
    510 
    511   UInt uiSum = 0;
    512  
     405
     406//! get weighted Hadamard cost
     407Distortion TComRdCostWeightPrediction::xGetHADsw( DistParam* pcDtParam )
     408{
     409  const Pel        *piOrg      = pcDtParam->pOrg;
     410  const Pel        *piCur      = pcDtParam->pCur;
     411  const Int         iRows      = pcDtParam->iRows;
     412  const Int         iCols      = pcDtParam->iCols;
     413  const Int         iStrideCur = pcDtParam->iStrideCur;
     414  const Int         iStrideOrg = pcDtParam->iStrideOrg;
     415  const Int         iStep      = pcDtParam->iStep;
     416  const ComponentID compIdx    = pcDtParam->compIdx;
     417  assert(compIdx<MAX_NUM_COMPONENT);
     418  const WPScalingParam  wpCur    = pcDtParam->wpCur[compIdx];
     419
     420  Distortion uiSum = 0;
     421
    513422  if( ( iRows % 8 == 0) && (iCols % 8 == 0) )
    514423  {
    515     Int iOffsetOrg = iStrideOrg<<3;
    516     Int iOffsetCur = iStrideCur<<3;
    517     for ( y=0; y<iRows; y+= 8 )
    518     {
    519       for ( x=0; x<iCols; x+= 8 )
     424    const Int iOffsetOrg = iStrideOrg<<3;
     425    const Int iOffsetCur = iStrideCur<<3;
     426    for (Int y=0; y<iRows; y+= 8 )
     427    {
     428      for (Int x=0; x<iCols; x+= 8 )
    520429      {
    521         uiSum += xCalcHADs8x8w( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
     430        uiSum += xCalcHADs8x8w( wpCur, &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    522431      }
    523432      piOrg += iOffsetOrg;
     
    527436  else if( ( iRows % 4 == 0) && (iCols % 4 == 0) )
    528437  {
    529     Int iOffsetOrg = iStrideOrg<<2;
    530     Int iOffsetCur = iStrideCur<<2;
    531    
    532     for ( y=0; y<iRows; y+= 4 )
    533     {
    534       for ( x=0; x<iCols; x+= 4 )
     438    const Int iOffsetOrg = iStrideOrg<<2;
     439    const Int iOffsetCur = iStrideCur<<2;
     440
     441    for (Int y=0; y<iRows; y+= 4 )
     442    {
     443      for (Int x=0; x<iCols; x+= 4 )
    535444      {
    536         uiSum += xCalcHADs4x4w( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
     445        uiSum += xCalcHADs4x4w( wpCur, &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    537446      }
    538447      piOrg += iOffsetOrg;
     
    542451  else
    543452  {
    544     for ( y=0; y<iRows; y+=2 )
    545     {
    546       for ( x=0; x<iCols; x+=2 )
     453    for (Int y=0; y<iRows; y+=2 )
     454    {
     455      for (Int x=0; x<iCols; x+=2 )
    547456      {
    548         uiSum += xCalcHADs2x2w( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
     457        uiSum += xCalcHADs2x2w( wpCur, &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    549458      }
    550459      piOrg += iStrideOrg;
     
    552461    }
    553462  }
    554  
    555   m_xSetDone  = false;
    556463
    557464  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
Note: See TracChangeset for help on using the changeset viewer.