[191] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file TComRdCost.cpp |
---|
| 35 | \brief RD cost computation class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include <math.h> |
---|
| 39 | #include <assert.h> |
---|
| 40 | #include "TComRom.h" |
---|
| 41 | #include "TComRdCost.h" |
---|
| 42 | |
---|
| 43 | //! \ingroup TLibCommon |
---|
| 44 | //! \{ |
---|
| 45 | |
---|
| 46 | TComRdCost::TComRdCost() |
---|
| 47 | { |
---|
| 48 | init(); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | TComRdCost::~TComRdCost() |
---|
| 52 | { |
---|
| 53 | #if !FIX203 |
---|
| 54 | xUninit(); |
---|
| 55 | #endif |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | // Calculate RD functions |
---|
| 59 | Double TComRdCost::calcRdCost( UInt uiBits, UInt uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
| 60 | { |
---|
| 61 | Double dRdCost = 0.0; |
---|
| 62 | Double dLambda = 0.0; |
---|
| 63 | |
---|
| 64 | switch ( eDFunc ) |
---|
| 65 | { |
---|
| 66 | case DF_SSE: |
---|
| 67 | assert(0); |
---|
| 68 | break; |
---|
| 69 | case DF_SAD: |
---|
| 70 | dLambda = (Double)m_uiLambdaMotionSAD; |
---|
| 71 | break; |
---|
| 72 | case DF_DEFAULT: |
---|
| 73 | dLambda = m_dLambda; |
---|
| 74 | break; |
---|
| 75 | case DF_SSE_FRAME: |
---|
| 76 | dLambda = m_dFrameLambda; |
---|
| 77 | break; |
---|
| 78 | default: |
---|
| 79 | assert (0); |
---|
| 80 | break; |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | if (bFlag) |
---|
| 84 | { |
---|
| 85 | // Intra8x8, Intra4x4 Block only... |
---|
| 86 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
| 87 | dRdCost = (Double)(uiBits); |
---|
| 88 | #else |
---|
| 89 | dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda)); |
---|
| 90 | #endif |
---|
| 91 | } |
---|
| 92 | else |
---|
| 93 | { |
---|
| 94 | if (eDFunc == DF_SAD) |
---|
| 95 | { |
---|
| 96 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16)); |
---|
| 97 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
| 98 | } |
---|
| 99 | else |
---|
| 100 | { |
---|
| 101 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
| 102 | dRdCost = (Double)(uiBits); |
---|
| 103 | #else |
---|
| 104 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5))); |
---|
| 105 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
| 106 | #endif |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | return dRdCost; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
| 114 | { |
---|
| 115 | Double dRdCost = 0.0; |
---|
| 116 | Double dLambda = 0.0; |
---|
| 117 | |
---|
| 118 | switch ( eDFunc ) |
---|
| 119 | { |
---|
| 120 | case DF_SSE: |
---|
| 121 | assert(0); |
---|
| 122 | break; |
---|
| 123 | case DF_SAD: |
---|
| 124 | dLambda = (Double)m_uiLambdaMotionSAD; |
---|
| 125 | break; |
---|
| 126 | case DF_DEFAULT: |
---|
| 127 | dLambda = m_dLambda; |
---|
| 128 | break; |
---|
| 129 | case DF_SSE_FRAME: |
---|
| 130 | dLambda = m_dFrameLambda; |
---|
| 131 | break; |
---|
| 132 | default: |
---|
| 133 | assert (0); |
---|
| 134 | break; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | if (bFlag) |
---|
| 138 | { |
---|
| 139 | // Intra8x8, Intra4x4 Block only... |
---|
| 140 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
| 141 | dRdCost = (Double)(uiBits); |
---|
| 142 | #else |
---|
| 143 | dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda)); |
---|
| 144 | #endif |
---|
| 145 | } |
---|
| 146 | else |
---|
| 147 | { |
---|
| 148 | if (eDFunc == DF_SAD) |
---|
| 149 | { |
---|
| 150 | dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5)>>16)); |
---|
| 151 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
| 152 | } |
---|
| 153 | else |
---|
| 154 | { |
---|
| 155 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
| 156 | dRdCost = (Double)(uiBits); |
---|
| 157 | #else |
---|
| 158 | dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5))); |
---|
| 159 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
| 160 | #endif |
---|
| 161 | } |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | return dRdCost; |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | Void TComRdCost::setLambda( Double dLambda ) |
---|
| 168 | { |
---|
| 169 | m_dLambda = dLambda; |
---|
| 170 | m_sqrtLambda = sqrt(m_dLambda); |
---|
| 171 | m_uiLambdaMotionSAD = (UInt)floor(65536.0 * m_sqrtLambda); |
---|
| 172 | m_uiLambdaMotionSSE = (UInt)floor(65536.0 * m_dLambda ); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | // Initalize Function Pointer by [eDFunc] |
---|
| 177 | Void TComRdCost::init() |
---|
| 178 | { |
---|
| 179 | m_afpDistortFunc[0] = NULL; // for DF_DEFAULT |
---|
| 180 | |
---|
| 181 | m_afpDistortFunc[1] = TComRdCost::xGetSSE; |
---|
| 182 | m_afpDistortFunc[2] = TComRdCost::xGetSSE4; |
---|
| 183 | m_afpDistortFunc[3] = TComRdCost::xGetSSE8; |
---|
| 184 | m_afpDistortFunc[4] = TComRdCost::xGetSSE16; |
---|
| 185 | m_afpDistortFunc[5] = TComRdCost::xGetSSE32; |
---|
| 186 | m_afpDistortFunc[6] = TComRdCost::xGetSSE64; |
---|
| 187 | m_afpDistortFunc[7] = TComRdCost::xGetSSE16N; |
---|
| 188 | |
---|
| 189 | m_afpDistortFunc[8] = TComRdCost::xGetSAD; |
---|
| 190 | m_afpDistortFunc[9] = TComRdCost::xGetSAD4; |
---|
| 191 | m_afpDistortFunc[10] = TComRdCost::xGetSAD8; |
---|
| 192 | m_afpDistortFunc[11] = TComRdCost::xGetSAD16; |
---|
| 193 | m_afpDistortFunc[12] = TComRdCost::xGetSAD32; |
---|
| 194 | m_afpDistortFunc[13] = TComRdCost::xGetSAD64; |
---|
| 195 | m_afpDistortFunc[14] = TComRdCost::xGetSAD16N; |
---|
| 196 | |
---|
| 197 | m_afpDistortFunc[15] = TComRdCost::xGetSAD; |
---|
| 198 | m_afpDistortFunc[16] = TComRdCost::xGetSAD4; |
---|
| 199 | m_afpDistortFunc[17] = TComRdCost::xGetSAD8; |
---|
| 200 | m_afpDistortFunc[18] = TComRdCost::xGetSAD16; |
---|
| 201 | m_afpDistortFunc[19] = TComRdCost::xGetSAD32; |
---|
| 202 | m_afpDistortFunc[20] = TComRdCost::xGetSAD64; |
---|
| 203 | m_afpDistortFunc[21] = TComRdCost::xGetSAD16N; |
---|
| 204 | |
---|
| 205 | #if AMP_SAD |
---|
| 206 | m_afpDistortFunc[43] = TComRdCost::xGetSAD12; |
---|
| 207 | m_afpDistortFunc[44] = TComRdCost::xGetSAD24; |
---|
| 208 | m_afpDistortFunc[45] = TComRdCost::xGetSAD48; |
---|
| 209 | |
---|
| 210 | m_afpDistortFunc[46] = TComRdCost::xGetSAD12; |
---|
| 211 | m_afpDistortFunc[47] = TComRdCost::xGetSAD24; |
---|
| 212 | m_afpDistortFunc[48] = TComRdCost::xGetSAD48; |
---|
| 213 | #endif |
---|
| 214 | m_afpDistortFunc[22] = TComRdCost::xGetHADs; |
---|
| 215 | m_afpDistortFunc[23] = TComRdCost::xGetHADs; |
---|
| 216 | m_afpDistortFunc[24] = TComRdCost::xGetHADs; |
---|
| 217 | m_afpDistortFunc[25] = TComRdCost::xGetHADs; |
---|
| 218 | m_afpDistortFunc[26] = TComRdCost::xGetHADs; |
---|
| 219 | m_afpDistortFunc[27] = TComRdCost::xGetHADs; |
---|
| 220 | m_afpDistortFunc[28] = TComRdCost::xGetHADs; |
---|
| 221 | |
---|
| 222 | #if !FIX203 |
---|
| 223 | m_puiComponentCostOriginP = NULL; |
---|
| 224 | m_puiComponentCost = NULL; |
---|
| 225 | m_puiVerCost = NULL; |
---|
| 226 | m_puiHorCost = NULL; |
---|
| 227 | #endif |
---|
| 228 | m_uiCost = 0; |
---|
| 229 | m_iCostScale = 0; |
---|
| 230 | #if !FIX203 |
---|
| 231 | m_iSearchLimit = 0xdeaddead; |
---|
| 232 | #endif |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | #if !FIX203 |
---|
| 236 | Void TComRdCost::initRateDistortionModel( Int iSubPelSearchLimit ) |
---|
| 237 | { |
---|
| 238 | // make it larger |
---|
| 239 | iSubPelSearchLimit += 4; |
---|
| 240 | iSubPelSearchLimit *= 8; |
---|
| 241 | |
---|
| 242 | if( m_iSearchLimit != iSubPelSearchLimit ) |
---|
| 243 | { |
---|
| 244 | xUninit(); |
---|
| 245 | |
---|
| 246 | m_iSearchLimit = iSubPelSearchLimit; |
---|
| 247 | |
---|
| 248 | m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ]; |
---|
| 249 | iSubPelSearchLimit *= 2; |
---|
| 250 | |
---|
| 251 | m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit; |
---|
| 252 | |
---|
| 253 | for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++) |
---|
| 254 | { |
---|
| 255 | m_puiComponentCost[n] = xGetComponentBits( n ); |
---|
| 256 | } |
---|
| 257 | } |
---|
| 258 | } |
---|
| 259 | |
---|
| 260 | Void TComRdCost::xUninit() |
---|
| 261 | { |
---|
| 262 | if( NULL != m_puiComponentCostOriginP ) |
---|
| 263 | { |
---|
| 264 | delete [] m_puiComponentCostOriginP; |
---|
| 265 | m_puiComponentCostOriginP = NULL; |
---|
| 266 | } |
---|
| 267 | } |
---|
| 268 | #endif |
---|
| 269 | |
---|
| 270 | UInt TComRdCost::xGetComponentBits( Int iVal ) |
---|
| 271 | { |
---|
| 272 | UInt uiLength = 1; |
---|
| 273 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
| 274 | |
---|
| 275 | assert ( uiTemp ); |
---|
| 276 | |
---|
| 277 | while ( 1 != uiTemp ) |
---|
| 278 | { |
---|
| 279 | uiTemp >>= 1; |
---|
| 280 | uiLength += 2; |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | return uiLength; |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | Void TComRdCost::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam ) |
---|
| 287 | { |
---|
| 288 | // set Block Width / Height |
---|
| 289 | rcDistParam.iCols = uiBlkWidth; |
---|
| 290 | rcDistParam.iRows = uiBlkHeight; |
---|
| 291 | rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
| 292 | |
---|
| 293 | // initialize |
---|
| 294 | rcDistParam.iSubShift = 0; |
---|
| 295 | } |
---|
| 296 | |
---|
| 297 | // Setting the Distortion Parameter for Inter (ME) |
---|
| 298 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam ) |
---|
| 299 | { |
---|
| 300 | // set Original & Curr Pointer / Stride |
---|
| 301 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
| 302 | rcDistParam.pCur = piRefY; |
---|
| 303 | |
---|
| 304 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
| 305 | rcDistParam.iStrideCur = iRefStride; |
---|
| 306 | |
---|
| 307 | // set Block Width / Height |
---|
| 308 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
| 309 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
| 310 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
| 311 | |
---|
| 312 | #if AMP_SAD |
---|
| 313 | if (rcDistParam.iCols == 12) |
---|
| 314 | { |
---|
| 315 | rcDistParam.DistFunc = m_afpDistortFunc[43 ]; |
---|
| 316 | } |
---|
| 317 | else if (rcDistParam.iCols == 24) |
---|
| 318 | { |
---|
| 319 | rcDistParam.DistFunc = m_afpDistortFunc[44 ]; |
---|
| 320 | } |
---|
| 321 | else if (rcDistParam.iCols == 48) |
---|
| 322 | { |
---|
| 323 | rcDistParam.DistFunc = m_afpDistortFunc[45 ]; |
---|
| 324 | } |
---|
| 325 | #endif |
---|
| 326 | |
---|
| 327 | // initialize |
---|
| 328 | rcDistParam.iSubShift = 0; |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | // Setting the Distortion Parameter for Inter (subpel ME with step) |
---|
| 332 | #if NS_HAD |
---|
| 333 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME, Bool bUseNSHAD ) |
---|
| 334 | #else |
---|
| 335 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME ) |
---|
| 336 | #endif |
---|
| 337 | { |
---|
| 338 | // set Original & Curr Pointer / Stride |
---|
| 339 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
| 340 | rcDistParam.pCur = piRefY; |
---|
| 341 | |
---|
| 342 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
| 343 | rcDistParam.iStrideCur = iRefStride * iStep; |
---|
| 344 | |
---|
| 345 | // set Step for interpolated buffer |
---|
| 346 | rcDistParam.iStep = iStep; |
---|
| 347 | |
---|
| 348 | // set Block Width / Height |
---|
| 349 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
| 350 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
| 351 | #if NS_HAD |
---|
| 352 | rcDistParam.bUseNSHAD = bUseNSHAD; |
---|
| 353 | #endif |
---|
| 354 | |
---|
| 355 | // set distortion function |
---|
| 356 | if ( !bHADME ) |
---|
| 357 | { |
---|
| 358 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
| 359 | #if AMP_SAD |
---|
| 360 | if (rcDistParam.iCols == 12) |
---|
| 361 | { |
---|
| 362 | rcDistParam.DistFunc = m_afpDistortFunc[46 ]; |
---|
| 363 | } |
---|
| 364 | else if (rcDistParam.iCols == 24) |
---|
| 365 | { |
---|
| 366 | rcDistParam.DistFunc = m_afpDistortFunc[47 ]; |
---|
| 367 | } |
---|
| 368 | else if (rcDistParam.iCols == 48) |
---|
| 369 | { |
---|
| 370 | rcDistParam.DistFunc = m_afpDistortFunc[48 ]; |
---|
| 371 | } |
---|
| 372 | #endif |
---|
| 373 | } |
---|
| 374 | else |
---|
| 375 | { |
---|
| 376 | rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | // initialize |
---|
| 380 | rcDistParam.iSubShift = 0; |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | Void |
---|
| 384 | #if NS_HAD |
---|
| 385 | TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard, Bool bUseNSHAD ) |
---|
| 386 | #else |
---|
| 387 | TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard ) |
---|
| 388 | #endif |
---|
| 389 | { |
---|
| 390 | rcDP.pOrg = p1; |
---|
| 391 | rcDP.pCur = p2; |
---|
| 392 | rcDP.iStrideOrg = iStride1; |
---|
| 393 | rcDP.iStrideCur = iStride2; |
---|
| 394 | rcDP.iCols = iWidth; |
---|
| 395 | rcDP.iRows = iHeight; |
---|
| 396 | rcDP.iStep = 1; |
---|
| 397 | rcDP.iSubShift = 0; |
---|
| 398 | rcDP.bitDepth = bitDepth; |
---|
| 399 | rcDP.DistFunc = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ]; |
---|
| 400 | #if NS_HAD |
---|
| 401 | rcDP.bUseNSHAD = bUseNSHAD; |
---|
| 402 | #endif |
---|
| 403 | } |
---|
| 404 | |
---|
| 405 | UInt TComRdCost::calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight ) |
---|
| 406 | { |
---|
| 407 | UInt uiSum = 0; |
---|
| 408 | Int x, y; |
---|
| 409 | |
---|
| 410 | if ( ( (iWidth % 8) == 0 ) && ( (iHeight % 8) == 0 ) ) |
---|
| 411 | { |
---|
| 412 | for ( y=0; y<iHeight; y+= 8 ) |
---|
| 413 | { |
---|
| 414 | for ( x=0; x<iWidth; x+= 8 ) |
---|
| 415 | { |
---|
| 416 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
| 417 | } |
---|
| 418 | pi0 += iStride0*8; |
---|
| 419 | pi1 += iStride1*8; |
---|
| 420 | } |
---|
| 421 | } |
---|
| 422 | else if ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) ) |
---|
| 423 | { |
---|
| 424 | for ( y=0; y<iHeight; y+= 4 ) |
---|
| 425 | { |
---|
| 426 | for ( x=0; x<iWidth; x+= 4 ) |
---|
| 427 | { |
---|
| 428 | uiSum += xCalcHADs4x4( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
| 429 | } |
---|
| 430 | pi0 += iStride0*4; |
---|
| 431 | pi1 += iStride1*4; |
---|
| 432 | } |
---|
| 433 | } |
---|
| 434 | else |
---|
| 435 | { |
---|
| 436 | for ( y=0; y<iHeight; y+= 2 ) |
---|
| 437 | { |
---|
| 438 | for ( x=0; x<iWidth; x+= 2 ) |
---|
| 439 | { |
---|
| 440 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
| 441 | } |
---|
| 442 | pi0 += iStride0*2; |
---|
| 443 | pi1 += iStride1*2; |
---|
| 444 | } |
---|
| 445 | } |
---|
| 446 | |
---|
| 447 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); |
---|
| 448 | |
---|
| 449 | } |
---|
| 450 | |
---|
| 451 | #if WEIGHTED_CHROMA_DISTORTION |
---|
| 452 | UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText, DFunc eDFunc) |
---|
| 453 | #else |
---|
| 454 | UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc ) |
---|
| 455 | #endif |
---|
| 456 | { |
---|
| 457 | DistParam cDtParam; |
---|
| 458 | setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam ); |
---|
| 459 | cDtParam.pOrg = piOrg; |
---|
| 460 | cDtParam.pCur = piCur; |
---|
| 461 | cDtParam.iStrideOrg = iOrgStride; |
---|
| 462 | cDtParam.iStrideCur = iCurStride; |
---|
| 463 | cDtParam.iStep = 1; |
---|
| 464 | |
---|
| 465 | cDtParam.bApplyWeight = false; |
---|
| 466 | cDtParam.uiComp = 255; // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed. |
---|
| 467 | cDtParam.bitDepth = bitDepth; |
---|
| 468 | |
---|
| 469 | #if WEIGHTED_CHROMA_DISTORTION |
---|
| 470 | if (eText == TEXT_CHROMA_U) |
---|
| 471 | { |
---|
| 472 | return ((Int) (m_cbDistortionWeight * cDtParam.DistFunc( &cDtParam ))); |
---|
| 473 | } |
---|
| 474 | else if (eText == TEXT_CHROMA_V) |
---|
| 475 | { |
---|
| 476 | return ((Int) (m_crDistortionWeight * cDtParam.DistFunc( &cDtParam ))); |
---|
| 477 | } |
---|
| 478 | else |
---|
| 479 | { |
---|
| 480 | return cDtParam.DistFunc( &cDtParam ); |
---|
| 481 | } |
---|
| 482 | #else |
---|
| 483 | return cDtParam.DistFunc( &cDtParam ); |
---|
| 484 | #endif |
---|
| 485 | } |
---|
| 486 | |
---|
| 487 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
| 488 | UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride, Pel* pelOrg, Int orgStride, UInt width, UInt height ) |
---|
| 489 | { |
---|
| 490 | UInt SAD = 0; |
---|
| 491 | Int shift = DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); |
---|
| 492 | for ( Int i=0; i<height; i++ ) |
---|
| 493 | { |
---|
| 494 | for( Int j=0; j<width; j++ ) |
---|
| 495 | { |
---|
| 496 | SAD += abs((pelCur[j] - pelOrg[j])) >> shift; |
---|
| 497 | } |
---|
| 498 | pelCur = pelCur + curStride; |
---|
| 499 | pelOrg = pelOrg + orgStride; |
---|
| 500 | } |
---|
| 501 | return SAD; |
---|
| 502 | } |
---|
| 503 | #endif |
---|
| 504 | |
---|
| 505 | // ==================================================================================================================== |
---|
| 506 | // Distortion functions |
---|
| 507 | // ==================================================================================================================== |
---|
| 508 | |
---|
| 509 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 510 | // SAD |
---|
| 511 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 512 | |
---|
| 513 | UInt TComRdCost::xGetSAD( DistParam* pcDtParam ) |
---|
| 514 | { |
---|
| 515 | if ( pcDtParam->bApplyWeight ) |
---|
| 516 | { |
---|
| 517 | return xGetSADw( pcDtParam ); |
---|
| 518 | } |
---|
| 519 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 520 | Pel* piCur = pcDtParam->pCur; |
---|
| 521 | Int iRows = pcDtParam->iRows; |
---|
| 522 | Int iCols = pcDtParam->iCols; |
---|
| 523 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 524 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 525 | |
---|
| 526 | UInt uiSum = 0; |
---|
| 527 | |
---|
| 528 | for( ; iRows != 0; iRows-- ) |
---|
| 529 | { |
---|
| 530 | for (Int n = 0; n < iCols; n++ ) |
---|
| 531 | { |
---|
| 532 | uiSum += abs( piOrg[n] - piCur[n] ); |
---|
| 533 | } |
---|
| 534 | piOrg += iStrideOrg; |
---|
| 535 | piCur += iStrideCur; |
---|
| 536 | } |
---|
| 537 | |
---|
| 538 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | UInt TComRdCost::xGetSAD4( DistParam* pcDtParam ) |
---|
| 542 | { |
---|
| 543 | if ( pcDtParam->bApplyWeight ) |
---|
| 544 | { |
---|
| 545 | return xGetSADw( pcDtParam ); |
---|
| 546 | } |
---|
| 547 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 548 | Pel* piCur = pcDtParam->pCur; |
---|
| 549 | Int iRows = pcDtParam->iRows; |
---|
| 550 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 551 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 552 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 553 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 554 | |
---|
| 555 | UInt uiSum = 0; |
---|
| 556 | |
---|
| 557 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 558 | { |
---|
| 559 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 560 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 561 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 562 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 563 | |
---|
| 564 | piOrg += iStrideOrg; |
---|
| 565 | piCur += iStrideCur; |
---|
| 566 | } |
---|
| 567 | |
---|
| 568 | uiSum <<= iSubShift; |
---|
| 569 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 570 | } |
---|
| 571 | |
---|
| 572 | UInt TComRdCost::xGetSAD8( DistParam* pcDtParam ) |
---|
| 573 | { |
---|
| 574 | if ( pcDtParam->bApplyWeight ) |
---|
| 575 | { |
---|
| 576 | return xGetSADw( pcDtParam ); |
---|
| 577 | } |
---|
| 578 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 579 | Pel* piCur = pcDtParam->pCur; |
---|
| 580 | Int iRows = pcDtParam->iRows; |
---|
| 581 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 582 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 583 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 584 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 585 | |
---|
| 586 | UInt uiSum = 0; |
---|
| 587 | |
---|
| 588 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 589 | { |
---|
| 590 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 591 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 592 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 593 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 594 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 595 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 596 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 597 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 598 | |
---|
| 599 | piOrg += iStrideOrg; |
---|
| 600 | piCur += iStrideCur; |
---|
| 601 | } |
---|
| 602 | |
---|
| 603 | uiSum <<= iSubShift; |
---|
| 604 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 605 | } |
---|
| 606 | |
---|
| 607 | UInt TComRdCost::xGetSAD16( DistParam* pcDtParam ) |
---|
| 608 | { |
---|
| 609 | if ( pcDtParam->bApplyWeight ) |
---|
| 610 | { |
---|
| 611 | return xGetSADw( pcDtParam ); |
---|
| 612 | } |
---|
| 613 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 614 | Pel* piCur = pcDtParam->pCur; |
---|
| 615 | Int iRows = pcDtParam->iRows; |
---|
| 616 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 617 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 618 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 619 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 620 | |
---|
| 621 | UInt uiSum = 0; |
---|
| 622 | |
---|
| 623 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 624 | { |
---|
| 625 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 626 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 627 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 628 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 629 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 630 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 631 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 632 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 633 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 634 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 635 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 636 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 637 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 638 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 639 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 640 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 641 | |
---|
| 642 | piOrg += iStrideOrg; |
---|
| 643 | piCur += iStrideCur; |
---|
| 644 | } |
---|
| 645 | |
---|
| 646 | uiSum <<= iSubShift; |
---|
| 647 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 648 | } |
---|
| 649 | |
---|
| 650 | #if AMP_SAD |
---|
| 651 | UInt TComRdCost::xGetSAD12( DistParam* pcDtParam ) |
---|
| 652 | { |
---|
| 653 | if ( pcDtParam->bApplyWeight ) |
---|
| 654 | { |
---|
| 655 | return xGetSADw( pcDtParam ); |
---|
| 656 | } |
---|
| 657 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 658 | Pel* piCur = pcDtParam->pCur; |
---|
| 659 | Int iRows = pcDtParam->iRows; |
---|
| 660 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 661 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 662 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 663 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 664 | |
---|
| 665 | UInt uiSum = 0; |
---|
| 666 | |
---|
| 667 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 668 | { |
---|
| 669 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 670 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 671 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 672 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 673 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 674 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 675 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 676 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 677 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 678 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 679 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 680 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 681 | |
---|
| 682 | piOrg += iStrideOrg; |
---|
| 683 | piCur += iStrideCur; |
---|
| 684 | } |
---|
| 685 | |
---|
| 686 | uiSum <<= iSubShift; |
---|
| 687 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 688 | } |
---|
| 689 | #endif |
---|
| 690 | |
---|
| 691 | UInt TComRdCost::xGetSAD16N( DistParam* pcDtParam ) |
---|
| 692 | { |
---|
| 693 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 694 | Pel* piCur = pcDtParam->pCur; |
---|
| 695 | Int iRows = pcDtParam->iRows; |
---|
| 696 | Int iCols = pcDtParam->iCols; |
---|
| 697 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 698 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 699 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 700 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 701 | |
---|
| 702 | UInt uiSum = 0; |
---|
| 703 | |
---|
| 704 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 705 | { |
---|
| 706 | for (Int n = 0; n < iCols; n+=16 ) |
---|
| 707 | { |
---|
| 708 | uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] ); |
---|
| 709 | uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] ); |
---|
| 710 | uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] ); |
---|
| 711 | uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] ); |
---|
| 712 | uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] ); |
---|
| 713 | uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] ); |
---|
| 714 | uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] ); |
---|
| 715 | uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] ); |
---|
| 716 | uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] ); |
---|
| 717 | uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] ); |
---|
| 718 | uiSum += abs( piOrg[n+10] - piCur[n+10] ); |
---|
| 719 | uiSum += abs( piOrg[n+11] - piCur[n+11] ); |
---|
| 720 | uiSum += abs( piOrg[n+12] - piCur[n+12] ); |
---|
| 721 | uiSum += abs( piOrg[n+13] - piCur[n+13] ); |
---|
| 722 | uiSum += abs( piOrg[n+14] - piCur[n+14] ); |
---|
| 723 | uiSum += abs( piOrg[n+15] - piCur[n+15] ); |
---|
| 724 | } |
---|
| 725 | piOrg += iStrideOrg; |
---|
| 726 | piCur += iStrideCur; |
---|
| 727 | } |
---|
| 728 | |
---|
| 729 | uiSum <<= iSubShift; |
---|
| 730 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 731 | } |
---|
| 732 | |
---|
| 733 | UInt TComRdCost::xGetSAD32( DistParam* pcDtParam ) |
---|
| 734 | { |
---|
| 735 | if ( pcDtParam->bApplyWeight ) |
---|
| 736 | { |
---|
| 737 | return xGetSADw( pcDtParam ); |
---|
| 738 | } |
---|
| 739 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 740 | Pel* piCur = pcDtParam->pCur; |
---|
| 741 | Int iRows = pcDtParam->iRows; |
---|
| 742 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 743 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 744 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 745 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 746 | |
---|
| 747 | UInt uiSum = 0; |
---|
| 748 | |
---|
| 749 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 750 | { |
---|
| 751 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 752 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 753 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 754 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 755 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 756 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 757 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 758 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 759 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 760 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 761 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 762 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 763 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 764 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 765 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 766 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 767 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 768 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 769 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 770 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 771 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 772 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 773 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 774 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 775 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
| 776 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
| 777 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
| 778 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
| 779 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
| 780 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
| 781 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
| 782 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
| 783 | |
---|
| 784 | piOrg += iStrideOrg; |
---|
| 785 | piCur += iStrideCur; |
---|
| 786 | } |
---|
| 787 | |
---|
| 788 | uiSum <<= iSubShift; |
---|
| 789 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 790 | } |
---|
| 791 | |
---|
| 792 | #if AMP_SAD |
---|
| 793 | UInt TComRdCost::xGetSAD24( DistParam* pcDtParam ) |
---|
| 794 | { |
---|
| 795 | if ( pcDtParam->bApplyWeight ) |
---|
| 796 | { |
---|
| 797 | return xGetSADw( pcDtParam ); |
---|
| 798 | } |
---|
| 799 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 800 | Pel* piCur = pcDtParam->pCur; |
---|
| 801 | Int iRows = pcDtParam->iRows; |
---|
| 802 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 803 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 804 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 805 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 806 | |
---|
| 807 | UInt uiSum = 0; |
---|
| 808 | |
---|
| 809 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 810 | { |
---|
| 811 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 812 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 813 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 814 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 815 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 816 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 817 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 818 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 819 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 820 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 821 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 822 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 823 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 824 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 825 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 826 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 827 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 828 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 829 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 830 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 831 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 832 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 833 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 834 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 835 | |
---|
| 836 | piOrg += iStrideOrg; |
---|
| 837 | piCur += iStrideCur; |
---|
| 838 | } |
---|
| 839 | |
---|
| 840 | uiSum <<= iSubShift; |
---|
| 841 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 842 | } |
---|
| 843 | |
---|
| 844 | #endif |
---|
| 845 | |
---|
| 846 | UInt TComRdCost::xGetSAD64( DistParam* pcDtParam ) |
---|
| 847 | { |
---|
| 848 | if ( pcDtParam->bApplyWeight ) |
---|
| 849 | { |
---|
| 850 | return xGetSADw( pcDtParam ); |
---|
| 851 | } |
---|
| 852 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 853 | Pel* piCur = pcDtParam->pCur; |
---|
| 854 | Int iRows = pcDtParam->iRows; |
---|
| 855 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 856 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 857 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 858 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 859 | |
---|
| 860 | UInt uiSum = 0; |
---|
| 861 | |
---|
| 862 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 863 | { |
---|
| 864 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 865 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 866 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 867 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 868 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 869 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 870 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 871 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 872 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 873 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 874 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 875 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 876 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 877 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 878 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 879 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 880 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 881 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 882 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 883 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 884 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 885 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 886 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 887 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 888 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
| 889 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
| 890 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
| 891 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
| 892 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
| 893 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
| 894 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
| 895 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
| 896 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
| 897 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
| 898 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
| 899 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
| 900 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
| 901 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
| 902 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
| 903 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
| 904 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
| 905 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
| 906 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
| 907 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
| 908 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
| 909 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
| 910 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
| 911 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
| 912 | uiSum += abs( piOrg[48] - piCur[48] ); |
---|
| 913 | uiSum += abs( piOrg[49] - piCur[49] ); |
---|
| 914 | uiSum += abs( piOrg[50] - piCur[50] ); |
---|
| 915 | uiSum += abs( piOrg[51] - piCur[51] ); |
---|
| 916 | uiSum += abs( piOrg[52] - piCur[52] ); |
---|
| 917 | uiSum += abs( piOrg[53] - piCur[53] ); |
---|
| 918 | uiSum += abs( piOrg[54] - piCur[54] ); |
---|
| 919 | uiSum += abs( piOrg[55] - piCur[55] ); |
---|
| 920 | uiSum += abs( piOrg[56] - piCur[56] ); |
---|
| 921 | uiSum += abs( piOrg[57] - piCur[57] ); |
---|
| 922 | uiSum += abs( piOrg[58] - piCur[58] ); |
---|
| 923 | uiSum += abs( piOrg[59] - piCur[59] ); |
---|
| 924 | uiSum += abs( piOrg[60] - piCur[60] ); |
---|
| 925 | uiSum += abs( piOrg[61] - piCur[61] ); |
---|
| 926 | uiSum += abs( piOrg[62] - piCur[62] ); |
---|
| 927 | uiSum += abs( piOrg[63] - piCur[63] ); |
---|
| 928 | |
---|
| 929 | piOrg += iStrideOrg; |
---|
| 930 | piCur += iStrideCur; |
---|
| 931 | } |
---|
| 932 | |
---|
| 933 | uiSum <<= iSubShift; |
---|
| 934 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 935 | } |
---|
| 936 | |
---|
| 937 | #if AMP_SAD |
---|
| 938 | UInt TComRdCost::xGetSAD48( DistParam* pcDtParam ) |
---|
| 939 | { |
---|
| 940 | if ( pcDtParam->bApplyWeight ) |
---|
| 941 | { |
---|
| 942 | return xGetSADw( pcDtParam ); |
---|
| 943 | } |
---|
| 944 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 945 | Pel* piCur = pcDtParam->pCur; |
---|
| 946 | Int iRows = pcDtParam->iRows; |
---|
| 947 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 948 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 949 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 950 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 951 | |
---|
| 952 | UInt uiSum = 0; |
---|
| 953 | |
---|
| 954 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 955 | { |
---|
| 956 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 957 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 958 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 959 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 960 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 961 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 962 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 963 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 964 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 965 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 966 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 967 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 968 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 969 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 970 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 971 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 972 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 973 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 974 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 975 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 976 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 977 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 978 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 979 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 980 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
| 981 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
| 982 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
| 983 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
| 984 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
| 985 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
| 986 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
| 987 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
| 988 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
| 989 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
| 990 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
| 991 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
| 992 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
| 993 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
| 994 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
| 995 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
| 996 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
| 997 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
| 998 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
| 999 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
| 1000 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
| 1001 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
| 1002 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
| 1003 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
| 1004 | |
---|
| 1005 | piOrg += iStrideOrg; |
---|
| 1006 | piCur += iStrideCur; |
---|
| 1007 | } |
---|
| 1008 | |
---|
| 1009 | uiSum <<= iSubShift; |
---|
| 1010 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 1011 | } |
---|
| 1012 | #endif |
---|
| 1013 | |
---|
| 1014 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 1015 | // SSE |
---|
| 1016 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 1017 | |
---|
| 1018 | UInt TComRdCost::xGetSSE( DistParam* pcDtParam ) |
---|
| 1019 | { |
---|
| 1020 | if ( pcDtParam->bApplyWeight ) |
---|
| 1021 | { |
---|
| 1022 | return xGetSSEw( pcDtParam ); |
---|
| 1023 | } |
---|
| 1024 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1025 | Pel* piCur = pcDtParam->pCur; |
---|
| 1026 | Int iRows = pcDtParam->iRows; |
---|
| 1027 | Int iCols = pcDtParam->iCols; |
---|
| 1028 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1029 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1030 | |
---|
| 1031 | UInt uiSum = 0; |
---|
| 1032 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 1033 | |
---|
| 1034 | Int iTemp; |
---|
| 1035 | |
---|
| 1036 | for( ; iRows != 0; iRows-- ) |
---|
| 1037 | { |
---|
| 1038 | for (Int n = 0; n < iCols; n++ ) |
---|
| 1039 | { |
---|
| 1040 | iTemp = piOrg[n ] - piCur[n ]; |
---|
| 1041 | uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1042 | } |
---|
| 1043 | piOrg += iStrideOrg; |
---|
| 1044 | piCur += iStrideCur; |
---|
| 1045 | } |
---|
| 1046 | |
---|
| 1047 | return ( uiSum ); |
---|
| 1048 | } |
---|
| 1049 | |
---|
| 1050 | UInt TComRdCost::xGetSSE4( DistParam* pcDtParam ) |
---|
| 1051 | { |
---|
| 1052 | if ( pcDtParam->bApplyWeight ) |
---|
| 1053 | { |
---|
| 1054 | assert( pcDtParam->iCols == 4 ); |
---|
| 1055 | return xGetSSEw( pcDtParam ); |
---|
| 1056 | } |
---|
| 1057 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1058 | Pel* piCur = pcDtParam->pCur; |
---|
| 1059 | Int iRows = pcDtParam->iRows; |
---|
| 1060 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1061 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1062 | |
---|
| 1063 | UInt uiSum = 0; |
---|
| 1064 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 1065 | |
---|
| 1066 | Int iTemp; |
---|
| 1067 | |
---|
| 1068 | for( ; iRows != 0; iRows-- ) |
---|
| 1069 | { |
---|
| 1070 | |
---|
| 1071 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1072 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1073 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1074 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1075 | |
---|
| 1076 | piOrg += iStrideOrg; |
---|
| 1077 | piCur += iStrideCur; |
---|
| 1078 | } |
---|
| 1079 | |
---|
| 1080 | return ( uiSum ); |
---|
| 1081 | } |
---|
| 1082 | |
---|
| 1083 | UInt TComRdCost::xGetSSE8( DistParam* pcDtParam ) |
---|
| 1084 | { |
---|
| 1085 | if ( pcDtParam->bApplyWeight ) |
---|
| 1086 | { |
---|
| 1087 | assert( pcDtParam->iCols == 8 ); |
---|
| 1088 | return xGetSSEw( pcDtParam ); |
---|
| 1089 | } |
---|
| 1090 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1091 | Pel* piCur = pcDtParam->pCur; |
---|
| 1092 | Int iRows = pcDtParam->iRows; |
---|
| 1093 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1094 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1095 | |
---|
| 1096 | UInt uiSum = 0; |
---|
| 1097 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 1098 | |
---|
| 1099 | Int iTemp; |
---|
| 1100 | |
---|
| 1101 | for( ; iRows != 0; iRows-- ) |
---|
| 1102 | { |
---|
| 1103 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1104 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1105 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1106 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1107 | iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1108 | iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1109 | iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1110 | iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1111 | |
---|
| 1112 | piOrg += iStrideOrg; |
---|
| 1113 | piCur += iStrideCur; |
---|
| 1114 | } |
---|
| 1115 | |
---|
| 1116 | return ( uiSum ); |
---|
| 1117 | } |
---|
| 1118 | |
---|
| 1119 | UInt TComRdCost::xGetSSE16( DistParam* pcDtParam ) |
---|
| 1120 | { |
---|
| 1121 | if ( pcDtParam->bApplyWeight ) |
---|
| 1122 | { |
---|
| 1123 | assert( pcDtParam->iCols == 16 ); |
---|
| 1124 | return xGetSSEw( pcDtParam ); |
---|
| 1125 | } |
---|
| 1126 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1127 | Pel* piCur = pcDtParam->pCur; |
---|
| 1128 | Int iRows = pcDtParam->iRows; |
---|
| 1129 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1130 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1131 | |
---|
| 1132 | UInt uiSum = 0; |
---|
| 1133 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 1134 | |
---|
| 1135 | Int iTemp; |
---|
| 1136 | |
---|
| 1137 | for( ; iRows != 0; iRows-- ) |
---|
| 1138 | { |
---|
| 1139 | |
---|
| 1140 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1141 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1142 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1143 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1144 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1145 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1146 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1147 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1148 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1149 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1150 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1151 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1152 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1153 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1154 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1155 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1156 | |
---|
| 1157 | piOrg += iStrideOrg; |
---|
| 1158 | piCur += iStrideCur; |
---|
| 1159 | } |
---|
| 1160 | |
---|
| 1161 | return ( uiSum ); |
---|
| 1162 | } |
---|
| 1163 | |
---|
| 1164 | UInt TComRdCost::xGetSSE16N( DistParam* pcDtParam ) |
---|
| 1165 | { |
---|
| 1166 | if ( pcDtParam->bApplyWeight ) |
---|
| 1167 | { |
---|
| 1168 | return xGetSSEw( pcDtParam ); |
---|
| 1169 | } |
---|
| 1170 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1171 | Pel* piCur = pcDtParam->pCur; |
---|
| 1172 | Int iRows = pcDtParam->iRows; |
---|
| 1173 | Int iCols = pcDtParam->iCols; |
---|
| 1174 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1175 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1176 | |
---|
| 1177 | UInt uiSum = 0; |
---|
| 1178 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 1179 | Int iTemp; |
---|
| 1180 | |
---|
| 1181 | for( ; iRows != 0; iRows-- ) |
---|
| 1182 | { |
---|
| 1183 | for (Int n = 0; n < iCols; n+=16 ) |
---|
| 1184 | { |
---|
| 1185 | |
---|
| 1186 | iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1187 | iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1188 | iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1189 | iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1190 | iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1191 | iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1192 | iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1193 | iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1194 | iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1195 | iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1196 | iTemp = piOrg[n+10] - piCur[n+10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1197 | iTemp = piOrg[n+11] - piCur[n+11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1198 | iTemp = piOrg[n+12] - piCur[n+12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1199 | iTemp = piOrg[n+13] - piCur[n+13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1200 | iTemp = piOrg[n+14] - piCur[n+14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1201 | iTemp = piOrg[n+15] - piCur[n+15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1202 | |
---|
| 1203 | } |
---|
| 1204 | piOrg += iStrideOrg; |
---|
| 1205 | piCur += iStrideCur; |
---|
| 1206 | } |
---|
| 1207 | |
---|
| 1208 | return ( uiSum ); |
---|
| 1209 | } |
---|
| 1210 | |
---|
| 1211 | UInt TComRdCost::xGetSSE32( DistParam* pcDtParam ) |
---|
| 1212 | { |
---|
| 1213 | if ( pcDtParam->bApplyWeight ) |
---|
| 1214 | { |
---|
| 1215 | assert( pcDtParam->iCols == 32 ); |
---|
| 1216 | return xGetSSEw( pcDtParam ); |
---|
| 1217 | } |
---|
| 1218 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1219 | Pel* piCur = pcDtParam->pCur; |
---|
| 1220 | Int iRows = pcDtParam->iRows; |
---|
| 1221 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1222 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1223 | |
---|
| 1224 | UInt uiSum = 0; |
---|
| 1225 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 1226 | Int iTemp; |
---|
| 1227 | |
---|
| 1228 | for( ; iRows != 0; iRows-- ) |
---|
| 1229 | { |
---|
| 1230 | |
---|
| 1231 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1232 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1233 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1234 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1235 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1236 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1237 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1238 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1239 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1240 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1241 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1242 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1243 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1244 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1245 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1246 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1247 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1248 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1249 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1250 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1251 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1252 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1253 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1254 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1255 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1256 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1257 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1258 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1259 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1260 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1261 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1262 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1263 | |
---|
| 1264 | piOrg += iStrideOrg; |
---|
| 1265 | piCur += iStrideCur; |
---|
| 1266 | } |
---|
| 1267 | |
---|
| 1268 | return ( uiSum ); |
---|
| 1269 | } |
---|
| 1270 | |
---|
| 1271 | UInt TComRdCost::xGetSSE64( DistParam* pcDtParam ) |
---|
| 1272 | { |
---|
| 1273 | if ( pcDtParam->bApplyWeight ) |
---|
| 1274 | { |
---|
| 1275 | assert( pcDtParam->iCols == 64 ); |
---|
| 1276 | return xGetSSEw( pcDtParam ); |
---|
| 1277 | } |
---|
| 1278 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1279 | Pel* piCur = pcDtParam->pCur; |
---|
| 1280 | Int iRows = pcDtParam->iRows; |
---|
| 1281 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1282 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1283 | |
---|
| 1284 | UInt uiSum = 0; |
---|
| 1285 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 1286 | Int iTemp; |
---|
| 1287 | |
---|
| 1288 | for( ; iRows != 0; iRows-- ) |
---|
| 1289 | { |
---|
| 1290 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1291 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1292 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1293 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1294 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1295 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1296 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1297 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1298 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1299 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1300 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1301 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1302 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1303 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1304 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1305 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1306 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1307 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1308 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1309 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1310 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1311 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1312 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1313 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1314 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1315 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1316 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1317 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1318 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1319 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1320 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1321 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1322 | iTemp = piOrg[32] - piCur[32]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1323 | iTemp = piOrg[33] - piCur[33]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1324 | iTemp = piOrg[34] - piCur[34]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1325 | iTemp = piOrg[35] - piCur[35]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1326 | iTemp = piOrg[36] - piCur[36]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1327 | iTemp = piOrg[37] - piCur[37]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1328 | iTemp = piOrg[38] - piCur[38]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1329 | iTemp = piOrg[39] - piCur[39]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1330 | iTemp = piOrg[40] - piCur[40]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1331 | iTemp = piOrg[41] - piCur[41]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1332 | iTemp = piOrg[42] - piCur[42]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1333 | iTemp = piOrg[43] - piCur[43]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1334 | iTemp = piOrg[44] - piCur[44]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1335 | iTemp = piOrg[45] - piCur[45]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1336 | iTemp = piOrg[46] - piCur[46]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1337 | iTemp = piOrg[47] - piCur[47]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1338 | iTemp = piOrg[48] - piCur[48]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1339 | iTemp = piOrg[49] - piCur[49]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1340 | iTemp = piOrg[50] - piCur[50]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1341 | iTemp = piOrg[51] - piCur[51]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1342 | iTemp = piOrg[52] - piCur[52]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1343 | iTemp = piOrg[53] - piCur[53]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1344 | iTemp = piOrg[54] - piCur[54]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1345 | iTemp = piOrg[55] - piCur[55]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1346 | iTemp = piOrg[56] - piCur[56]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1347 | iTemp = piOrg[57] - piCur[57]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1348 | iTemp = piOrg[58] - piCur[58]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1349 | iTemp = piOrg[59] - piCur[59]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1350 | iTemp = piOrg[60] - piCur[60]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1351 | iTemp = piOrg[61] - piCur[61]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1352 | iTemp = piOrg[62] - piCur[62]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1353 | iTemp = piOrg[63] - piCur[63]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 1354 | |
---|
| 1355 | piOrg += iStrideOrg; |
---|
| 1356 | piCur += iStrideCur; |
---|
| 1357 | } |
---|
| 1358 | |
---|
| 1359 | return ( uiSum ); |
---|
| 1360 | } |
---|
| 1361 | |
---|
| 1362 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 1363 | // HADAMARD with step (used in fractional search) |
---|
| 1364 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 1365 | |
---|
| 1366 | UInt TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
| 1367 | { |
---|
| 1368 | Int satd = 0, diff[4], m[4]; |
---|
| 1369 | assert( iStep == 1 ); |
---|
| 1370 | diff[0] = piOrg[0 ] - piCur[0]; |
---|
| 1371 | diff[1] = piOrg[1 ] - piCur[1]; |
---|
| 1372 | diff[2] = piOrg[iStrideOrg ] - piCur[0 + iStrideCur]; |
---|
| 1373 | diff[3] = piOrg[iStrideOrg + 1] - piCur[1 + iStrideCur]; |
---|
| 1374 | m[0] = diff[0] + diff[2]; |
---|
| 1375 | m[1] = diff[1] + diff[3]; |
---|
| 1376 | m[2] = diff[0] - diff[2]; |
---|
| 1377 | m[3] = diff[1] - diff[3]; |
---|
| 1378 | |
---|
| 1379 | satd += abs(m[0] + m[1]); |
---|
| 1380 | satd += abs(m[0] - m[1]); |
---|
| 1381 | satd += abs(m[2] + m[3]); |
---|
| 1382 | satd += abs(m[2] - m[3]); |
---|
| 1383 | |
---|
| 1384 | return satd; |
---|
| 1385 | } |
---|
| 1386 | |
---|
| 1387 | UInt TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
| 1388 | { |
---|
| 1389 | Int k, satd = 0, diff[16], m[16], d[16]; |
---|
| 1390 | |
---|
| 1391 | assert( iStep == 1 ); |
---|
| 1392 | for( k = 0; k < 16; k+=4 ) |
---|
| 1393 | { |
---|
| 1394 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
| 1395 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
| 1396 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
| 1397 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
| 1398 | |
---|
| 1399 | piCur += iStrideCur; |
---|
| 1400 | piOrg += iStrideOrg; |
---|
| 1401 | } |
---|
| 1402 | |
---|
| 1403 | /*===== hadamard transform =====*/ |
---|
| 1404 | m[ 0] = diff[ 0] + diff[12]; |
---|
| 1405 | m[ 1] = diff[ 1] + diff[13]; |
---|
| 1406 | m[ 2] = diff[ 2] + diff[14]; |
---|
| 1407 | m[ 3] = diff[ 3] + diff[15]; |
---|
| 1408 | m[ 4] = diff[ 4] + diff[ 8]; |
---|
| 1409 | m[ 5] = diff[ 5] + diff[ 9]; |
---|
| 1410 | m[ 6] = diff[ 6] + diff[10]; |
---|
| 1411 | m[ 7] = diff[ 7] + diff[11]; |
---|
| 1412 | m[ 8] = diff[ 4] - diff[ 8]; |
---|
| 1413 | m[ 9] = diff[ 5] - diff[ 9]; |
---|
| 1414 | m[10] = diff[ 6] - diff[10]; |
---|
| 1415 | m[11] = diff[ 7] - diff[11]; |
---|
| 1416 | m[12] = diff[ 0] - diff[12]; |
---|
| 1417 | m[13] = diff[ 1] - diff[13]; |
---|
| 1418 | m[14] = diff[ 2] - diff[14]; |
---|
| 1419 | m[15] = diff[ 3] - diff[15]; |
---|
| 1420 | |
---|
| 1421 | d[ 0] = m[ 0] + m[ 4]; |
---|
| 1422 | d[ 1] = m[ 1] + m[ 5]; |
---|
| 1423 | d[ 2] = m[ 2] + m[ 6]; |
---|
| 1424 | d[ 3] = m[ 3] + m[ 7]; |
---|
| 1425 | d[ 4] = m[ 8] + m[12]; |
---|
| 1426 | d[ 5] = m[ 9] + m[13]; |
---|
| 1427 | d[ 6] = m[10] + m[14]; |
---|
| 1428 | d[ 7] = m[11] + m[15]; |
---|
| 1429 | d[ 8] = m[ 0] - m[ 4]; |
---|
| 1430 | d[ 9] = m[ 1] - m[ 5]; |
---|
| 1431 | d[10] = m[ 2] - m[ 6]; |
---|
| 1432 | d[11] = m[ 3] - m[ 7]; |
---|
| 1433 | d[12] = m[12] - m[ 8]; |
---|
| 1434 | d[13] = m[13] - m[ 9]; |
---|
| 1435 | d[14] = m[14] - m[10]; |
---|
| 1436 | d[15] = m[15] - m[11]; |
---|
| 1437 | |
---|
| 1438 | m[ 0] = d[ 0] + d[ 3]; |
---|
| 1439 | m[ 1] = d[ 1] + d[ 2]; |
---|
| 1440 | m[ 2] = d[ 1] - d[ 2]; |
---|
| 1441 | m[ 3] = d[ 0] - d[ 3]; |
---|
| 1442 | m[ 4] = d[ 4] + d[ 7]; |
---|
| 1443 | m[ 5] = d[ 5] + d[ 6]; |
---|
| 1444 | m[ 6] = d[ 5] - d[ 6]; |
---|
| 1445 | m[ 7] = d[ 4] - d[ 7]; |
---|
| 1446 | m[ 8] = d[ 8] + d[11]; |
---|
| 1447 | m[ 9] = d[ 9] + d[10]; |
---|
| 1448 | m[10] = d[ 9] - d[10]; |
---|
| 1449 | m[11] = d[ 8] - d[11]; |
---|
| 1450 | m[12] = d[12] + d[15]; |
---|
| 1451 | m[13] = d[13] + d[14]; |
---|
| 1452 | m[14] = d[13] - d[14]; |
---|
| 1453 | m[15] = d[12] - d[15]; |
---|
| 1454 | |
---|
| 1455 | d[ 0] = m[ 0] + m[ 1]; |
---|
| 1456 | d[ 1] = m[ 0] - m[ 1]; |
---|
| 1457 | d[ 2] = m[ 2] + m[ 3]; |
---|
| 1458 | d[ 3] = m[ 3] - m[ 2]; |
---|
| 1459 | d[ 4] = m[ 4] + m[ 5]; |
---|
| 1460 | d[ 5] = m[ 4] - m[ 5]; |
---|
| 1461 | d[ 6] = m[ 6] + m[ 7]; |
---|
| 1462 | d[ 7] = m[ 7] - m[ 6]; |
---|
| 1463 | d[ 8] = m[ 8] + m[ 9]; |
---|
| 1464 | d[ 9] = m[ 8] - m[ 9]; |
---|
| 1465 | d[10] = m[10] + m[11]; |
---|
| 1466 | d[11] = m[11] - m[10]; |
---|
| 1467 | d[12] = m[12] + m[13]; |
---|
| 1468 | d[13] = m[12] - m[13]; |
---|
| 1469 | d[14] = m[14] + m[15]; |
---|
| 1470 | d[15] = m[15] - m[14]; |
---|
| 1471 | |
---|
| 1472 | for (k=0; k<16; ++k) |
---|
| 1473 | { |
---|
| 1474 | satd += abs(d[k]); |
---|
| 1475 | } |
---|
| 1476 | satd = ((satd+1)>>1); |
---|
| 1477 | |
---|
| 1478 | return satd; |
---|
| 1479 | } |
---|
| 1480 | |
---|
| 1481 | UInt TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
| 1482 | { |
---|
| 1483 | Int k, i, j, jj, sad=0; |
---|
| 1484 | Int diff[64], m1[8][8], m2[8][8], m3[8][8]; |
---|
| 1485 | assert( iStep == 1 ); |
---|
| 1486 | for( k = 0; k < 64; k += 8 ) |
---|
| 1487 | { |
---|
| 1488 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
| 1489 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
| 1490 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
| 1491 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
| 1492 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
| 1493 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
| 1494 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
| 1495 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
| 1496 | |
---|
| 1497 | piCur += iStrideCur; |
---|
| 1498 | piOrg += iStrideOrg; |
---|
| 1499 | } |
---|
| 1500 | |
---|
| 1501 | //horizontal |
---|
| 1502 | for (j=0; j < 8; j++) |
---|
| 1503 | { |
---|
| 1504 | jj = j << 3; |
---|
| 1505 | m2[j][0] = diff[jj ] + diff[jj+4]; |
---|
| 1506 | m2[j][1] = diff[jj+1] + diff[jj+5]; |
---|
| 1507 | m2[j][2] = diff[jj+2] + diff[jj+6]; |
---|
| 1508 | m2[j][3] = diff[jj+3] + diff[jj+7]; |
---|
| 1509 | m2[j][4] = diff[jj ] - diff[jj+4]; |
---|
| 1510 | m2[j][5] = diff[jj+1] - diff[jj+5]; |
---|
| 1511 | m2[j][6] = diff[jj+2] - diff[jj+6]; |
---|
| 1512 | m2[j][7] = diff[jj+3] - diff[jj+7]; |
---|
| 1513 | |
---|
| 1514 | m1[j][0] = m2[j][0] + m2[j][2]; |
---|
| 1515 | m1[j][1] = m2[j][1] + m2[j][3]; |
---|
| 1516 | m1[j][2] = m2[j][0] - m2[j][2]; |
---|
| 1517 | m1[j][3] = m2[j][1] - m2[j][3]; |
---|
| 1518 | m1[j][4] = m2[j][4] + m2[j][6]; |
---|
| 1519 | m1[j][5] = m2[j][5] + m2[j][7]; |
---|
| 1520 | m1[j][6] = m2[j][4] - m2[j][6]; |
---|
| 1521 | m1[j][7] = m2[j][5] - m2[j][7]; |
---|
| 1522 | |
---|
| 1523 | m2[j][0] = m1[j][0] + m1[j][1]; |
---|
| 1524 | m2[j][1] = m1[j][0] - m1[j][1]; |
---|
| 1525 | m2[j][2] = m1[j][2] + m1[j][3]; |
---|
| 1526 | m2[j][3] = m1[j][2] - m1[j][3]; |
---|
| 1527 | m2[j][4] = m1[j][4] + m1[j][5]; |
---|
| 1528 | m2[j][5] = m1[j][4] - m1[j][5]; |
---|
| 1529 | m2[j][6] = m1[j][6] + m1[j][7]; |
---|
| 1530 | m2[j][7] = m1[j][6] - m1[j][7]; |
---|
| 1531 | } |
---|
| 1532 | |
---|
| 1533 | //vertical |
---|
| 1534 | for (i=0; i < 8; i++) |
---|
| 1535 | { |
---|
| 1536 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
| 1537 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
| 1538 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
| 1539 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
| 1540 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
| 1541 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
| 1542 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
| 1543 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
| 1544 | |
---|
| 1545 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
| 1546 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
| 1547 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
| 1548 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
| 1549 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
| 1550 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
| 1551 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
| 1552 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
| 1553 | |
---|
| 1554 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
| 1555 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
| 1556 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
| 1557 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
| 1558 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
| 1559 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
| 1560 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
| 1561 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
| 1562 | } |
---|
| 1563 | |
---|
| 1564 | for (i = 0; i < 8; i++) |
---|
| 1565 | { |
---|
| 1566 | for (j = 0; j < 8; j++) |
---|
| 1567 | { |
---|
| 1568 | sad += abs(m2[i][j]); |
---|
| 1569 | } |
---|
| 1570 | } |
---|
| 1571 | |
---|
| 1572 | sad=((sad+2)>>2); |
---|
| 1573 | |
---|
| 1574 | return sad; |
---|
| 1575 | } |
---|
| 1576 | |
---|
| 1577 | #if NS_HAD |
---|
| 1578 | UInt TComRdCost::xCalcHADs16x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
| 1579 | { |
---|
| 1580 | Int k, i, j, jj, sad=0; |
---|
| 1581 | Int diff[64], m1[4][16], m2[4][16]; |
---|
| 1582 | assert( iStep == 1 ); |
---|
| 1583 | for( k = 0; k < 64; k += 16 ) |
---|
| 1584 | { |
---|
| 1585 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
| 1586 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
| 1587 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
| 1588 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
| 1589 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
| 1590 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
| 1591 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
| 1592 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
| 1593 | |
---|
| 1594 | diff[k+8] = piOrg[8] - piCur[8] ; |
---|
| 1595 | diff[k+9] = piOrg[9] - piCur[9] ; |
---|
| 1596 | diff[k+10] = piOrg[10] - piCur[10]; |
---|
| 1597 | diff[k+11] = piOrg[11] - piCur[11]; |
---|
| 1598 | diff[k+12] = piOrg[12] - piCur[12]; |
---|
| 1599 | diff[k+13] = piOrg[13] - piCur[13]; |
---|
| 1600 | diff[k+14] = piOrg[14] - piCur[14]; |
---|
| 1601 | diff[k+15] = piOrg[15] - piCur[15]; |
---|
| 1602 | |
---|
| 1603 | piCur += iStrideCur; |
---|
| 1604 | piOrg += iStrideOrg; |
---|
| 1605 | } |
---|
| 1606 | |
---|
| 1607 | //horizontal |
---|
| 1608 | for (j=0; j < 4; j++) |
---|
| 1609 | { |
---|
| 1610 | jj = j << 4; |
---|
| 1611 | |
---|
| 1612 | m2[j][0] = diff[jj ] + diff[jj+8]; |
---|
| 1613 | m2[j][1] = diff[jj+1] + diff[jj+9]; |
---|
| 1614 | m2[j][2] = diff[jj+2] + diff[jj+10]; |
---|
| 1615 | m2[j][3] = diff[jj+3] + diff[jj+11]; |
---|
| 1616 | m2[j][4] = diff[jj+4] + diff[jj+12]; |
---|
| 1617 | m2[j][5] = diff[jj+5] + diff[jj+13]; |
---|
| 1618 | m2[j][6] = diff[jj+6] + diff[jj+14]; |
---|
| 1619 | m2[j][7] = diff[jj+7] + diff[jj+15]; |
---|
| 1620 | m2[j][8] = diff[jj ] - diff[jj+8]; |
---|
| 1621 | m2[j][9] = diff[jj+1] - diff[jj+9]; |
---|
| 1622 | m2[j][10] = diff[jj+2] - diff[jj+10]; |
---|
| 1623 | m2[j][11] = diff[jj+3] - diff[jj+11]; |
---|
| 1624 | m2[j][12] = diff[jj+4] - diff[jj+12]; |
---|
| 1625 | m2[j][13] = diff[jj+5] - diff[jj+13]; |
---|
| 1626 | m2[j][14] = diff[jj+6] - diff[jj+14]; |
---|
| 1627 | m2[j][15] = diff[jj+7] - diff[jj+15]; |
---|
| 1628 | |
---|
| 1629 | m1[j][0] = m2[j][0] + m2[j][4]; |
---|
| 1630 | m1[j][1] = m2[j][1] + m2[j][5]; |
---|
| 1631 | m1[j][2] = m2[j][2] + m2[j][6]; |
---|
| 1632 | m1[j][3] = m2[j][3] + m2[j][7]; |
---|
| 1633 | m1[j][4] = m2[j][0] - m2[j][4]; |
---|
| 1634 | m1[j][5] = m2[j][1] - m2[j][5]; |
---|
| 1635 | m1[j][6] = m2[j][2] - m2[j][6]; |
---|
| 1636 | m1[j][7] = m2[j][3] - m2[j][7]; |
---|
| 1637 | m1[j][8] = m2[j][8] + m2[j][12]; |
---|
| 1638 | m1[j][9] = m2[j][9] + m2[j][13]; |
---|
| 1639 | m1[j][10] = m2[j][10] + m2[j][14]; |
---|
| 1640 | m1[j][11] = m2[j][11] + m2[j][15]; |
---|
| 1641 | m1[j][12] = m2[j][8] - m2[j][12]; |
---|
| 1642 | m1[j][13] = m2[j][9] - m2[j][13]; |
---|
| 1643 | m1[j][14] = m2[j][10] - m2[j][14]; |
---|
| 1644 | m1[j][15] = m2[j][11] - m2[j][15]; |
---|
| 1645 | |
---|
| 1646 | m2[j][0] = m1[j][0] + m1[j][2]; |
---|
| 1647 | m2[j][1] = m1[j][1] + m1[j][3]; |
---|
| 1648 | m2[j][2] = m1[j][0] - m1[j][2]; |
---|
| 1649 | m2[j][3] = m1[j][1] - m1[j][3]; |
---|
| 1650 | m2[j][4] = m1[j][4] + m1[j][6]; |
---|
| 1651 | m2[j][5] = m1[j][5] + m1[j][7]; |
---|
| 1652 | m2[j][6] = m1[j][4] - m1[j][6]; |
---|
| 1653 | m2[j][7] = m1[j][5] - m1[j][7]; |
---|
| 1654 | m2[j][8] = m1[j][8] + m1[j][10]; |
---|
| 1655 | m2[j][9] = m1[j][9] + m1[j][11]; |
---|
| 1656 | m2[j][10] = m1[j][8] - m1[j][10]; |
---|
| 1657 | m2[j][11] = m1[j][9] - m1[j][11]; |
---|
| 1658 | m2[j][12] = m1[j][12] + m1[j][14]; |
---|
| 1659 | m2[j][13] = m1[j][13] + m1[j][15]; |
---|
| 1660 | m2[j][14] = m1[j][12] - m1[j][14]; |
---|
| 1661 | m2[j][15] = m1[j][13] - m1[j][15]; |
---|
| 1662 | |
---|
| 1663 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
| 1664 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
| 1665 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
| 1666 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
| 1667 | m1[j][4] = m2[j][4] + m2[j][5]; |
---|
| 1668 | m1[j][5] = m2[j][4] - m2[j][5]; |
---|
| 1669 | m1[j][6] = m2[j][6] + m2[j][7]; |
---|
| 1670 | m1[j][7] = m2[j][6] - m2[j][7]; |
---|
| 1671 | m1[j][8] = m2[j][8] + m2[j][9]; |
---|
| 1672 | m1[j][9] = m2[j][8] - m2[j][9]; |
---|
| 1673 | m1[j][10] = m2[j][10] + m2[j][11]; |
---|
| 1674 | m1[j][11] = m2[j][10] - m2[j][11]; |
---|
| 1675 | m1[j][12] = m2[j][12] + m2[j][13]; |
---|
| 1676 | m1[j][13] = m2[j][12] - m2[j][13]; |
---|
| 1677 | m1[j][14] = m2[j][14] + m2[j][15]; |
---|
| 1678 | m1[j][15] = m2[j][14] - m2[j][15]; |
---|
| 1679 | } |
---|
| 1680 | |
---|
| 1681 | //vertical |
---|
| 1682 | for (i=0; i < 16; i++) |
---|
| 1683 | { |
---|
| 1684 | m2[0][i] = m1[0][i] + m1[2][i]; |
---|
| 1685 | m2[1][i] = m1[1][i] + m1[3][i]; |
---|
| 1686 | m2[2][i] = m1[0][i] - m1[2][i]; |
---|
| 1687 | m2[3][i] = m1[1][i] - m1[3][i]; |
---|
| 1688 | |
---|
| 1689 | m1[0][i] = m2[0][i] + m2[1][i]; |
---|
| 1690 | m1[1][i] = m2[0][i] - m2[1][i]; |
---|
| 1691 | m1[2][i] = m2[2][i] + m2[3][i]; |
---|
| 1692 | m1[3][i] = m2[2][i] - m2[3][i]; |
---|
| 1693 | } |
---|
| 1694 | |
---|
| 1695 | for (i = 0; i < 4; i++) |
---|
| 1696 | { |
---|
| 1697 | for (j = 0; j < 16; j++) |
---|
| 1698 | { |
---|
| 1699 | sad += abs(m1[i][j]); |
---|
| 1700 | } |
---|
| 1701 | } |
---|
| 1702 | |
---|
| 1703 | sad=((sad+2)>>2); |
---|
| 1704 | |
---|
| 1705 | return sad; |
---|
| 1706 | } |
---|
| 1707 | |
---|
| 1708 | UInt TComRdCost::xCalcHADs4x16( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
| 1709 | { |
---|
| 1710 | Int k, i, j, jj, sad=0; |
---|
| 1711 | Int diff[64], m1[16][4], m2[16][4], m3[16][4]; |
---|
| 1712 | assert( iStep == 1 ); |
---|
| 1713 | for( k = 0; k < 64; k += 4 ) |
---|
| 1714 | { |
---|
| 1715 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
| 1716 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
| 1717 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
| 1718 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
| 1719 | |
---|
| 1720 | piCur += iStrideCur; |
---|
| 1721 | piOrg += iStrideOrg; |
---|
| 1722 | } |
---|
| 1723 | |
---|
| 1724 | //horizontal |
---|
| 1725 | for (j=0; j < 16; j++) |
---|
| 1726 | { |
---|
| 1727 | jj = j << 2; |
---|
| 1728 | m2[j][0] = diff[jj ] + diff[jj+2]; |
---|
| 1729 | m2[j][1] = diff[jj+1] + diff[jj+3]; |
---|
| 1730 | m2[j][2] = diff[jj ] - diff[jj+2]; |
---|
| 1731 | m2[j][3] = diff[jj+1] - diff[jj+3]; |
---|
| 1732 | |
---|
| 1733 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
| 1734 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
| 1735 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
| 1736 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
| 1737 | } |
---|
| 1738 | |
---|
| 1739 | //vertical |
---|
| 1740 | for (i=0; i < 4; i++) |
---|
| 1741 | { |
---|
| 1742 | m2[0][i] = m1[0][i] + m1[8][i]; |
---|
| 1743 | m2[1][i] = m1[1][i] + m1[9][i]; |
---|
| 1744 | m2[2][i] = m1[2][i] + m1[10][i]; |
---|
| 1745 | m2[3][i] = m1[3][i] + m1[11][i]; |
---|
| 1746 | m2[4][i] = m1[4][i] + m1[12][i]; |
---|
| 1747 | m2[5][i] = m1[5][i] + m1[13][i]; |
---|
| 1748 | m2[6][i] = m1[6][i] + m1[14][i]; |
---|
| 1749 | m2[7][i] = m1[7][i] + m1[15][i]; |
---|
| 1750 | m2[8][i] = m1[0][i] - m1[8][i]; |
---|
| 1751 | m2[9][i] = m1[1][i] - m1[9][i]; |
---|
| 1752 | m2[10][i] = m1[2][i] - m1[10][i]; |
---|
| 1753 | m2[11][i] = m1[3][i] - m1[11][i]; |
---|
| 1754 | m2[12][i] = m1[4][i] - m1[12][i]; |
---|
| 1755 | m2[13][i] = m1[5][i] - m1[13][i]; |
---|
| 1756 | m2[14][i] = m1[6][i] - m1[14][i]; |
---|
| 1757 | m2[15][i] = m1[7][i] - m1[15][i]; |
---|
| 1758 | |
---|
| 1759 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
| 1760 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
| 1761 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
| 1762 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
| 1763 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
| 1764 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
| 1765 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
| 1766 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
| 1767 | m3[8][i] = m2[8][i] + m2[12][i]; |
---|
| 1768 | m3[9][i] = m2[9][i] + m2[13][i]; |
---|
| 1769 | m3[10][i] = m2[10][i] + m2[14][i]; |
---|
| 1770 | m3[11][i] = m2[11][i] + m2[15][i]; |
---|
| 1771 | m3[12][i] = m2[8][i] - m2[12][i]; |
---|
| 1772 | m3[13][i] = m2[9][i] - m2[13][i]; |
---|
| 1773 | m3[14][i] = m2[10][i] - m2[14][i]; |
---|
| 1774 | m3[15][i] = m2[11][i] - m2[15][i]; |
---|
| 1775 | |
---|
| 1776 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
| 1777 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
| 1778 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
| 1779 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
| 1780 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
| 1781 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
| 1782 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
| 1783 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
| 1784 | m1[8][i] = m3[8][i] + m3[10][i]; |
---|
| 1785 | m1[9][i] = m3[9][i] + m3[11][i]; |
---|
| 1786 | m1[10][i] = m3[8][i] - m3[10][i]; |
---|
| 1787 | m1[11][i] = m3[9][i] - m3[11][i]; |
---|
| 1788 | m1[12][i] = m3[12][i] + m3[14][i]; |
---|
| 1789 | m1[13][i] = m3[13][i] + m3[15][i]; |
---|
| 1790 | m1[14][i] = m3[12][i] - m3[14][i]; |
---|
| 1791 | m1[15][i] = m3[13][i] - m3[15][i]; |
---|
| 1792 | |
---|
| 1793 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
| 1794 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
| 1795 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
| 1796 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
| 1797 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
| 1798 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
| 1799 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
| 1800 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
| 1801 | m2[8][i] = m1[8][i] + m1[9][i]; |
---|
| 1802 | m2[9][i] = m1[8][i] - m1[9][i]; |
---|
| 1803 | m2[10][i] = m1[10][i] + m1[11][i]; |
---|
| 1804 | m2[11][i] = m1[10][i] - m1[11][i]; |
---|
| 1805 | m2[12][i] = m1[12][i] + m1[13][i]; |
---|
| 1806 | m2[13][i] = m1[12][i] - m1[13][i]; |
---|
| 1807 | m2[14][i] = m1[14][i] + m1[15][i]; |
---|
| 1808 | m2[15][i] = m1[14][i] - m1[15][i]; |
---|
| 1809 | } |
---|
| 1810 | |
---|
| 1811 | for (i = 0; i < 16; i++) |
---|
| 1812 | { |
---|
| 1813 | for (j = 0; j < 4; j++) |
---|
| 1814 | { |
---|
| 1815 | sad += abs(m2[i][j]); |
---|
| 1816 | } |
---|
| 1817 | } |
---|
| 1818 | |
---|
| 1819 | sad=((sad+2)>>2); |
---|
| 1820 | |
---|
| 1821 | return sad; |
---|
| 1822 | } |
---|
| 1823 | #endif |
---|
| 1824 | |
---|
| 1825 | UInt TComRdCost::xGetHADs4( DistParam* pcDtParam ) |
---|
| 1826 | { |
---|
| 1827 | if ( pcDtParam->bApplyWeight ) |
---|
| 1828 | { |
---|
| 1829 | return xGetHADs4w( pcDtParam ); |
---|
| 1830 | } |
---|
| 1831 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1832 | Pel* piCur = pcDtParam->pCur; |
---|
| 1833 | Int iRows = pcDtParam->iRows; |
---|
| 1834 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1835 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1836 | Int iStep = pcDtParam->iStep; |
---|
| 1837 | Int y; |
---|
| 1838 | Int iOffsetOrg = iStrideOrg<<2; |
---|
| 1839 | Int iOffsetCur = iStrideCur<<2; |
---|
| 1840 | |
---|
| 1841 | UInt uiSum = 0; |
---|
| 1842 | |
---|
| 1843 | for ( y=0; y<iRows; y+= 4 ) |
---|
| 1844 | { |
---|
| 1845 | uiSum += xCalcHADs4x4( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
| 1846 | piOrg += iOffsetOrg; |
---|
| 1847 | piCur += iOffsetCur; |
---|
| 1848 | } |
---|
| 1849 | |
---|
| 1850 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 1851 | } |
---|
| 1852 | |
---|
| 1853 | UInt TComRdCost::xGetHADs8( DistParam* pcDtParam ) |
---|
| 1854 | { |
---|
| 1855 | if ( pcDtParam->bApplyWeight ) |
---|
| 1856 | { |
---|
| 1857 | return xGetHADs8w( pcDtParam ); |
---|
| 1858 | } |
---|
| 1859 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1860 | Pel* piCur = pcDtParam->pCur; |
---|
| 1861 | Int iRows = pcDtParam->iRows; |
---|
| 1862 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1863 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1864 | Int iStep = pcDtParam->iStep; |
---|
| 1865 | Int y; |
---|
| 1866 | |
---|
| 1867 | UInt uiSum = 0; |
---|
| 1868 | |
---|
| 1869 | if ( iRows == 4 ) |
---|
| 1870 | { |
---|
| 1871 | uiSum += xCalcHADs4x4( piOrg+0, piCur , iStrideOrg, iStrideCur, iStep ); |
---|
| 1872 | uiSum += xCalcHADs4x4( piOrg+4, piCur+4*iStep, iStrideOrg, iStrideCur, iStep ); |
---|
| 1873 | } |
---|
| 1874 | else |
---|
| 1875 | { |
---|
| 1876 | Int iOffsetOrg = iStrideOrg<<3; |
---|
| 1877 | Int iOffsetCur = iStrideCur<<3; |
---|
| 1878 | for ( y=0; y<iRows; y+= 8 ) |
---|
| 1879 | { |
---|
| 1880 | uiSum += xCalcHADs8x8( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
| 1881 | piOrg += iOffsetOrg; |
---|
| 1882 | piCur += iOffsetCur; |
---|
| 1883 | } |
---|
| 1884 | } |
---|
| 1885 | |
---|
| 1886 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 1887 | } |
---|
| 1888 | |
---|
| 1889 | UInt TComRdCost::xGetHADs( DistParam* pcDtParam ) |
---|
| 1890 | { |
---|
| 1891 | if ( pcDtParam->bApplyWeight ) |
---|
| 1892 | { |
---|
| 1893 | return xGetHADsw( pcDtParam ); |
---|
| 1894 | } |
---|
| 1895 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1896 | Pel* piCur = pcDtParam->pCur; |
---|
| 1897 | Int iRows = pcDtParam->iRows; |
---|
| 1898 | Int iCols = pcDtParam->iCols; |
---|
| 1899 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1900 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1901 | Int iStep = pcDtParam->iStep; |
---|
| 1902 | |
---|
| 1903 | Int x, y; |
---|
| 1904 | |
---|
| 1905 | UInt uiSum = 0; |
---|
| 1906 | |
---|
| 1907 | #if NS_HAD |
---|
| 1908 | if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) ) |
---|
| 1909 | #else |
---|
| 1910 | if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) |
---|
| 1911 | #endif |
---|
| 1912 | { |
---|
| 1913 | Int iOffsetOrg = iStrideOrg<<3; |
---|
| 1914 | Int iOffsetCur = iStrideCur<<3; |
---|
| 1915 | for ( y=0; y<iRows; y+= 8 ) |
---|
| 1916 | { |
---|
| 1917 | for ( x=0; x<iCols; x+= 8 ) |
---|
| 1918 | { |
---|
| 1919 | uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 1920 | } |
---|
| 1921 | piOrg += iOffsetOrg; |
---|
| 1922 | piCur += iOffsetCur; |
---|
| 1923 | } |
---|
| 1924 | } |
---|
| 1925 | #if NS_HAD |
---|
| 1926 | else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD ) |
---|
| 1927 | { |
---|
| 1928 | Int iOffsetOrg = iStrideOrg<<2; |
---|
| 1929 | Int iOffsetCur = iStrideCur<<2; |
---|
| 1930 | for ( y=0; y<iRows; y+= 4 ) |
---|
| 1931 | { |
---|
| 1932 | for ( x=0; x<iCols; x+= 16 ) |
---|
| 1933 | { |
---|
| 1934 | uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 1935 | } |
---|
| 1936 | piOrg += iOffsetOrg; |
---|
| 1937 | piCur += iOffsetCur; |
---|
| 1938 | } |
---|
| 1939 | } |
---|
| 1940 | else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD ) |
---|
| 1941 | { |
---|
| 1942 | Int iOffsetOrg = iStrideOrg<<4; |
---|
| 1943 | Int iOffsetCur = iStrideCur<<4; |
---|
| 1944 | for ( y=0; y<iRows; y+= 16 ) |
---|
| 1945 | { |
---|
| 1946 | for ( x=0; x<iCols; x+= 4 ) |
---|
| 1947 | { |
---|
| 1948 | uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 1949 | } |
---|
| 1950 | piOrg += iOffsetOrg; |
---|
| 1951 | piCur += iOffsetCur; |
---|
| 1952 | } |
---|
| 1953 | } |
---|
| 1954 | #endif |
---|
| 1955 | else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) |
---|
| 1956 | { |
---|
| 1957 | Int iOffsetOrg = iStrideOrg<<2; |
---|
| 1958 | Int iOffsetCur = iStrideCur<<2; |
---|
| 1959 | |
---|
| 1960 | for ( y=0; y<iRows; y+= 4 ) |
---|
| 1961 | { |
---|
| 1962 | for ( x=0; x<iCols; x+= 4 ) |
---|
| 1963 | { |
---|
| 1964 | uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 1965 | } |
---|
| 1966 | piOrg += iOffsetOrg; |
---|
| 1967 | piCur += iOffsetCur; |
---|
| 1968 | } |
---|
| 1969 | } |
---|
| 1970 | else if( ( iRows % 2 == 0) && (iCols % 2 == 0) ) |
---|
| 1971 | { |
---|
| 1972 | Int iOffsetOrg = iStrideOrg<<1; |
---|
| 1973 | Int iOffsetCur = iStrideCur<<1; |
---|
| 1974 | for ( y=0; y<iRows; y+=2 ) |
---|
| 1975 | { |
---|
| 1976 | for ( x=0; x<iCols; x+=2 ) |
---|
| 1977 | { |
---|
| 1978 | uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 1979 | } |
---|
| 1980 | piOrg += iOffsetOrg; |
---|
| 1981 | piCur += iOffsetCur; |
---|
| 1982 | } |
---|
| 1983 | } |
---|
| 1984 | else |
---|
| 1985 | { |
---|
| 1986 | assert(false); |
---|
| 1987 | } |
---|
| 1988 | |
---|
| 1989 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 1990 | } |
---|
| 1991 | |
---|
| 1992 | //! \} |
---|