[324] | 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" |
---|
[446] | 42 | #if H_3D |
---|
| 43 | #include "TComDataCU.h" |
---|
| 44 | #endif |
---|
[324] | 45 | |
---|
| 46 | //! \ingroup TLibCommon |
---|
| 47 | //! \{ |
---|
| 48 | |
---|
[446] | 49 | #if H_3D_VSO |
---|
| 50 | // SAIT_VSO_EST_A0033 |
---|
| 51 | Double TComRdCost::m_dDisparityCoeff = 1.0; |
---|
| 52 | #endif |
---|
| 53 | |
---|
[324] | 54 | TComRdCost::TComRdCost() |
---|
| 55 | { |
---|
| 56 | init(); |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | TComRdCost::~TComRdCost() |
---|
| 60 | { |
---|
| 61 | #if !FIX203 |
---|
| 62 | xUninit(); |
---|
| 63 | #endif |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | // Calculate RD functions |
---|
[446] | 67 | #if H_3D_VSO |
---|
| 68 | Double TComRdCost::calcRdCost( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
| 69 | #else |
---|
[324] | 70 | Double TComRdCost::calcRdCost( UInt uiBits, UInt uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
[446] | 71 | #endif |
---|
[324] | 72 | { |
---|
| 73 | Double dRdCost = 0.0; |
---|
| 74 | Double dLambda = 0.0; |
---|
| 75 | |
---|
| 76 | switch ( eDFunc ) |
---|
| 77 | { |
---|
| 78 | case DF_SSE: |
---|
| 79 | assert(0); |
---|
| 80 | break; |
---|
| 81 | case DF_SAD: |
---|
| 82 | dLambda = (Double)m_uiLambdaMotionSAD; |
---|
| 83 | break; |
---|
| 84 | case DF_DEFAULT: |
---|
| 85 | dLambda = m_dLambda; |
---|
| 86 | break; |
---|
| 87 | case DF_SSE_FRAME: |
---|
| 88 | dLambda = m_dFrameLambda; |
---|
| 89 | break; |
---|
| 90 | default: |
---|
| 91 | assert (0); |
---|
| 92 | break; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | if (bFlag) |
---|
| 96 | { |
---|
| 97 | // Intra8x8, Intra4x4 Block only... |
---|
| 98 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
| 99 | dRdCost = (Double)(uiBits); |
---|
| 100 | #else |
---|
| 101 | dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda)); |
---|
| 102 | #endif |
---|
| 103 | } |
---|
| 104 | else |
---|
| 105 | { |
---|
| 106 | if (eDFunc == DF_SAD) |
---|
| 107 | { |
---|
| 108 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16)); |
---|
| 109 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
| 110 | } |
---|
| 111 | else |
---|
| 112 | { |
---|
| 113 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
| 114 | dRdCost = (Double)(uiBits); |
---|
| 115 | #else |
---|
| 116 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5))); |
---|
| 117 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
| 118 | #endif |
---|
| 119 | } |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | return dRdCost; |
---|
| 123 | } |
---|
| 124 | |
---|
[446] | 125 | #if H_3D_VSO |
---|
| 126 | Double TComRdCost::calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
| 127 | #else |
---|
[324] | 128 | Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
[446] | 129 | #endif |
---|
[324] | 130 | { |
---|
| 131 | Double dRdCost = 0.0; |
---|
| 132 | Double dLambda = 0.0; |
---|
| 133 | |
---|
| 134 | switch ( eDFunc ) |
---|
| 135 | { |
---|
| 136 | case DF_SSE: |
---|
| 137 | assert(0); |
---|
| 138 | break; |
---|
| 139 | case DF_SAD: |
---|
| 140 | dLambda = (Double)m_uiLambdaMotionSAD; |
---|
| 141 | break; |
---|
| 142 | case DF_DEFAULT: |
---|
| 143 | dLambda = m_dLambda; |
---|
| 144 | break; |
---|
| 145 | case DF_SSE_FRAME: |
---|
| 146 | dLambda = m_dFrameLambda; |
---|
| 147 | break; |
---|
| 148 | default: |
---|
| 149 | assert (0); |
---|
| 150 | break; |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | if (bFlag) |
---|
| 154 | { |
---|
| 155 | // Intra8x8, Intra4x4 Block only... |
---|
| 156 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
| 157 | dRdCost = (Double)(uiBits); |
---|
| 158 | #else |
---|
| 159 | dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda)); |
---|
| 160 | #endif |
---|
| 161 | } |
---|
| 162 | else |
---|
| 163 | { |
---|
| 164 | if (eDFunc == DF_SAD) |
---|
| 165 | { |
---|
| 166 | dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5)>>16)); |
---|
| 167 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
| 168 | } |
---|
| 169 | else |
---|
| 170 | { |
---|
| 171 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
| 172 | dRdCost = (Double)(uiBits); |
---|
| 173 | #else |
---|
| 174 | dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5))); |
---|
| 175 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
| 176 | #endif |
---|
| 177 | } |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | return dRdCost; |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | Void TComRdCost::setLambda( Double dLambda ) |
---|
| 184 | { |
---|
| 185 | m_dLambda = dLambda; |
---|
| 186 | m_sqrtLambda = sqrt(m_dLambda); |
---|
| 187 | m_uiLambdaMotionSAD = (UInt)floor(65536.0 * m_sqrtLambda); |
---|
| 188 | m_uiLambdaMotionSSE = (UInt)floor(65536.0 * m_dLambda ); |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | |
---|
| 192 | // Initalize Function Pointer by [eDFunc] |
---|
| 193 | Void TComRdCost::init() |
---|
| 194 | { |
---|
| 195 | m_afpDistortFunc[0] = NULL; // for DF_DEFAULT |
---|
| 196 | |
---|
| 197 | m_afpDistortFunc[1] = TComRdCost::xGetSSE; |
---|
| 198 | m_afpDistortFunc[2] = TComRdCost::xGetSSE4; |
---|
| 199 | m_afpDistortFunc[3] = TComRdCost::xGetSSE8; |
---|
| 200 | m_afpDistortFunc[4] = TComRdCost::xGetSSE16; |
---|
| 201 | m_afpDistortFunc[5] = TComRdCost::xGetSSE32; |
---|
| 202 | m_afpDistortFunc[6] = TComRdCost::xGetSSE64; |
---|
| 203 | m_afpDistortFunc[7] = TComRdCost::xGetSSE16N; |
---|
| 204 | |
---|
| 205 | m_afpDistortFunc[8] = TComRdCost::xGetSAD; |
---|
| 206 | m_afpDistortFunc[9] = TComRdCost::xGetSAD4; |
---|
| 207 | m_afpDistortFunc[10] = TComRdCost::xGetSAD8; |
---|
| 208 | m_afpDistortFunc[11] = TComRdCost::xGetSAD16; |
---|
| 209 | m_afpDistortFunc[12] = TComRdCost::xGetSAD32; |
---|
| 210 | m_afpDistortFunc[13] = TComRdCost::xGetSAD64; |
---|
| 211 | m_afpDistortFunc[14] = TComRdCost::xGetSAD16N; |
---|
| 212 | |
---|
| 213 | m_afpDistortFunc[15] = TComRdCost::xGetSAD; |
---|
| 214 | m_afpDistortFunc[16] = TComRdCost::xGetSAD4; |
---|
| 215 | m_afpDistortFunc[17] = TComRdCost::xGetSAD8; |
---|
| 216 | m_afpDistortFunc[18] = TComRdCost::xGetSAD16; |
---|
| 217 | m_afpDistortFunc[19] = TComRdCost::xGetSAD32; |
---|
| 218 | m_afpDistortFunc[20] = TComRdCost::xGetSAD64; |
---|
| 219 | m_afpDistortFunc[21] = TComRdCost::xGetSAD16N; |
---|
| 220 | |
---|
| 221 | #if AMP_SAD |
---|
| 222 | m_afpDistortFunc[43] = TComRdCost::xGetSAD12; |
---|
| 223 | m_afpDistortFunc[44] = TComRdCost::xGetSAD24; |
---|
| 224 | m_afpDistortFunc[45] = TComRdCost::xGetSAD48; |
---|
| 225 | |
---|
| 226 | m_afpDistortFunc[46] = TComRdCost::xGetSAD12; |
---|
| 227 | m_afpDistortFunc[47] = TComRdCost::xGetSAD24; |
---|
| 228 | m_afpDistortFunc[48] = TComRdCost::xGetSAD48; |
---|
| 229 | #endif |
---|
| 230 | m_afpDistortFunc[22] = TComRdCost::xGetHADs; |
---|
| 231 | m_afpDistortFunc[23] = TComRdCost::xGetHADs; |
---|
| 232 | m_afpDistortFunc[24] = TComRdCost::xGetHADs; |
---|
| 233 | m_afpDistortFunc[25] = TComRdCost::xGetHADs; |
---|
| 234 | m_afpDistortFunc[26] = TComRdCost::xGetHADs; |
---|
| 235 | m_afpDistortFunc[27] = TComRdCost::xGetHADs; |
---|
| 236 | m_afpDistortFunc[28] = TComRdCost::xGetHADs; |
---|
[446] | 237 | |
---|
| 238 | #if H_3D_VSO |
---|
| 239 | // SAIT_VSO_EST_A0033 |
---|
| 240 | m_afpDistortFunc[29] = TComRdCost::xGetVSD; |
---|
| 241 | m_afpDistortFunc[30] = TComRdCost::xGetVSD4; |
---|
| 242 | m_afpDistortFunc[31] = TComRdCost::xGetVSD8; |
---|
| 243 | m_afpDistortFunc[32] = TComRdCost::xGetVSD16; |
---|
| 244 | m_afpDistortFunc[33] = TComRdCost::xGetVSD32; |
---|
| 245 | m_afpDistortFunc[34] = TComRdCost::xGetVSD64; |
---|
| 246 | m_afpDistortFunc[35] = TComRdCost::xGetVSD16N; |
---|
| 247 | #endif |
---|
[324] | 248 | #if !FIX203 |
---|
| 249 | m_puiComponentCostOriginP = NULL; |
---|
| 250 | m_puiComponentCost = NULL; |
---|
| 251 | m_puiVerCost = NULL; |
---|
| 252 | m_puiHorCost = NULL; |
---|
| 253 | #endif |
---|
| 254 | m_uiCost = 0; |
---|
| 255 | m_iCostScale = 0; |
---|
| 256 | #if !FIX203 |
---|
| 257 | m_iSearchLimit = 0xdeaddead; |
---|
| 258 | #endif |
---|
[446] | 259 | #if H_3D_VSO |
---|
| 260 | m_bUseVSO = false; |
---|
| 261 | m_uiVSOMode = 0; |
---|
| 262 | m_fpDistortFuncVSO = NULL; |
---|
| 263 | m_pcRenModel = NULL; |
---|
| 264 | |
---|
| 265 | // SAIT_VSO_EST_A0033 |
---|
| 266 | m_bUseEstimatedVSD = false; |
---|
| 267 | #endif |
---|
[324] | 268 | } |
---|
| 269 | |
---|
| 270 | #if !FIX203 |
---|
| 271 | Void TComRdCost::initRateDistortionModel( Int iSubPelSearchLimit ) |
---|
| 272 | { |
---|
| 273 | // make it larger |
---|
| 274 | iSubPelSearchLimit += 4; |
---|
| 275 | iSubPelSearchLimit *= 8; |
---|
| 276 | |
---|
| 277 | if( m_iSearchLimit != iSubPelSearchLimit ) |
---|
| 278 | { |
---|
| 279 | xUninit(); |
---|
| 280 | |
---|
| 281 | m_iSearchLimit = iSubPelSearchLimit; |
---|
| 282 | |
---|
| 283 | m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ]; |
---|
| 284 | iSubPelSearchLimit *= 2; |
---|
| 285 | |
---|
| 286 | m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit; |
---|
| 287 | |
---|
| 288 | for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++) |
---|
| 289 | { |
---|
| 290 | m_puiComponentCost[n] = xGetComponentBits( n ); |
---|
| 291 | } |
---|
| 292 | } |
---|
| 293 | } |
---|
| 294 | |
---|
| 295 | Void TComRdCost::xUninit() |
---|
| 296 | { |
---|
| 297 | if( NULL != m_puiComponentCostOriginP ) |
---|
| 298 | { |
---|
| 299 | delete [] m_puiComponentCostOriginP; |
---|
| 300 | m_puiComponentCostOriginP = NULL; |
---|
| 301 | } |
---|
| 302 | } |
---|
| 303 | #endif |
---|
| 304 | |
---|
| 305 | UInt TComRdCost::xGetComponentBits( Int iVal ) |
---|
| 306 | { |
---|
| 307 | UInt uiLength = 1; |
---|
| 308 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
| 309 | |
---|
| 310 | assert ( uiTemp ); |
---|
| 311 | |
---|
| 312 | while ( 1 != uiTemp ) |
---|
| 313 | { |
---|
| 314 | uiTemp >>= 1; |
---|
| 315 | uiLength += 2; |
---|
| 316 | } |
---|
| 317 | |
---|
| 318 | return uiLength; |
---|
| 319 | } |
---|
| 320 | |
---|
| 321 | Void TComRdCost::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam ) |
---|
| 322 | { |
---|
| 323 | // set Block Width / Height |
---|
| 324 | rcDistParam.iCols = uiBlkWidth; |
---|
| 325 | rcDistParam.iRows = uiBlkHeight; |
---|
| 326 | rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
| 327 | |
---|
| 328 | // initialize |
---|
| 329 | rcDistParam.iSubShift = 0; |
---|
| 330 | } |
---|
| 331 | |
---|
| 332 | // Setting the Distortion Parameter for Inter (ME) |
---|
| 333 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam ) |
---|
| 334 | { |
---|
| 335 | // set Original & Curr Pointer / Stride |
---|
| 336 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
| 337 | rcDistParam.pCur = piRefY; |
---|
| 338 | |
---|
| 339 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
| 340 | rcDistParam.iStrideCur = iRefStride; |
---|
| 341 | |
---|
| 342 | // set Block Width / Height |
---|
| 343 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
| 344 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
| 345 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
| 346 | |
---|
| 347 | #if AMP_SAD |
---|
| 348 | if (rcDistParam.iCols == 12) |
---|
| 349 | { |
---|
| 350 | rcDistParam.DistFunc = m_afpDistortFunc[43 ]; |
---|
| 351 | } |
---|
| 352 | else if (rcDistParam.iCols == 24) |
---|
| 353 | { |
---|
| 354 | rcDistParam.DistFunc = m_afpDistortFunc[44 ]; |
---|
| 355 | } |
---|
| 356 | else if (rcDistParam.iCols == 48) |
---|
| 357 | { |
---|
| 358 | rcDistParam.DistFunc = m_afpDistortFunc[45 ]; |
---|
| 359 | } |
---|
| 360 | #endif |
---|
| 361 | |
---|
| 362 | // initialize |
---|
| 363 | rcDistParam.iSubShift = 0; |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | // Setting the Distortion Parameter for Inter (subpel ME with step) |
---|
| 367 | #if NS_HAD |
---|
| 368 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME, Bool bUseNSHAD ) |
---|
| 369 | #else |
---|
| 370 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME ) |
---|
| 371 | #endif |
---|
| 372 | { |
---|
| 373 | // set Original & Curr Pointer / Stride |
---|
| 374 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
| 375 | rcDistParam.pCur = piRefY; |
---|
| 376 | |
---|
| 377 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
| 378 | rcDistParam.iStrideCur = iRefStride * iStep; |
---|
| 379 | |
---|
| 380 | // set Step for interpolated buffer |
---|
| 381 | rcDistParam.iStep = iStep; |
---|
| 382 | |
---|
| 383 | // set Block Width / Height |
---|
| 384 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
| 385 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
| 386 | #if NS_HAD |
---|
| 387 | rcDistParam.bUseNSHAD = bUseNSHAD; |
---|
| 388 | #endif |
---|
| 389 | |
---|
| 390 | // set distortion function |
---|
| 391 | if ( !bHADME ) |
---|
| 392 | { |
---|
| 393 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
| 394 | #if AMP_SAD |
---|
| 395 | if (rcDistParam.iCols == 12) |
---|
| 396 | { |
---|
| 397 | rcDistParam.DistFunc = m_afpDistortFunc[46 ]; |
---|
| 398 | } |
---|
| 399 | else if (rcDistParam.iCols == 24) |
---|
| 400 | { |
---|
| 401 | rcDistParam.DistFunc = m_afpDistortFunc[47 ]; |
---|
| 402 | } |
---|
| 403 | else if (rcDistParam.iCols == 48) |
---|
| 404 | { |
---|
| 405 | rcDistParam.DistFunc = m_afpDistortFunc[48 ]; |
---|
| 406 | } |
---|
| 407 | #endif |
---|
| 408 | } |
---|
| 409 | else |
---|
| 410 | { |
---|
| 411 | rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
| 412 | } |
---|
| 413 | |
---|
| 414 | // initialize |
---|
| 415 | rcDistParam.iSubShift = 0; |
---|
| 416 | } |
---|
| 417 | |
---|
| 418 | Void |
---|
| 419 | #if NS_HAD |
---|
| 420 | TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard, Bool bUseNSHAD ) |
---|
| 421 | #else |
---|
| 422 | TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard ) |
---|
| 423 | #endif |
---|
| 424 | { |
---|
| 425 | rcDP.pOrg = p1; |
---|
| 426 | rcDP.pCur = p2; |
---|
| 427 | rcDP.iStrideOrg = iStride1; |
---|
| 428 | rcDP.iStrideCur = iStride2; |
---|
| 429 | rcDP.iCols = iWidth; |
---|
| 430 | rcDP.iRows = iHeight; |
---|
| 431 | rcDP.iStep = 1; |
---|
| 432 | rcDP.iSubShift = 0; |
---|
| 433 | rcDP.bitDepth = bitDepth; |
---|
| 434 | rcDP.DistFunc = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ]; |
---|
| 435 | #if NS_HAD |
---|
| 436 | rcDP.bUseNSHAD = bUseNSHAD; |
---|
| 437 | #endif |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | UInt TComRdCost::calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight ) |
---|
| 441 | { |
---|
| 442 | UInt uiSum = 0; |
---|
| 443 | Int x, y; |
---|
| 444 | |
---|
| 445 | if ( ( (iWidth % 8) == 0 ) && ( (iHeight % 8) == 0 ) ) |
---|
| 446 | { |
---|
| 447 | for ( y=0; y<iHeight; y+= 8 ) |
---|
| 448 | { |
---|
| 449 | for ( x=0; x<iWidth; x+= 8 ) |
---|
| 450 | { |
---|
| 451 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
| 452 | } |
---|
| 453 | pi0 += iStride0*8; |
---|
| 454 | pi1 += iStride1*8; |
---|
| 455 | } |
---|
| 456 | } |
---|
| 457 | else if ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) ) |
---|
| 458 | { |
---|
| 459 | for ( y=0; y<iHeight; y+= 4 ) |
---|
| 460 | { |
---|
| 461 | for ( x=0; x<iWidth; x+= 4 ) |
---|
| 462 | { |
---|
| 463 | uiSum += xCalcHADs4x4( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
| 464 | } |
---|
| 465 | pi0 += iStride0*4; |
---|
| 466 | pi1 += iStride1*4; |
---|
| 467 | } |
---|
| 468 | } |
---|
| 469 | else |
---|
| 470 | { |
---|
| 471 | for ( y=0; y<iHeight; y+= 2 ) |
---|
| 472 | { |
---|
| 473 | for ( x=0; x<iWidth; x+= 2 ) |
---|
| 474 | { |
---|
| 475 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
| 476 | } |
---|
| 477 | pi0 += iStride0*2; |
---|
| 478 | pi1 += iStride1*2; |
---|
| 479 | } |
---|
| 480 | } |
---|
| 481 | |
---|
| 482 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); |
---|
| 483 | |
---|
| 484 | } |
---|
| 485 | |
---|
[573] | 486 | #if SCU_HS_FAST_DEPTH_INTRA_E0238 |
---|
| 487 | |
---|
[582] | 488 | UInt TComRdCost::calcVAR (Pel* pi0, Int uiWidth, Int uiHeight, Int cuDepth) |
---|
| 489 | { |
---|
[573] | 490 | Int x, y; |
---|
| 491 | Int temp = 0; |
---|
| 492 | |
---|
[582] | 493 | for (x = 0; x < uiHeight; x++) |
---|
[573] | 494 | { |
---|
[582] | 495 | for (y = 0; y < uiWidth; y++) |
---|
[573] | 496 | { |
---|
[582] | 497 | temp += pi0[x*uiHeight+y]; |
---|
[573] | 498 | } |
---|
| 499 | } |
---|
[582] | 500 | Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2; |
---|
| 501 | if (uiWidth == 4) |
---|
| 502 | { |
---|
| 503 | cuDepth = cuMaxLog2Size-2; |
---|
| 504 | } |
---|
[573] | 505 | |
---|
[582] | 506 | temp = temp >> (cuMaxLog2Size-cuDepth)*2; |
---|
| 507 | |
---|
| 508 | UInt uiSum = 0; |
---|
| 509 | for (x = 0; x < uiHeight; x++) |
---|
[573] | 510 | { |
---|
[582] | 511 | for (y = 0; y < uiWidth; y++) |
---|
[573] | 512 | { |
---|
[582] | 513 | uiSum += (pi0[x*uiHeight+y]-temp)*(pi0[x*uiHeight+y]-temp); |
---|
[573] | 514 | } |
---|
| 515 | } |
---|
[582] | 516 | return (uiSum >> (cuMaxLog2Size-cuDepth)*2); |
---|
[573] | 517 | |
---|
| 518 | } |
---|
| 519 | #endif |
---|
| 520 | |
---|
| 521 | |
---|
[324] | 522 | #if WEIGHTED_CHROMA_DISTORTION |
---|
| 523 | UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText, DFunc eDFunc) |
---|
| 524 | #else |
---|
| 525 | UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc ) |
---|
| 526 | #endif |
---|
| 527 | { |
---|
| 528 | DistParam cDtParam; |
---|
| 529 | setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam ); |
---|
| 530 | cDtParam.pOrg = piOrg; |
---|
| 531 | cDtParam.pCur = piCur; |
---|
| 532 | cDtParam.iStrideOrg = iOrgStride; |
---|
| 533 | cDtParam.iStrideCur = iCurStride; |
---|
| 534 | cDtParam.iStep = 1; |
---|
| 535 | |
---|
| 536 | cDtParam.bApplyWeight = false; |
---|
| 537 | cDtParam.uiComp = 255; // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed. |
---|
| 538 | cDtParam.bitDepth = bitDepth; |
---|
| 539 | |
---|
[504] | 540 | #if H_3D_IC |
---|
| 541 | cDtParam.bUseIC = false; |
---|
| 542 | #endif |
---|
[324] | 543 | #if WEIGHTED_CHROMA_DISTORTION |
---|
| 544 | if (eText == TEXT_CHROMA_U) |
---|
| 545 | { |
---|
| 546 | return ((Int) (m_cbDistortionWeight * cDtParam.DistFunc( &cDtParam ))); |
---|
| 547 | } |
---|
| 548 | else if (eText == TEXT_CHROMA_V) |
---|
| 549 | { |
---|
| 550 | return ((Int) (m_crDistortionWeight * cDtParam.DistFunc( &cDtParam ))); |
---|
| 551 | } |
---|
| 552 | else |
---|
| 553 | { |
---|
| 554 | return cDtParam.DistFunc( &cDtParam ); |
---|
| 555 | } |
---|
| 556 | #else |
---|
| 557 | return cDtParam.DistFunc( &cDtParam ); |
---|
| 558 | #endif |
---|
| 559 | } |
---|
[446] | 560 | #if H_3D_VSO |
---|
| 561 | // SAIT_VSO_EST_A0033 |
---|
| 562 | UInt TComRdCost::getDistPartVSD( TComDataCU* pcCU, UInt uiPartOffset, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHAD, DFunc eDFunc ) |
---|
| 563 | { |
---|
| 564 | AOT( ( m_dDisparityCoeff <= 0 ) || ( m_dDisparityCoeff > 10 ) ); |
---|
[324] | 565 | |
---|
[446] | 566 | Pel* piVirRec = m_pcVideoRecPicYuv->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset); |
---|
| 567 | Pel* piVirOrg = m_pcDepthPicYuv ->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset); |
---|
| 568 | Int iVirStride = m_pcVideoRecPicYuv->getStride(); |
---|
| 569 | |
---|
| 570 | DistParam cDtParam; |
---|
| 571 | setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam ); |
---|
| 572 | cDtParam.pOrg = piOrg; |
---|
| 573 | cDtParam.pCur = piCur; |
---|
| 574 | cDtParam.pVirRec = piVirRec; |
---|
| 575 | cDtParam.pVirOrg = piVirOrg; |
---|
| 576 | cDtParam.iStrideVir = iVirStride; |
---|
| 577 | cDtParam.iStrideOrg = iOrgStride; |
---|
| 578 | cDtParam.iStrideCur = iCurStride; |
---|
| 579 | cDtParam.iStep = 1; |
---|
| 580 | |
---|
| 581 | cDtParam.bApplyWeight = false; |
---|
| 582 | cDtParam.uiComp = 255; // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed. |
---|
| 583 | |
---|
| 584 | Dist dist = cDtParam.DistFunc( &cDtParam ); |
---|
| 585 | |
---|
| 586 | if ( m_bUseWVSO ) |
---|
| 587 | { |
---|
| 588 | Int iDWeight = m_iDWeight * m_iDWeight; |
---|
| 589 | Int iVSOWeight = m_iVSDWeight * m_iVSDWeight; |
---|
| 590 | Dist distDepth; |
---|
| 591 | |
---|
| 592 | if ( !bHAD ) |
---|
| 593 | { |
---|
| 594 | distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
| 595 | } |
---|
| 596 | else |
---|
| 597 | { |
---|
| 598 | distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
| 599 | } |
---|
| 600 | |
---|
| 601 | dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight); |
---|
| 602 | } |
---|
| 603 | return dist; |
---|
| 604 | |
---|
| 605 | } |
---|
| 606 | #endif |
---|
| 607 | |
---|
[537] | 608 | #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT |
---|
[324] | 609 | UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride, Pel* pelOrg, Int orgStride, UInt width, UInt height ) |
---|
| 610 | { |
---|
| 611 | UInt SAD = 0; |
---|
| 612 | Int shift = DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); |
---|
| 613 | for ( Int i=0; i<height; i++ ) |
---|
| 614 | { |
---|
| 615 | for( Int j=0; j<width; j++ ) |
---|
| 616 | { |
---|
| 617 | SAD += abs((pelCur[j] - pelOrg[j])) >> shift; |
---|
| 618 | } |
---|
| 619 | pelCur = pelCur + curStride; |
---|
| 620 | pelOrg = pelOrg + orgStride; |
---|
| 621 | } |
---|
| 622 | return SAD; |
---|
| 623 | } |
---|
| 624 | #endif |
---|
| 625 | |
---|
| 626 | // ==================================================================================================================== |
---|
| 627 | // Distortion functions |
---|
| 628 | // ==================================================================================================================== |
---|
| 629 | |
---|
| 630 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 631 | // SAD |
---|
| 632 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 633 | |
---|
| 634 | UInt TComRdCost::xGetSAD( DistParam* pcDtParam ) |
---|
| 635 | { |
---|
| 636 | if ( pcDtParam->bApplyWeight ) |
---|
| 637 | { |
---|
| 638 | return xGetSADw( pcDtParam ); |
---|
| 639 | } |
---|
[504] | 640 | #if H_3D_IC |
---|
| 641 | if( pcDtParam->bUseIC ) |
---|
| 642 | { |
---|
| 643 | return xGetSADic( pcDtParam ); |
---|
| 644 | } |
---|
| 645 | #endif |
---|
[324] | 646 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 647 | Pel* piCur = pcDtParam->pCur; |
---|
| 648 | Int iRows = pcDtParam->iRows; |
---|
| 649 | Int iCols = pcDtParam->iCols; |
---|
| 650 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 651 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 652 | |
---|
| 653 | UInt uiSum = 0; |
---|
| 654 | |
---|
| 655 | for( ; iRows != 0; iRows-- ) |
---|
| 656 | { |
---|
| 657 | for (Int n = 0; n < iCols; n++ ) |
---|
| 658 | { |
---|
| 659 | uiSum += abs( piOrg[n] - piCur[n] ); |
---|
| 660 | } |
---|
| 661 | piOrg += iStrideOrg; |
---|
| 662 | piCur += iStrideCur; |
---|
| 663 | } |
---|
| 664 | |
---|
| 665 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 666 | } |
---|
| 667 | |
---|
| 668 | UInt TComRdCost::xGetSAD4( DistParam* pcDtParam ) |
---|
| 669 | { |
---|
| 670 | if ( pcDtParam->bApplyWeight ) |
---|
| 671 | { |
---|
| 672 | return xGetSADw( pcDtParam ); |
---|
| 673 | } |
---|
[504] | 674 | #if H_3D_IC |
---|
| 675 | if( pcDtParam->bUseIC ) |
---|
| 676 | { |
---|
| 677 | return xGetSAD4ic( pcDtParam ); |
---|
| 678 | } |
---|
| 679 | #endif |
---|
[324] | 680 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 681 | Pel* piCur = pcDtParam->pCur; |
---|
| 682 | Int iRows = pcDtParam->iRows; |
---|
| 683 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 684 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 685 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 686 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 687 | |
---|
| 688 | UInt uiSum = 0; |
---|
| 689 | |
---|
| 690 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 691 | { |
---|
| 692 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 693 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 694 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 695 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 696 | |
---|
| 697 | piOrg += iStrideOrg; |
---|
| 698 | piCur += iStrideCur; |
---|
| 699 | } |
---|
| 700 | |
---|
| 701 | uiSum <<= iSubShift; |
---|
| 702 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 703 | } |
---|
| 704 | |
---|
| 705 | UInt TComRdCost::xGetSAD8( DistParam* pcDtParam ) |
---|
| 706 | { |
---|
| 707 | if ( pcDtParam->bApplyWeight ) |
---|
| 708 | { |
---|
| 709 | return xGetSADw( pcDtParam ); |
---|
| 710 | } |
---|
[504] | 711 | #if H_3D_IC |
---|
| 712 | if( pcDtParam->bUseIC ) |
---|
| 713 | { |
---|
| 714 | return xGetSAD8ic( pcDtParam ); |
---|
| 715 | } |
---|
| 716 | #endif |
---|
[324] | 717 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 718 | Pel* piCur = pcDtParam->pCur; |
---|
| 719 | Int iRows = pcDtParam->iRows; |
---|
| 720 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 721 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 722 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 723 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 724 | |
---|
| 725 | UInt uiSum = 0; |
---|
| 726 | |
---|
| 727 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 728 | { |
---|
| 729 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 730 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 731 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 732 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 733 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 734 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 735 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 736 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 737 | |
---|
| 738 | piOrg += iStrideOrg; |
---|
| 739 | piCur += iStrideCur; |
---|
| 740 | } |
---|
| 741 | |
---|
| 742 | uiSum <<= iSubShift; |
---|
| 743 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 744 | } |
---|
| 745 | |
---|
| 746 | UInt TComRdCost::xGetSAD16( DistParam* pcDtParam ) |
---|
| 747 | { |
---|
| 748 | if ( pcDtParam->bApplyWeight ) |
---|
| 749 | { |
---|
| 750 | return xGetSADw( pcDtParam ); |
---|
| 751 | } |
---|
[504] | 752 | #if H_3D_IC |
---|
| 753 | if( pcDtParam->bUseIC ) |
---|
| 754 | { |
---|
| 755 | return xGetSAD16ic( pcDtParam ); |
---|
| 756 | } |
---|
| 757 | #endif |
---|
[324] | 758 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 759 | Pel* piCur = pcDtParam->pCur; |
---|
| 760 | Int iRows = pcDtParam->iRows; |
---|
| 761 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 762 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 763 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 764 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 765 | |
---|
| 766 | UInt uiSum = 0; |
---|
| 767 | |
---|
| 768 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 769 | { |
---|
| 770 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 771 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 772 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 773 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 774 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 775 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 776 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 777 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 778 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 779 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 780 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 781 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 782 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 783 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 784 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 785 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 786 | |
---|
| 787 | piOrg += iStrideOrg; |
---|
| 788 | piCur += iStrideCur; |
---|
| 789 | } |
---|
| 790 | |
---|
| 791 | uiSum <<= iSubShift; |
---|
| 792 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 793 | } |
---|
| 794 | |
---|
| 795 | #if AMP_SAD |
---|
| 796 | UInt TComRdCost::xGetSAD12( DistParam* pcDtParam ) |
---|
| 797 | { |
---|
| 798 | if ( pcDtParam->bApplyWeight ) |
---|
| 799 | { |
---|
| 800 | return xGetSADw( pcDtParam ); |
---|
| 801 | } |
---|
[504] | 802 | #if H_3D_IC |
---|
| 803 | if( pcDtParam->bUseIC ) |
---|
| 804 | { |
---|
| 805 | return xGetSAD12ic( pcDtParam ); |
---|
| 806 | } |
---|
| 807 | #endif |
---|
[324] | 808 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 809 | Pel* piCur = pcDtParam->pCur; |
---|
| 810 | Int iRows = pcDtParam->iRows; |
---|
| 811 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 812 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 813 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 814 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 815 | |
---|
| 816 | UInt uiSum = 0; |
---|
| 817 | |
---|
| 818 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 819 | { |
---|
| 820 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 821 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 822 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 823 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 824 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 825 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 826 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 827 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 828 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 829 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 830 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 831 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 832 | |
---|
| 833 | piOrg += iStrideOrg; |
---|
| 834 | piCur += iStrideCur; |
---|
| 835 | } |
---|
| 836 | |
---|
| 837 | uiSum <<= iSubShift; |
---|
| 838 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 839 | } |
---|
| 840 | #endif |
---|
| 841 | |
---|
| 842 | UInt TComRdCost::xGetSAD16N( DistParam* pcDtParam ) |
---|
| 843 | { |
---|
[504] | 844 | #if H_3D_IC |
---|
| 845 | if( pcDtParam->bUseIC ) |
---|
| 846 | { |
---|
| 847 | return xGetSAD16Nic( pcDtParam ); |
---|
| 848 | } |
---|
| 849 | #endif |
---|
[324] | 850 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 851 | Pel* piCur = pcDtParam->pCur; |
---|
| 852 | Int iRows = pcDtParam->iRows; |
---|
| 853 | Int iCols = pcDtParam->iCols; |
---|
| 854 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 855 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 856 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 857 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 858 | |
---|
| 859 | UInt uiSum = 0; |
---|
| 860 | |
---|
| 861 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 862 | { |
---|
| 863 | for (Int n = 0; n < iCols; n+=16 ) |
---|
| 864 | { |
---|
| 865 | uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] ); |
---|
| 866 | uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] ); |
---|
| 867 | uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] ); |
---|
| 868 | uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] ); |
---|
| 869 | uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] ); |
---|
| 870 | uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] ); |
---|
| 871 | uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] ); |
---|
| 872 | uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] ); |
---|
| 873 | uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] ); |
---|
| 874 | uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] ); |
---|
| 875 | uiSum += abs( piOrg[n+10] - piCur[n+10] ); |
---|
| 876 | uiSum += abs( piOrg[n+11] - piCur[n+11] ); |
---|
| 877 | uiSum += abs( piOrg[n+12] - piCur[n+12] ); |
---|
| 878 | uiSum += abs( piOrg[n+13] - piCur[n+13] ); |
---|
| 879 | uiSum += abs( piOrg[n+14] - piCur[n+14] ); |
---|
| 880 | uiSum += abs( piOrg[n+15] - piCur[n+15] ); |
---|
| 881 | } |
---|
| 882 | piOrg += iStrideOrg; |
---|
| 883 | piCur += iStrideCur; |
---|
| 884 | } |
---|
| 885 | |
---|
| 886 | uiSum <<= iSubShift; |
---|
| 887 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 888 | } |
---|
| 889 | |
---|
| 890 | UInt TComRdCost::xGetSAD32( DistParam* pcDtParam ) |
---|
| 891 | { |
---|
| 892 | if ( pcDtParam->bApplyWeight ) |
---|
| 893 | { |
---|
| 894 | return xGetSADw( pcDtParam ); |
---|
| 895 | } |
---|
[504] | 896 | #if H_3D_IC |
---|
| 897 | if( pcDtParam->bUseIC ) |
---|
| 898 | { |
---|
| 899 | return xGetSAD32ic( pcDtParam ); |
---|
| 900 | } |
---|
| 901 | #endif |
---|
[324] | 902 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 903 | Pel* piCur = pcDtParam->pCur; |
---|
| 904 | Int iRows = pcDtParam->iRows; |
---|
| 905 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 906 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 907 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 908 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 909 | |
---|
| 910 | UInt uiSum = 0; |
---|
| 911 | |
---|
| 912 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 913 | { |
---|
| 914 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 915 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 916 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 917 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 918 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 919 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 920 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 921 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 922 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 923 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 924 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 925 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 926 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 927 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 928 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 929 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 930 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 931 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 932 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 933 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 934 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 935 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 936 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 937 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 938 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
| 939 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
| 940 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
| 941 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
| 942 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
| 943 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
| 944 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
| 945 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
| 946 | |
---|
| 947 | piOrg += iStrideOrg; |
---|
| 948 | piCur += iStrideCur; |
---|
| 949 | } |
---|
| 950 | |
---|
| 951 | uiSum <<= iSubShift; |
---|
| 952 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 953 | } |
---|
| 954 | |
---|
| 955 | #if AMP_SAD |
---|
| 956 | UInt TComRdCost::xGetSAD24( DistParam* pcDtParam ) |
---|
| 957 | { |
---|
| 958 | if ( pcDtParam->bApplyWeight ) |
---|
| 959 | { |
---|
| 960 | return xGetSADw( pcDtParam ); |
---|
| 961 | } |
---|
[504] | 962 | #if H_3D_IC |
---|
| 963 | if( pcDtParam->bUseIC ) |
---|
| 964 | { |
---|
| 965 | return xGetSAD24ic( pcDtParam ); |
---|
| 966 | } |
---|
| 967 | #endif |
---|
[324] | 968 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 969 | Pel* piCur = pcDtParam->pCur; |
---|
| 970 | Int iRows = pcDtParam->iRows; |
---|
| 971 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 972 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 973 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 974 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 975 | |
---|
| 976 | UInt uiSum = 0; |
---|
| 977 | |
---|
| 978 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 979 | { |
---|
| 980 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 981 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 982 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 983 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 984 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 985 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 986 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 987 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 988 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 989 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 990 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 991 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 992 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 993 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 994 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 995 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 996 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 997 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 998 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 999 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 1000 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 1001 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 1002 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 1003 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 1004 | |
---|
| 1005 | piOrg += iStrideOrg; |
---|
| 1006 | piCur += iStrideCur; |
---|
| 1007 | } |
---|
| 1008 | |
---|
| 1009 | uiSum <<= iSubShift; |
---|
| 1010 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 1011 | } |
---|
| 1012 | |
---|
| 1013 | #endif |
---|
| 1014 | |
---|
| 1015 | UInt TComRdCost::xGetSAD64( DistParam* pcDtParam ) |
---|
| 1016 | { |
---|
| 1017 | if ( pcDtParam->bApplyWeight ) |
---|
| 1018 | { |
---|
| 1019 | return xGetSADw( pcDtParam ); |
---|
| 1020 | } |
---|
[504] | 1021 | #if H_3D_IC |
---|
| 1022 | if( pcDtParam->bUseIC ) |
---|
| 1023 | { |
---|
| 1024 | return xGetSAD64ic( pcDtParam ); |
---|
| 1025 | } |
---|
| 1026 | #endif |
---|
[324] | 1027 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1028 | Pel* piCur = pcDtParam->pCur; |
---|
| 1029 | Int iRows = pcDtParam->iRows; |
---|
| 1030 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 1031 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 1032 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 1033 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 1034 | |
---|
| 1035 | UInt uiSum = 0; |
---|
| 1036 | |
---|
| 1037 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1038 | { |
---|
| 1039 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 1040 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 1041 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 1042 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 1043 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 1044 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 1045 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 1046 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 1047 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 1048 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 1049 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 1050 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 1051 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 1052 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 1053 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 1054 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 1055 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 1056 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 1057 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 1058 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 1059 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 1060 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 1061 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 1062 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 1063 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
| 1064 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
| 1065 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
| 1066 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
| 1067 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
| 1068 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
| 1069 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
| 1070 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
| 1071 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
| 1072 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
| 1073 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
| 1074 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
| 1075 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
| 1076 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
| 1077 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
| 1078 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
| 1079 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
| 1080 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
| 1081 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
| 1082 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
| 1083 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
| 1084 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
| 1085 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
| 1086 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
| 1087 | uiSum += abs( piOrg[48] - piCur[48] ); |
---|
| 1088 | uiSum += abs( piOrg[49] - piCur[49] ); |
---|
| 1089 | uiSum += abs( piOrg[50] - piCur[50] ); |
---|
| 1090 | uiSum += abs( piOrg[51] - piCur[51] ); |
---|
| 1091 | uiSum += abs( piOrg[52] - piCur[52] ); |
---|
| 1092 | uiSum += abs( piOrg[53] - piCur[53] ); |
---|
| 1093 | uiSum += abs( piOrg[54] - piCur[54] ); |
---|
| 1094 | uiSum += abs( piOrg[55] - piCur[55] ); |
---|
| 1095 | uiSum += abs( piOrg[56] - piCur[56] ); |
---|
| 1096 | uiSum += abs( piOrg[57] - piCur[57] ); |
---|
| 1097 | uiSum += abs( piOrg[58] - piCur[58] ); |
---|
| 1098 | uiSum += abs( piOrg[59] - piCur[59] ); |
---|
| 1099 | uiSum += abs( piOrg[60] - piCur[60] ); |
---|
| 1100 | uiSum += abs( piOrg[61] - piCur[61] ); |
---|
| 1101 | uiSum += abs( piOrg[62] - piCur[62] ); |
---|
| 1102 | uiSum += abs( piOrg[63] - piCur[63] ); |
---|
| 1103 | |
---|
| 1104 | piOrg += iStrideOrg; |
---|
| 1105 | piCur += iStrideCur; |
---|
| 1106 | } |
---|
| 1107 | |
---|
| 1108 | uiSum <<= iSubShift; |
---|
| 1109 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 1110 | } |
---|
| 1111 | |
---|
| 1112 | #if AMP_SAD |
---|
| 1113 | UInt TComRdCost::xGetSAD48( DistParam* pcDtParam ) |
---|
| 1114 | { |
---|
| 1115 | if ( pcDtParam->bApplyWeight ) |
---|
| 1116 | { |
---|
| 1117 | return xGetSADw( pcDtParam ); |
---|
| 1118 | } |
---|
[504] | 1119 | #if H_3D_IC |
---|
| 1120 | if( pcDtParam->bUseIC ) |
---|
| 1121 | { |
---|
| 1122 | return xGetSAD48ic( pcDtParam ); |
---|
| 1123 | } |
---|
| 1124 | #endif |
---|
[324] | 1125 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1126 | Pel* piCur = pcDtParam->pCur; |
---|
| 1127 | Int iRows = pcDtParam->iRows; |
---|
| 1128 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 1129 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 1130 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 1131 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 1132 | |
---|
| 1133 | UInt uiSum = 0; |
---|
| 1134 | |
---|
| 1135 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1136 | { |
---|
| 1137 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 1138 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 1139 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 1140 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 1141 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 1142 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 1143 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 1144 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 1145 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 1146 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 1147 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 1148 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 1149 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 1150 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 1151 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 1152 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 1153 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 1154 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 1155 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 1156 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 1157 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 1158 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 1159 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 1160 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 1161 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
| 1162 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
| 1163 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
| 1164 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
| 1165 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
| 1166 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
| 1167 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
| 1168 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
| 1169 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
| 1170 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
| 1171 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
| 1172 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
| 1173 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
| 1174 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
| 1175 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
| 1176 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
| 1177 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
| 1178 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
| 1179 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
| 1180 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
| 1181 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
| 1182 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
| 1183 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
| 1184 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
| 1185 | |
---|
| 1186 | piOrg += iStrideOrg; |
---|
| 1187 | piCur += iStrideCur; |
---|
| 1188 | } |
---|
| 1189 | |
---|
| 1190 | uiSum <<= iSubShift; |
---|
| 1191 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 1192 | } |
---|
| 1193 | #endif |
---|
| 1194 | |
---|
[504] | 1195 | #if H_3D_IC |
---|
| 1196 | UInt TComRdCost::xGetSADic( DistParam* pcDtParam ) |
---|
| 1197 | { |
---|
| 1198 | if ( pcDtParam->bApplyWeight ) |
---|
| 1199 | { |
---|
| 1200 | return xGetSADw( pcDtParam ); |
---|
| 1201 | } |
---|
| 1202 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1203 | Pel* piCur = pcDtParam->pCur; |
---|
| 1204 | Int iRows = pcDtParam->iRows; |
---|
| 1205 | Int iCols = pcDtParam->iCols; |
---|
| 1206 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1207 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1208 | |
---|
| 1209 | UInt uiSum = 0; |
---|
| 1210 | |
---|
| 1211 | Int iOrigAvg = 0, iCurAvg = 0; |
---|
| 1212 | Int iDeltaC; |
---|
| 1213 | |
---|
| 1214 | for( ; iRows != 0; iRows-- ) |
---|
| 1215 | { |
---|
| 1216 | for (Int n = 0; n < iCols; n++ ) |
---|
| 1217 | { |
---|
| 1218 | iOrigAvg += piOrg[n]; |
---|
| 1219 | iCurAvg += piCur[n]; |
---|
| 1220 | } |
---|
| 1221 | piOrg += iStrideOrg; |
---|
| 1222 | piCur += iStrideCur; |
---|
| 1223 | } |
---|
| 1224 | |
---|
| 1225 | piOrg = pcDtParam->pOrg; |
---|
| 1226 | piCur = pcDtParam->pCur; |
---|
| 1227 | iRows = pcDtParam->iRows; |
---|
| 1228 | |
---|
| 1229 | iDeltaC = (iOrigAvg - iCurAvg)/iCols/iRows; |
---|
| 1230 | |
---|
| 1231 | for( ; iRows != 0; iRows-- ) |
---|
| 1232 | { |
---|
| 1233 | for (Int n = 0; n < iCols; n++ ) |
---|
| 1234 | { |
---|
| 1235 | uiSum += abs( piOrg[n] - piCur[n] - iDeltaC ); |
---|
| 1236 | } |
---|
| 1237 | piOrg += iStrideOrg; |
---|
| 1238 | piCur += iStrideCur; |
---|
| 1239 | } |
---|
| 1240 | |
---|
| 1241 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
| 1242 | } |
---|
| 1243 | |
---|
| 1244 | UInt TComRdCost::xGetSAD4ic( DistParam* pcDtParam ) |
---|
| 1245 | { |
---|
| 1246 | if ( pcDtParam->bApplyWeight ) |
---|
| 1247 | { |
---|
| 1248 | return xGetSADw( pcDtParam ); |
---|
| 1249 | } |
---|
| 1250 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1251 | Pel* piCur = pcDtParam->pCur; |
---|
| 1252 | Int iRows = pcDtParam->iRows; |
---|
| 1253 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 1254 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 1255 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 1256 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 1257 | |
---|
| 1258 | UInt uiSum = 0; |
---|
| 1259 | |
---|
| 1260 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
| 1261 | Int iDeltaC; |
---|
| 1262 | |
---|
| 1263 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1264 | { |
---|
| 1265 | iOrigAvg += piOrg[0]; |
---|
| 1266 | iOrigAvg += piOrg[1]; |
---|
| 1267 | iOrigAvg += piOrg[2]; |
---|
| 1268 | iOrigAvg += piOrg[3]; |
---|
| 1269 | |
---|
| 1270 | iCurAvg += piCur[0]; |
---|
| 1271 | iCurAvg += piCur[1]; |
---|
| 1272 | iCurAvg += piCur[2]; |
---|
| 1273 | iCurAvg += piCur[3]; |
---|
| 1274 | |
---|
| 1275 | piOrg += iStrideOrg; |
---|
| 1276 | piCur += iStrideCur; |
---|
| 1277 | uiRowCnt++; |
---|
| 1278 | } |
---|
| 1279 | |
---|
| 1280 | piOrg = pcDtParam->pOrg; |
---|
| 1281 | piCur = pcDtParam->pCur; |
---|
| 1282 | iRows = pcDtParam->iRows; |
---|
| 1283 | |
---|
| 1284 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/4) : 0; |
---|
| 1285 | |
---|
| 1286 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1287 | { |
---|
| 1288 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
| 1289 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
| 1290 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
| 1291 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
| 1292 | |
---|
| 1293 | piOrg += iStrideOrg; |
---|
| 1294 | piCur += iStrideCur; |
---|
| 1295 | } |
---|
| 1296 | |
---|
| 1297 | uiSum <<= iSubShift; |
---|
| 1298 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
| 1299 | } |
---|
| 1300 | |
---|
| 1301 | UInt TComRdCost::xGetSAD8ic( DistParam* pcDtParam ) |
---|
| 1302 | { |
---|
| 1303 | if ( pcDtParam->bApplyWeight ) |
---|
| 1304 | { |
---|
| 1305 | return xGetSADw( pcDtParam ); |
---|
| 1306 | } |
---|
| 1307 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1308 | Pel* piCur = pcDtParam->pCur; |
---|
| 1309 | Int iRows = pcDtParam->iRows; |
---|
| 1310 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 1311 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 1312 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 1313 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 1314 | |
---|
| 1315 | UInt uiSum = 0; |
---|
| 1316 | |
---|
| 1317 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
| 1318 | Int iDeltaC; |
---|
| 1319 | |
---|
| 1320 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1321 | { |
---|
| 1322 | iOrigAvg += piOrg[0]; |
---|
| 1323 | iOrigAvg += piOrg[1]; |
---|
| 1324 | iOrigAvg += piOrg[2]; |
---|
| 1325 | iOrigAvg += piOrg[3]; |
---|
| 1326 | iOrigAvg += piOrg[4]; |
---|
| 1327 | iOrigAvg += piOrg[5]; |
---|
| 1328 | iOrigAvg += piOrg[6]; |
---|
| 1329 | iOrigAvg += piOrg[7]; |
---|
| 1330 | |
---|
| 1331 | iCurAvg += piCur[0]; |
---|
| 1332 | iCurAvg += piCur[1]; |
---|
| 1333 | iCurAvg += piCur[2]; |
---|
| 1334 | iCurAvg += piCur[3]; |
---|
| 1335 | iCurAvg += piCur[4]; |
---|
| 1336 | iCurAvg += piCur[5]; |
---|
| 1337 | iCurAvg += piCur[6]; |
---|
| 1338 | iCurAvg += piCur[7]; |
---|
| 1339 | |
---|
| 1340 | piOrg += iStrideOrg; |
---|
| 1341 | piCur += iStrideCur; |
---|
| 1342 | uiRowCnt++; |
---|
| 1343 | } |
---|
| 1344 | |
---|
| 1345 | piOrg = pcDtParam->pOrg; |
---|
| 1346 | piCur = pcDtParam->pCur; |
---|
| 1347 | iRows = pcDtParam->iRows; |
---|
| 1348 | |
---|
| 1349 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/8) : 0; |
---|
| 1350 | |
---|
| 1351 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1352 | { |
---|
| 1353 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
| 1354 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
| 1355 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
| 1356 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
| 1357 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
| 1358 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
| 1359 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
| 1360 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
| 1361 | |
---|
| 1362 | piOrg += iStrideOrg; |
---|
| 1363 | piCur += iStrideCur; |
---|
| 1364 | } |
---|
| 1365 | |
---|
| 1366 | uiSum <<= iSubShift; |
---|
| 1367 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
| 1368 | } |
---|
| 1369 | |
---|
| 1370 | UInt TComRdCost::xGetSAD16ic( DistParam* pcDtParam ) |
---|
| 1371 | { |
---|
| 1372 | if ( pcDtParam->bApplyWeight ) |
---|
| 1373 | { |
---|
| 1374 | return xGetSADw( pcDtParam ); |
---|
| 1375 | } |
---|
| 1376 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1377 | Pel* piCur = pcDtParam->pCur; |
---|
| 1378 | Int iRows = pcDtParam->iRows; |
---|
| 1379 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 1380 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 1381 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 1382 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 1383 | |
---|
| 1384 | UInt uiSum = 0; |
---|
| 1385 | |
---|
| 1386 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
| 1387 | Int iDeltaC; |
---|
| 1388 | |
---|
| 1389 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1390 | { |
---|
| 1391 | iOrigAvg += piOrg[0]; |
---|
| 1392 | iOrigAvg += piOrg[1]; |
---|
| 1393 | iOrigAvg += piOrg[2]; |
---|
| 1394 | iOrigAvg += piOrg[3]; |
---|
| 1395 | iOrigAvg += piOrg[4]; |
---|
| 1396 | iOrigAvg += piOrg[5]; |
---|
| 1397 | iOrigAvg += piOrg[6]; |
---|
| 1398 | iOrigAvg += piOrg[7]; |
---|
| 1399 | iOrigAvg += piOrg[8]; |
---|
| 1400 | iOrigAvg += piOrg[9]; |
---|
| 1401 | iOrigAvg += piOrg[10]; |
---|
| 1402 | iOrigAvg += piOrg[11]; |
---|
| 1403 | iOrigAvg += piOrg[12]; |
---|
| 1404 | iOrigAvg += piOrg[13]; |
---|
| 1405 | iOrigAvg += piOrg[14]; |
---|
| 1406 | iOrigAvg += piOrg[15]; |
---|
| 1407 | |
---|
| 1408 | iCurAvg += piCur[0]; |
---|
| 1409 | iCurAvg += piCur[1]; |
---|
| 1410 | iCurAvg += piCur[2]; |
---|
| 1411 | iCurAvg += piCur[3]; |
---|
| 1412 | iCurAvg += piCur[4]; |
---|
| 1413 | iCurAvg += piCur[5]; |
---|
| 1414 | iCurAvg += piCur[6]; |
---|
| 1415 | iCurAvg += piCur[7]; |
---|
| 1416 | iCurAvg += piCur[8]; |
---|
| 1417 | iCurAvg += piCur[9]; |
---|
| 1418 | iCurAvg += piCur[10]; |
---|
| 1419 | iCurAvg += piCur[11]; |
---|
| 1420 | iCurAvg += piCur[12]; |
---|
| 1421 | iCurAvg += piCur[13]; |
---|
| 1422 | iCurAvg += piCur[14]; |
---|
| 1423 | iCurAvg += piCur[15]; |
---|
| 1424 | |
---|
| 1425 | piOrg += iStrideOrg; |
---|
| 1426 | piCur += iStrideCur; |
---|
| 1427 | uiRowCnt++; |
---|
| 1428 | } |
---|
| 1429 | |
---|
| 1430 | piOrg = pcDtParam->pOrg; |
---|
| 1431 | piCur = pcDtParam->pCur; |
---|
| 1432 | iRows = pcDtParam->iRows; |
---|
| 1433 | |
---|
| 1434 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/16) : 0; |
---|
| 1435 | |
---|
| 1436 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1437 | { |
---|
| 1438 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
| 1439 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
| 1440 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
| 1441 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
| 1442 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
| 1443 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
| 1444 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
| 1445 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
| 1446 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
| 1447 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
| 1448 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
| 1449 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
| 1450 | uiSum += abs( piOrg[12] - piCur[12] - iDeltaC ); |
---|
| 1451 | uiSum += abs( piOrg[13] - piCur[13] - iDeltaC ); |
---|
| 1452 | uiSum += abs( piOrg[14] - piCur[14] - iDeltaC ); |
---|
| 1453 | uiSum += abs( piOrg[15] - piCur[15] - iDeltaC ); |
---|
| 1454 | |
---|
| 1455 | piOrg += iStrideOrg; |
---|
| 1456 | piCur += iStrideCur; |
---|
| 1457 | } |
---|
| 1458 | |
---|
| 1459 | uiSum <<= iSubShift; |
---|
| 1460 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
| 1461 | } |
---|
| 1462 | |
---|
| 1463 | #if AMP_SAD |
---|
| 1464 | UInt TComRdCost::xGetSAD12ic( DistParam* pcDtParam ) |
---|
| 1465 | { |
---|
| 1466 | if ( pcDtParam->bApplyWeight ) |
---|
| 1467 | { |
---|
| 1468 | return xGetSADw( pcDtParam ); |
---|
| 1469 | } |
---|
| 1470 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1471 | Pel* piCur = pcDtParam->pCur; |
---|
| 1472 | Int iRows = pcDtParam->iRows; |
---|
| 1473 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 1474 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 1475 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 1476 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 1477 | |
---|
| 1478 | UInt uiSum = 0; |
---|
| 1479 | |
---|
| 1480 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
| 1481 | Int iDeltaC; |
---|
| 1482 | |
---|
| 1483 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1484 | { |
---|
| 1485 | iOrigAvg += piOrg[0]; |
---|
| 1486 | iOrigAvg += piOrg[1]; |
---|
| 1487 | iOrigAvg += piOrg[2]; |
---|
| 1488 | iOrigAvg += piOrg[3]; |
---|
| 1489 | iOrigAvg += piOrg[4]; |
---|
| 1490 | iOrigAvg += piOrg[5]; |
---|
| 1491 | iOrigAvg += piOrg[6]; |
---|
| 1492 | iOrigAvg += piOrg[7]; |
---|
| 1493 | iOrigAvg += piOrg[8]; |
---|
| 1494 | iOrigAvg += piOrg[9]; |
---|
| 1495 | iOrigAvg += piOrg[10]; |
---|
| 1496 | iOrigAvg += piOrg[11]; |
---|
| 1497 | |
---|
| 1498 | iCurAvg += piCur[0]; |
---|
| 1499 | iCurAvg += piCur[1]; |
---|
| 1500 | iCurAvg += piCur[2]; |
---|
| 1501 | iCurAvg += piCur[3]; |
---|
| 1502 | iCurAvg += piCur[4]; |
---|
| 1503 | iCurAvg += piCur[5]; |
---|
| 1504 | iCurAvg += piCur[6]; |
---|
| 1505 | iCurAvg += piCur[7]; |
---|
| 1506 | iCurAvg += piCur[8]; |
---|
| 1507 | iCurAvg += piCur[9]; |
---|
| 1508 | iCurAvg += piCur[10]; |
---|
| 1509 | iCurAvg += piCur[11]; |
---|
| 1510 | |
---|
| 1511 | piOrg += iStrideOrg; |
---|
| 1512 | piCur += iStrideCur; |
---|
| 1513 | uiRowCnt++; |
---|
| 1514 | } |
---|
| 1515 | |
---|
| 1516 | piOrg = pcDtParam->pOrg; |
---|
| 1517 | piCur = pcDtParam->pCur; |
---|
| 1518 | iRows = pcDtParam->iRows; |
---|
| 1519 | |
---|
| 1520 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/12) : 0; |
---|
| 1521 | |
---|
| 1522 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1523 | { |
---|
| 1524 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
| 1525 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
| 1526 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
| 1527 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
| 1528 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
| 1529 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
| 1530 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
| 1531 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
| 1532 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
| 1533 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
| 1534 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
| 1535 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
| 1536 | |
---|
| 1537 | piOrg += iStrideOrg; |
---|
| 1538 | piCur += iStrideCur; |
---|
| 1539 | } |
---|
| 1540 | |
---|
| 1541 | uiSum <<= iSubShift; |
---|
| 1542 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
| 1543 | } |
---|
| 1544 | #endif |
---|
| 1545 | |
---|
| 1546 | UInt TComRdCost::xGetSAD16Nic( DistParam* pcDtParam ) |
---|
| 1547 | { |
---|
| 1548 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1549 | Pel* piCur = pcDtParam->pCur; |
---|
| 1550 | Int iRows = pcDtParam->iRows; |
---|
| 1551 | Int iCols = pcDtParam->iCols; |
---|
| 1552 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 1553 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 1554 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 1555 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 1556 | |
---|
| 1557 | UInt uiSum = 0; |
---|
| 1558 | |
---|
| 1559 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0, uiColCnt = (iCols-1)/16 + 1; |
---|
| 1560 | Int iDeltaC; |
---|
| 1561 | |
---|
| 1562 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1563 | { |
---|
| 1564 | for (Int n = 0; n < iCols; n+=16 ) |
---|
| 1565 | { |
---|
| 1566 | iOrigAvg += piOrg[n + 0]; |
---|
| 1567 | iOrigAvg += piOrg[n + 1]; |
---|
| 1568 | iOrigAvg += piOrg[n + 2]; |
---|
| 1569 | iOrigAvg += piOrg[n + 3]; |
---|
| 1570 | iOrigAvg += piOrg[n + 4]; |
---|
| 1571 | iOrigAvg += piOrg[n + 5]; |
---|
| 1572 | iOrigAvg += piOrg[n + 6]; |
---|
| 1573 | iOrigAvg += piOrg[n + 7]; |
---|
| 1574 | iOrigAvg += piOrg[n + 8]; |
---|
| 1575 | iOrigAvg += piOrg[n + 9]; |
---|
| 1576 | iOrigAvg += piOrg[n + 10]; |
---|
| 1577 | iOrigAvg += piOrg[n + 11]; |
---|
| 1578 | iOrigAvg += piOrg[n + 12]; |
---|
| 1579 | iOrigAvg += piOrg[n + 13]; |
---|
| 1580 | iOrigAvg += piOrg[n + 14]; |
---|
| 1581 | iOrigAvg += piOrg[n + 15]; |
---|
| 1582 | |
---|
| 1583 | iCurAvg += piCur[n + 0]; |
---|
| 1584 | iCurAvg += piCur[n + 1]; |
---|
| 1585 | iCurAvg += piCur[n + 2]; |
---|
| 1586 | iCurAvg += piCur[n + 3]; |
---|
| 1587 | iCurAvg += piCur[n + 4]; |
---|
| 1588 | iCurAvg += piCur[n + 5]; |
---|
| 1589 | iCurAvg += piCur[n + 6]; |
---|
| 1590 | iCurAvg += piCur[n + 7]; |
---|
| 1591 | iCurAvg += piCur[n + 8]; |
---|
| 1592 | iCurAvg += piCur[n + 9]; |
---|
| 1593 | iCurAvg += piCur[n + 10]; |
---|
| 1594 | iCurAvg += piCur[n + 11]; |
---|
| 1595 | iCurAvg += piCur[n + 12]; |
---|
| 1596 | iCurAvg += piCur[n + 13]; |
---|
| 1597 | iCurAvg += piCur[n + 14]; |
---|
| 1598 | iCurAvg += piCur[n + 15]; |
---|
| 1599 | } |
---|
| 1600 | piOrg += iStrideOrg; |
---|
| 1601 | piCur += iStrideCur; |
---|
| 1602 | uiRowCnt++; |
---|
| 1603 | } |
---|
| 1604 | piOrg = pcDtParam->pOrg; |
---|
| 1605 | piCur = pcDtParam->pCur; |
---|
| 1606 | iRows = pcDtParam->iRows; |
---|
| 1607 | |
---|
| 1608 | iDeltaC = (uiRowCnt && uiColCnt) ? ((iOrigAvg - iCurAvg)/uiRowCnt/uiColCnt/16) : 0; |
---|
| 1609 | |
---|
| 1610 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1611 | { |
---|
| 1612 | for (Int n = 0; n < iCols; n+=16 ) |
---|
| 1613 | { |
---|
| 1614 | uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] - iDeltaC ); |
---|
| 1615 | uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] - iDeltaC ); |
---|
| 1616 | uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] - iDeltaC ); |
---|
| 1617 | uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] - iDeltaC ); |
---|
| 1618 | uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] - iDeltaC ); |
---|
| 1619 | uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] - iDeltaC ); |
---|
| 1620 | uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] - iDeltaC ); |
---|
| 1621 | uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] - iDeltaC ); |
---|
| 1622 | uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] - iDeltaC ); |
---|
| 1623 | uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] - iDeltaC ); |
---|
| 1624 | uiSum += abs( piOrg[n+10] - piCur[n+10] - iDeltaC ); |
---|
| 1625 | uiSum += abs( piOrg[n+11] - piCur[n+11] - iDeltaC ); |
---|
| 1626 | uiSum += abs( piOrg[n+12] - piCur[n+12] - iDeltaC ); |
---|
| 1627 | uiSum += abs( piOrg[n+13] - piCur[n+13] - iDeltaC ); |
---|
| 1628 | uiSum += abs( piOrg[n+14] - piCur[n+14] - iDeltaC ); |
---|
| 1629 | uiSum += abs( piOrg[n+15] - piCur[n+15] - iDeltaC ); |
---|
| 1630 | } |
---|
| 1631 | piOrg += iStrideOrg; |
---|
| 1632 | piCur += iStrideCur; |
---|
| 1633 | } |
---|
| 1634 | |
---|
| 1635 | uiSum <<= iSubShift; |
---|
| 1636 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
| 1637 | } |
---|
| 1638 | |
---|
| 1639 | UInt TComRdCost::xGetSAD32ic( DistParam* pcDtParam ) |
---|
| 1640 | { |
---|
| 1641 | if ( pcDtParam->bApplyWeight ) |
---|
| 1642 | { |
---|
| 1643 | return xGetSADw( pcDtParam ); |
---|
| 1644 | } |
---|
| 1645 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1646 | Pel* piCur = pcDtParam->pCur; |
---|
| 1647 | Int iRows = pcDtParam->iRows; |
---|
| 1648 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 1649 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 1650 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 1651 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 1652 | |
---|
| 1653 | UInt uiSum = 0; |
---|
| 1654 | |
---|
| 1655 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
| 1656 | Int iDeltaC; |
---|
| 1657 | |
---|
| 1658 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1659 | { |
---|
| 1660 | iOrigAvg += piOrg[0]; |
---|
| 1661 | iOrigAvg += piOrg[1]; |
---|
| 1662 | iOrigAvg += piOrg[2]; |
---|
| 1663 | iOrigAvg += piOrg[3]; |
---|
| 1664 | iOrigAvg += piOrg[4]; |
---|
| 1665 | iOrigAvg += piOrg[5]; |
---|
| 1666 | iOrigAvg += piOrg[6]; |
---|
| 1667 | iOrigAvg += piOrg[7]; |
---|
| 1668 | iOrigAvg += piOrg[8]; |
---|
| 1669 | iOrigAvg += piOrg[9]; |
---|
| 1670 | iOrigAvg += piOrg[10]; |
---|
| 1671 | iOrigAvg += piOrg[11]; |
---|
| 1672 | iOrigAvg += piOrg[12]; |
---|
| 1673 | iOrigAvg += piOrg[13]; |
---|
| 1674 | iOrigAvg += piOrg[14]; |
---|
| 1675 | iOrigAvg += piOrg[15]; |
---|
| 1676 | iOrigAvg += piOrg[16]; |
---|
| 1677 | iOrigAvg += piOrg[17]; |
---|
| 1678 | iOrigAvg += piOrg[18]; |
---|
| 1679 | iOrigAvg += piOrg[19]; |
---|
| 1680 | iOrigAvg += piOrg[20]; |
---|
| 1681 | iOrigAvg += piOrg[21]; |
---|
| 1682 | iOrigAvg += piOrg[22]; |
---|
| 1683 | iOrigAvg += piOrg[23]; |
---|
| 1684 | iOrigAvg += piOrg[24]; |
---|
| 1685 | iOrigAvg += piOrg[25]; |
---|
| 1686 | iOrigAvg += piOrg[26]; |
---|
| 1687 | iOrigAvg += piOrg[27]; |
---|
| 1688 | iOrigAvg += piOrg[28]; |
---|
| 1689 | iOrigAvg += piOrg[29]; |
---|
| 1690 | iOrigAvg += piOrg[30]; |
---|
| 1691 | iOrigAvg += piOrg[31]; |
---|
| 1692 | |
---|
| 1693 | iCurAvg += piCur[0]; |
---|
| 1694 | iCurAvg += piCur[1]; |
---|
| 1695 | iCurAvg += piCur[2]; |
---|
| 1696 | iCurAvg += piCur[3]; |
---|
| 1697 | iCurAvg += piCur[4]; |
---|
| 1698 | iCurAvg += piCur[5]; |
---|
| 1699 | iCurAvg += piCur[6]; |
---|
| 1700 | iCurAvg += piCur[7]; |
---|
| 1701 | iCurAvg += piCur[8]; |
---|
| 1702 | iCurAvg += piCur[9]; |
---|
| 1703 | iCurAvg += piCur[10]; |
---|
| 1704 | iCurAvg += piCur[11]; |
---|
| 1705 | iCurAvg += piCur[12]; |
---|
| 1706 | iCurAvg += piCur[13]; |
---|
| 1707 | iCurAvg += piCur[14]; |
---|
| 1708 | iCurAvg += piCur[15]; |
---|
| 1709 | iCurAvg += piCur[16]; |
---|
| 1710 | iCurAvg += piCur[17]; |
---|
| 1711 | iCurAvg += piCur[18]; |
---|
| 1712 | iCurAvg += piCur[19]; |
---|
| 1713 | iCurAvg += piCur[20]; |
---|
| 1714 | iCurAvg += piCur[21]; |
---|
| 1715 | iCurAvg += piCur[22]; |
---|
| 1716 | iCurAvg += piCur[23]; |
---|
| 1717 | iCurAvg += piCur[24]; |
---|
| 1718 | iCurAvg += piCur[25]; |
---|
| 1719 | iCurAvg += piCur[26]; |
---|
| 1720 | iCurAvg += piCur[27]; |
---|
| 1721 | iCurAvg += piCur[28]; |
---|
| 1722 | iCurAvg += piCur[29]; |
---|
| 1723 | iCurAvg += piCur[30]; |
---|
| 1724 | iCurAvg += piCur[31]; |
---|
| 1725 | |
---|
| 1726 | piOrg += iStrideOrg; |
---|
| 1727 | piCur += iStrideCur; |
---|
| 1728 | uiRowCnt++; |
---|
| 1729 | } |
---|
| 1730 | |
---|
| 1731 | piOrg = pcDtParam->pOrg; |
---|
| 1732 | piCur = pcDtParam->pCur; |
---|
| 1733 | iRows = pcDtParam->iRows; |
---|
| 1734 | |
---|
| 1735 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/32) : 0; |
---|
| 1736 | |
---|
| 1737 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1738 | { |
---|
| 1739 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
| 1740 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
| 1741 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
| 1742 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
| 1743 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
| 1744 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
| 1745 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
| 1746 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
| 1747 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
| 1748 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
| 1749 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
| 1750 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
| 1751 | uiSum += abs( piOrg[12] - piCur[12] - iDeltaC ); |
---|
| 1752 | uiSum += abs( piOrg[13] - piCur[13] - iDeltaC ); |
---|
| 1753 | uiSum += abs( piOrg[14] - piCur[14] - iDeltaC ); |
---|
| 1754 | uiSum += abs( piOrg[15] - piCur[15] - iDeltaC ); |
---|
| 1755 | uiSum += abs( piOrg[16] - piCur[16] - iDeltaC ); |
---|
| 1756 | uiSum += abs( piOrg[17] - piCur[17] - iDeltaC ); |
---|
| 1757 | uiSum += abs( piOrg[18] - piCur[18] - iDeltaC ); |
---|
| 1758 | uiSum += abs( piOrg[19] - piCur[19] - iDeltaC ); |
---|
| 1759 | uiSum += abs( piOrg[20] - piCur[20] - iDeltaC ); |
---|
| 1760 | uiSum += abs( piOrg[21] - piCur[21] - iDeltaC ); |
---|
| 1761 | uiSum += abs( piOrg[22] - piCur[22] - iDeltaC ); |
---|
| 1762 | uiSum += abs( piOrg[23] - piCur[23] - iDeltaC ); |
---|
| 1763 | uiSum += abs( piOrg[24] - piCur[24] - iDeltaC ); |
---|
| 1764 | uiSum += abs( piOrg[25] - piCur[25] - iDeltaC ); |
---|
| 1765 | uiSum += abs( piOrg[26] - piCur[26] - iDeltaC ); |
---|
| 1766 | uiSum += abs( piOrg[27] - piCur[27] - iDeltaC ); |
---|
| 1767 | uiSum += abs( piOrg[28] - piCur[28] - iDeltaC ); |
---|
| 1768 | uiSum += abs( piOrg[29] - piCur[29] - iDeltaC ); |
---|
| 1769 | uiSum += abs( piOrg[30] - piCur[30] - iDeltaC ); |
---|
| 1770 | uiSum += abs( piOrg[31] - piCur[31] - iDeltaC ); |
---|
| 1771 | |
---|
| 1772 | piOrg += iStrideOrg; |
---|
| 1773 | piCur += iStrideCur; |
---|
| 1774 | } |
---|
| 1775 | |
---|
| 1776 | uiSum <<= iSubShift; |
---|
| 1777 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
| 1778 | } |
---|
| 1779 | |
---|
| 1780 | #if AMP_SAD |
---|
| 1781 | UInt TComRdCost::xGetSAD24ic( DistParam* pcDtParam ) |
---|
| 1782 | { |
---|
| 1783 | if ( pcDtParam->bApplyWeight ) |
---|
| 1784 | { |
---|
| 1785 | return xGetSADw( pcDtParam ); |
---|
| 1786 | } |
---|
| 1787 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1788 | Pel* piCur = pcDtParam->pCur; |
---|
| 1789 | Int iRows = pcDtParam->iRows; |
---|
| 1790 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 1791 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 1792 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 1793 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 1794 | |
---|
| 1795 | UInt uiSum = 0; |
---|
| 1796 | |
---|
| 1797 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
| 1798 | Int iDeltaC; |
---|
| 1799 | |
---|
| 1800 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1801 | { |
---|
| 1802 | iOrigAvg += piOrg[0]; |
---|
| 1803 | iOrigAvg += piOrg[1]; |
---|
| 1804 | iOrigAvg += piOrg[2]; |
---|
| 1805 | iOrigAvg += piOrg[3]; |
---|
| 1806 | iOrigAvg += piOrg[4]; |
---|
| 1807 | iOrigAvg += piOrg[5]; |
---|
| 1808 | iOrigAvg += piOrg[6]; |
---|
| 1809 | iOrigAvg += piOrg[7]; |
---|
| 1810 | iOrigAvg += piOrg[8]; |
---|
| 1811 | iOrigAvg += piOrg[9]; |
---|
| 1812 | iOrigAvg += piOrg[10]; |
---|
| 1813 | iOrigAvg += piOrg[11]; |
---|
| 1814 | iOrigAvg += piOrg[12]; |
---|
| 1815 | iOrigAvg += piOrg[13]; |
---|
| 1816 | iOrigAvg += piOrg[14]; |
---|
| 1817 | iOrigAvg += piOrg[15]; |
---|
| 1818 | iOrigAvg += piOrg[16]; |
---|
| 1819 | iOrigAvg += piOrg[17]; |
---|
| 1820 | iOrigAvg += piOrg[18]; |
---|
| 1821 | iOrigAvg += piOrg[19]; |
---|
| 1822 | iOrigAvg += piOrg[20]; |
---|
| 1823 | iOrigAvg += piOrg[21]; |
---|
| 1824 | iOrigAvg += piOrg[22]; |
---|
| 1825 | iOrigAvg += piOrg[23]; |
---|
| 1826 | |
---|
| 1827 | iCurAvg += piCur[0]; |
---|
| 1828 | iCurAvg += piCur[1]; |
---|
| 1829 | iCurAvg += piCur[2]; |
---|
| 1830 | iCurAvg += piCur[3]; |
---|
| 1831 | iCurAvg += piCur[4]; |
---|
| 1832 | iCurAvg += piCur[5]; |
---|
| 1833 | iCurAvg += piCur[6]; |
---|
| 1834 | iCurAvg += piCur[7]; |
---|
| 1835 | iCurAvg += piCur[8]; |
---|
| 1836 | iCurAvg += piCur[9]; |
---|
| 1837 | iCurAvg += piCur[10]; |
---|
| 1838 | iCurAvg += piCur[11]; |
---|
| 1839 | iCurAvg += piCur[12]; |
---|
| 1840 | iCurAvg += piCur[13]; |
---|
| 1841 | iCurAvg += piCur[14]; |
---|
| 1842 | iCurAvg += piCur[15]; |
---|
| 1843 | iCurAvg += piCur[16]; |
---|
| 1844 | iCurAvg += piCur[17]; |
---|
| 1845 | iCurAvg += piCur[18]; |
---|
| 1846 | iCurAvg += piCur[19]; |
---|
| 1847 | iCurAvg += piCur[20]; |
---|
| 1848 | iCurAvg += piCur[21]; |
---|
| 1849 | iCurAvg += piCur[22]; |
---|
| 1850 | iCurAvg += piCur[23]; |
---|
| 1851 | |
---|
| 1852 | piOrg += iStrideOrg; |
---|
| 1853 | piCur += iStrideCur; |
---|
| 1854 | uiRowCnt++; |
---|
| 1855 | } |
---|
| 1856 | |
---|
| 1857 | piOrg = pcDtParam->pOrg; |
---|
| 1858 | piCur = pcDtParam->pCur; |
---|
| 1859 | iRows = pcDtParam->iRows; |
---|
| 1860 | |
---|
| 1861 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/24) : 0; |
---|
| 1862 | |
---|
| 1863 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1864 | { |
---|
| 1865 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
| 1866 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
| 1867 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
| 1868 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
| 1869 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
| 1870 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
| 1871 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
| 1872 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
| 1873 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
| 1874 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
| 1875 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
| 1876 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
| 1877 | uiSum += abs( piOrg[12] - piCur[12] - iDeltaC ); |
---|
| 1878 | uiSum += abs( piOrg[13] - piCur[13] - iDeltaC ); |
---|
| 1879 | uiSum += abs( piOrg[14] - piCur[14] - iDeltaC ); |
---|
| 1880 | uiSum += abs( piOrg[15] - piCur[15] - iDeltaC ); |
---|
| 1881 | uiSum += abs( piOrg[16] - piCur[16] - iDeltaC ); |
---|
| 1882 | uiSum += abs( piOrg[17] - piCur[17] - iDeltaC ); |
---|
| 1883 | uiSum += abs( piOrg[18] - piCur[18] - iDeltaC ); |
---|
| 1884 | uiSum += abs( piOrg[19] - piCur[19] - iDeltaC ); |
---|
| 1885 | uiSum += abs( piOrg[20] - piCur[20] - iDeltaC ); |
---|
| 1886 | uiSum += abs( piOrg[21] - piCur[21] - iDeltaC ); |
---|
| 1887 | uiSum += abs( piOrg[22] - piCur[22] - iDeltaC ); |
---|
| 1888 | uiSum += abs( piOrg[23] - piCur[23] - iDeltaC ); |
---|
| 1889 | |
---|
| 1890 | piOrg += iStrideOrg; |
---|
| 1891 | piCur += iStrideCur; |
---|
| 1892 | } |
---|
| 1893 | |
---|
| 1894 | uiSum <<= iSubShift; |
---|
| 1895 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
| 1896 | } |
---|
| 1897 | #endif |
---|
| 1898 | |
---|
| 1899 | UInt TComRdCost::xGetSAD64ic( DistParam* pcDtParam ) |
---|
| 1900 | { |
---|
| 1901 | if ( pcDtParam->bApplyWeight ) |
---|
| 1902 | { |
---|
| 1903 | return xGetSADw( pcDtParam ); |
---|
| 1904 | } |
---|
| 1905 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 1906 | Pel* piCur = pcDtParam->pCur; |
---|
| 1907 | Int iRows = pcDtParam->iRows; |
---|
| 1908 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 1909 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 1910 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 1911 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 1912 | |
---|
| 1913 | UInt uiSum = 0; |
---|
| 1914 | |
---|
| 1915 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
| 1916 | Int iDeltaC; |
---|
| 1917 | |
---|
| 1918 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 1919 | { |
---|
| 1920 | iOrigAvg += piOrg[0] ; |
---|
| 1921 | iOrigAvg += piOrg[1] ; |
---|
| 1922 | iOrigAvg += piOrg[2] ; |
---|
| 1923 | iOrigAvg += piOrg[3] ; |
---|
| 1924 | iOrigAvg += piOrg[4] ; |
---|
| 1925 | iOrigAvg += piOrg[5] ; |
---|
| 1926 | iOrigAvg += piOrg[6] ; |
---|
| 1927 | iOrigAvg += piOrg[7] ; |
---|
| 1928 | iOrigAvg += piOrg[8] ; |
---|
| 1929 | iOrigAvg += piOrg[9] ; |
---|
| 1930 | iOrigAvg += piOrg[10] ; |
---|
| 1931 | iOrigAvg += piOrg[11] ; |
---|
| 1932 | iOrigAvg += piOrg[12] ; |
---|
| 1933 | iOrigAvg += piOrg[13] ; |
---|
| 1934 | iOrigAvg += piOrg[14] ; |
---|
| 1935 | iOrigAvg += piOrg[15] ; |
---|
| 1936 | iOrigAvg += piOrg[16] ; |
---|
| 1937 | iOrigAvg += piOrg[17] ; |
---|
| 1938 | iOrigAvg += piOrg[18] ; |
---|
| 1939 | iOrigAvg += piOrg[19] ; |
---|
| 1940 | iOrigAvg += piOrg[20] ; |
---|
| 1941 | iOrigAvg += piOrg[21] ; |
---|
| 1942 | iOrigAvg += piOrg[22] ; |
---|
| 1943 | iOrigAvg += piOrg[23] ; |
---|
| 1944 | iOrigAvg += piOrg[24] ; |
---|
| 1945 | iOrigAvg += piOrg[25] ; |
---|
| 1946 | iOrigAvg += piOrg[26] ; |
---|
| 1947 | iOrigAvg += piOrg[27] ; |
---|
| 1948 | iOrigAvg += piOrg[28] ; |
---|
| 1949 | iOrigAvg += piOrg[29] ; |
---|
| 1950 | iOrigAvg += piOrg[30] ; |
---|
| 1951 | iOrigAvg += piOrg[31] ; |
---|
| 1952 | iOrigAvg += piOrg[32] ; |
---|
| 1953 | iOrigAvg += piOrg[33] ; |
---|
| 1954 | iOrigAvg += piOrg[34] ; |
---|
| 1955 | iOrigAvg += piOrg[35] ; |
---|
| 1956 | iOrigAvg += piOrg[36] ; |
---|
| 1957 | iOrigAvg += piOrg[37] ; |
---|
| 1958 | iOrigAvg += piOrg[38] ; |
---|
| 1959 | iOrigAvg += piOrg[39] ; |
---|
| 1960 | iOrigAvg += piOrg[40] ; |
---|
| 1961 | iOrigAvg += piOrg[41] ; |
---|
| 1962 | iOrigAvg += piOrg[42] ; |
---|
| 1963 | iOrigAvg += piOrg[43] ; |
---|
| 1964 | iOrigAvg += piOrg[44] ; |
---|
| 1965 | iOrigAvg += piOrg[45] ; |
---|
| 1966 | iOrigAvg += piOrg[46] ; |
---|
| 1967 | iOrigAvg += piOrg[47] ; |
---|
| 1968 | iOrigAvg += piOrg[48] ; |
---|
| 1969 | iOrigAvg += piOrg[49] ; |
---|
| 1970 | iOrigAvg += piOrg[50] ; |
---|
| 1971 | iOrigAvg += piOrg[51] ; |
---|
| 1972 | iOrigAvg += piOrg[52] ; |
---|
| 1973 | iOrigAvg += piOrg[53] ; |
---|
| 1974 | iOrigAvg += piOrg[54] ; |
---|
| 1975 | iOrigAvg += piOrg[55] ; |
---|
| 1976 | iOrigAvg += piOrg[56] ; |
---|
| 1977 | iOrigAvg += piOrg[57] ; |
---|
| 1978 | iOrigAvg += piOrg[58] ; |
---|
| 1979 | iOrigAvg += piOrg[59] ; |
---|
| 1980 | iOrigAvg += piOrg[60] ; |
---|
| 1981 | iOrigAvg += piOrg[61] ; |
---|
| 1982 | iOrigAvg += piOrg[62] ; |
---|
| 1983 | iOrigAvg += piOrg[63] ; |
---|
| 1984 | |
---|
| 1985 | iCurAvg += piCur[0] ; |
---|
| 1986 | iCurAvg += piCur[1] ; |
---|
| 1987 | iCurAvg += piCur[2] ; |
---|
| 1988 | iCurAvg += piCur[3] ; |
---|
| 1989 | iCurAvg += piCur[4] ; |
---|
| 1990 | iCurAvg += piCur[5] ; |
---|
| 1991 | iCurAvg += piCur[6] ; |
---|
| 1992 | iCurAvg += piCur[7] ; |
---|
| 1993 | iCurAvg += piCur[8] ; |
---|
| 1994 | iCurAvg += piCur[9] ; |
---|
| 1995 | iCurAvg += piCur[10] ; |
---|
| 1996 | iCurAvg += piCur[11] ; |
---|
| 1997 | iCurAvg += piCur[12] ; |
---|
| 1998 | iCurAvg += piCur[13] ; |
---|
| 1999 | iCurAvg += piCur[14] ; |
---|
| 2000 | iCurAvg += piCur[15] ; |
---|
| 2001 | iCurAvg += piCur[16] ; |
---|
| 2002 | iCurAvg += piCur[17] ; |
---|
| 2003 | iCurAvg += piCur[18] ; |
---|
| 2004 | iCurAvg += piCur[19] ; |
---|
| 2005 | iCurAvg += piCur[20] ; |
---|
| 2006 | iCurAvg += piCur[21] ; |
---|
| 2007 | iCurAvg += piCur[22] ; |
---|
| 2008 | iCurAvg += piCur[23] ; |
---|
| 2009 | iCurAvg += piCur[24] ; |
---|
| 2010 | iCurAvg += piCur[25] ; |
---|
| 2011 | iCurAvg += piCur[26] ; |
---|
| 2012 | iCurAvg += piCur[27] ; |
---|
| 2013 | iCurAvg += piCur[28] ; |
---|
| 2014 | iCurAvg += piCur[29] ; |
---|
| 2015 | iCurAvg += piCur[30] ; |
---|
| 2016 | iCurAvg += piCur[31] ; |
---|
| 2017 | iCurAvg += piCur[32] ; |
---|
| 2018 | iCurAvg += piCur[33] ; |
---|
| 2019 | iCurAvg += piCur[34] ; |
---|
| 2020 | iCurAvg += piCur[35] ; |
---|
| 2021 | iCurAvg += piCur[36] ; |
---|
| 2022 | iCurAvg += piCur[37] ; |
---|
| 2023 | iCurAvg += piCur[38] ; |
---|
| 2024 | iCurAvg += piCur[39] ; |
---|
| 2025 | iCurAvg += piCur[40] ; |
---|
| 2026 | iCurAvg += piCur[41] ; |
---|
| 2027 | iCurAvg += piCur[42] ; |
---|
| 2028 | iCurAvg += piCur[43] ; |
---|
| 2029 | iCurAvg += piCur[44] ; |
---|
| 2030 | iCurAvg += piCur[45] ; |
---|
| 2031 | iCurAvg += piCur[46] ; |
---|
| 2032 | iCurAvg += piCur[47] ; |
---|
| 2033 | iCurAvg += piCur[48] ; |
---|
| 2034 | iCurAvg += piCur[49] ; |
---|
| 2035 | iCurAvg += piCur[50] ; |
---|
| 2036 | iCurAvg += piCur[51] ; |
---|
| 2037 | iCurAvg += piCur[52] ; |
---|
| 2038 | iCurAvg += piCur[53] ; |
---|
| 2039 | iCurAvg += piCur[54] ; |
---|
| 2040 | iCurAvg += piCur[55] ; |
---|
| 2041 | iCurAvg += piCur[56] ; |
---|
| 2042 | iCurAvg += piCur[57] ; |
---|
| 2043 | iCurAvg += piCur[58] ; |
---|
| 2044 | iCurAvg += piCur[59] ; |
---|
| 2045 | iCurAvg += piCur[60] ; |
---|
| 2046 | iCurAvg += piCur[61] ; |
---|
| 2047 | iCurAvg += piCur[62] ; |
---|
| 2048 | iCurAvg += piCur[63] ; |
---|
| 2049 | |
---|
| 2050 | piOrg += iStrideOrg; |
---|
| 2051 | piCur += iStrideCur; |
---|
| 2052 | uiRowCnt++; |
---|
| 2053 | } |
---|
| 2054 | |
---|
| 2055 | piOrg = pcDtParam->pOrg; |
---|
| 2056 | piCur = pcDtParam->pCur; |
---|
| 2057 | iRows = pcDtParam->iRows; |
---|
| 2058 | |
---|
| 2059 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/64) : 0; |
---|
| 2060 | |
---|
| 2061 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 2062 | { |
---|
| 2063 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
| 2064 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
| 2065 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
| 2066 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
| 2067 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
| 2068 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
| 2069 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
| 2070 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
| 2071 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
| 2072 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
| 2073 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
| 2074 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
| 2075 | uiSum += abs( piOrg[12] - piCur[12] - iDeltaC ); |
---|
| 2076 | uiSum += abs( piOrg[13] - piCur[13] - iDeltaC ); |
---|
| 2077 | uiSum += abs( piOrg[14] - piCur[14] - iDeltaC ); |
---|
| 2078 | uiSum += abs( piOrg[15] - piCur[15] - iDeltaC ); |
---|
| 2079 | uiSum += abs( piOrg[16] - piCur[16] - iDeltaC ); |
---|
| 2080 | uiSum += abs( piOrg[17] - piCur[17] - iDeltaC ); |
---|
| 2081 | uiSum += abs( piOrg[18] - piCur[18] - iDeltaC ); |
---|
| 2082 | uiSum += abs( piOrg[19] - piCur[19] - iDeltaC ); |
---|
| 2083 | uiSum += abs( piOrg[20] - piCur[20] - iDeltaC ); |
---|
| 2084 | uiSum += abs( piOrg[21] - piCur[21] - iDeltaC ); |
---|
| 2085 | uiSum += abs( piOrg[22] - piCur[22] - iDeltaC ); |
---|
| 2086 | uiSum += abs( piOrg[23] - piCur[23] - iDeltaC ); |
---|
| 2087 | uiSum += abs( piOrg[24] - piCur[24] - iDeltaC ); |
---|
| 2088 | uiSum += abs( piOrg[25] - piCur[25] - iDeltaC ); |
---|
| 2089 | uiSum += abs( piOrg[26] - piCur[26] - iDeltaC ); |
---|
| 2090 | uiSum += abs( piOrg[27] - piCur[27] - iDeltaC ); |
---|
| 2091 | uiSum += abs( piOrg[28] - piCur[28] - iDeltaC ); |
---|
| 2092 | uiSum += abs( piOrg[29] - piCur[29] - iDeltaC ); |
---|
| 2093 | uiSum += abs( piOrg[30] - piCur[30] - iDeltaC ); |
---|
| 2094 | uiSum += abs( piOrg[31] - piCur[31] - iDeltaC ); |
---|
| 2095 | uiSum += abs( piOrg[32] - piCur[32] - iDeltaC ); |
---|
| 2096 | uiSum += abs( piOrg[33] - piCur[33] - iDeltaC ); |
---|
| 2097 | uiSum += abs( piOrg[34] - piCur[34] - iDeltaC ); |
---|
| 2098 | uiSum += abs( piOrg[35] - piCur[35] - iDeltaC ); |
---|
| 2099 | uiSum += abs( piOrg[36] - piCur[36] - iDeltaC ); |
---|
| 2100 | uiSum += abs( piOrg[37] - piCur[37] - iDeltaC ); |
---|
| 2101 | uiSum += abs( piOrg[38] - piCur[38] - iDeltaC ); |
---|
| 2102 | uiSum += abs( piOrg[39] - piCur[39] - iDeltaC ); |
---|
| 2103 | uiSum += abs( piOrg[40] - piCur[40] - iDeltaC ); |
---|
| 2104 | uiSum += abs( piOrg[41] - piCur[41] - iDeltaC ); |
---|
| 2105 | uiSum += abs( piOrg[42] - piCur[42] - iDeltaC ); |
---|
| 2106 | uiSum += abs( piOrg[43] - piCur[43] - iDeltaC ); |
---|
| 2107 | uiSum += abs( piOrg[44] - piCur[44] - iDeltaC ); |
---|
| 2108 | uiSum += abs( piOrg[45] - piCur[45] - iDeltaC ); |
---|
| 2109 | uiSum += abs( piOrg[46] - piCur[46] - iDeltaC ); |
---|
| 2110 | uiSum += abs( piOrg[47] - piCur[47] - iDeltaC ); |
---|
| 2111 | uiSum += abs( piOrg[48] - piCur[48] - iDeltaC ); |
---|
| 2112 | uiSum += abs( piOrg[49] - piCur[49] - iDeltaC ); |
---|
| 2113 | uiSum += abs( piOrg[50] - piCur[50] - iDeltaC ); |
---|
| 2114 | uiSum += abs( piOrg[51] - piCur[51] - iDeltaC ); |
---|
| 2115 | uiSum += abs( piOrg[52] - piCur[52] - iDeltaC ); |
---|
| 2116 | uiSum += abs( piOrg[53] - piCur[53] - iDeltaC ); |
---|
| 2117 | uiSum += abs( piOrg[54] - piCur[54] - iDeltaC ); |
---|
| 2118 | uiSum += abs( piOrg[55] - piCur[55] - iDeltaC ); |
---|
| 2119 | uiSum += abs( piOrg[56] - piCur[56] - iDeltaC ); |
---|
| 2120 | uiSum += abs( piOrg[57] - piCur[57] - iDeltaC ); |
---|
| 2121 | uiSum += abs( piOrg[58] - piCur[58] - iDeltaC ); |
---|
| 2122 | uiSum += abs( piOrg[59] - piCur[59] - iDeltaC ); |
---|
| 2123 | uiSum += abs( piOrg[60] - piCur[60] - iDeltaC ); |
---|
| 2124 | uiSum += abs( piOrg[61] - piCur[61] - iDeltaC ); |
---|
| 2125 | uiSum += abs( piOrg[62] - piCur[62] - iDeltaC ); |
---|
| 2126 | uiSum += abs( piOrg[63] - piCur[63] - iDeltaC ); |
---|
| 2127 | |
---|
| 2128 | piOrg += iStrideOrg; |
---|
| 2129 | piCur += iStrideCur; |
---|
| 2130 | } |
---|
| 2131 | |
---|
| 2132 | uiSum <<= iSubShift; |
---|
| 2133 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
| 2134 | } |
---|
| 2135 | |
---|
| 2136 | #if AMP_SAD |
---|
| 2137 | UInt TComRdCost::xGetSAD48ic( DistParam* pcDtParam ) |
---|
| 2138 | { |
---|
| 2139 | if ( pcDtParam->bApplyWeight ) |
---|
| 2140 | { |
---|
| 2141 | return xGetSADw( pcDtParam ); |
---|
| 2142 | } |
---|
| 2143 | |
---|
| 2144 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2145 | Pel* piCur = pcDtParam->pCur; |
---|
| 2146 | Int iRows = pcDtParam->iRows; |
---|
| 2147 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 2148 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 2149 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 2150 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
| 2151 | |
---|
| 2152 | UInt uiSum = 0; |
---|
| 2153 | |
---|
| 2154 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
| 2155 | Int iDeltaC; |
---|
| 2156 | |
---|
| 2157 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 2158 | { |
---|
| 2159 | iOrigAvg += piOrg[0] ; |
---|
| 2160 | iOrigAvg += piOrg[1] ; |
---|
| 2161 | iOrigAvg += piOrg[2] ; |
---|
| 2162 | iOrigAvg += piOrg[3] ; |
---|
| 2163 | iOrigAvg += piOrg[4] ; |
---|
| 2164 | iOrigAvg += piOrg[5] ; |
---|
| 2165 | iOrigAvg += piOrg[6] ; |
---|
| 2166 | iOrigAvg += piOrg[7] ; |
---|
| 2167 | iOrigAvg += piOrg[8] ; |
---|
| 2168 | iOrigAvg += piOrg[9] ; |
---|
| 2169 | iOrigAvg += piOrg[10] ; |
---|
| 2170 | iOrigAvg += piOrg[11] ; |
---|
| 2171 | iOrigAvg += piOrg[12] ; |
---|
| 2172 | iOrigAvg += piOrg[13] ; |
---|
| 2173 | iOrigAvg += piOrg[14] ; |
---|
| 2174 | iOrigAvg += piOrg[15] ; |
---|
| 2175 | iOrigAvg += piOrg[16] ; |
---|
| 2176 | iOrigAvg += piOrg[17] ; |
---|
| 2177 | iOrigAvg += piOrg[18] ; |
---|
| 2178 | iOrigAvg += piOrg[19] ; |
---|
| 2179 | iOrigAvg += piOrg[20] ; |
---|
| 2180 | iOrigAvg += piOrg[21] ; |
---|
| 2181 | iOrigAvg += piOrg[22] ; |
---|
| 2182 | iOrigAvg += piOrg[23] ; |
---|
| 2183 | iOrigAvg += piOrg[24] ; |
---|
| 2184 | iOrigAvg += piOrg[25] ; |
---|
| 2185 | iOrigAvg += piOrg[26] ; |
---|
| 2186 | iOrigAvg += piOrg[27] ; |
---|
| 2187 | iOrigAvg += piOrg[28] ; |
---|
| 2188 | iOrigAvg += piOrg[29] ; |
---|
| 2189 | iOrigAvg += piOrg[30] ; |
---|
| 2190 | iOrigAvg += piOrg[31] ; |
---|
| 2191 | iOrigAvg += piOrg[32] ; |
---|
| 2192 | iOrigAvg += piOrg[33] ; |
---|
| 2193 | iOrigAvg += piOrg[34] ; |
---|
| 2194 | iOrigAvg += piOrg[35] ; |
---|
| 2195 | iOrigAvg += piOrg[36] ; |
---|
| 2196 | iOrigAvg += piOrg[37] ; |
---|
| 2197 | iOrigAvg += piOrg[38] ; |
---|
| 2198 | iOrigAvg += piOrg[39] ; |
---|
| 2199 | iOrigAvg += piOrg[40] ; |
---|
| 2200 | iOrigAvg += piOrg[41] ; |
---|
| 2201 | iOrigAvg += piOrg[42] ; |
---|
| 2202 | iOrigAvg += piOrg[43] ; |
---|
| 2203 | iOrigAvg += piOrg[44] ; |
---|
| 2204 | iOrigAvg += piOrg[45] ; |
---|
| 2205 | iOrigAvg += piOrg[46] ; |
---|
| 2206 | iOrigAvg += piOrg[47] ; |
---|
| 2207 | |
---|
| 2208 | iCurAvg += piCur[0] ; |
---|
| 2209 | iCurAvg += piCur[1] ; |
---|
| 2210 | iCurAvg += piCur[2] ; |
---|
| 2211 | iCurAvg += piCur[3] ; |
---|
| 2212 | iCurAvg += piCur[4] ; |
---|
| 2213 | iCurAvg += piCur[5] ; |
---|
| 2214 | iCurAvg += piCur[6] ; |
---|
| 2215 | iCurAvg += piCur[7] ; |
---|
| 2216 | iCurAvg += piCur[8] ; |
---|
| 2217 | iCurAvg += piCur[9] ; |
---|
| 2218 | iCurAvg += piCur[10] ; |
---|
| 2219 | iCurAvg += piCur[11] ; |
---|
| 2220 | iCurAvg += piCur[12] ; |
---|
| 2221 | iCurAvg += piCur[13] ; |
---|
| 2222 | iCurAvg += piCur[14] ; |
---|
| 2223 | iCurAvg += piCur[15] ; |
---|
| 2224 | iCurAvg += piCur[16] ; |
---|
| 2225 | iCurAvg += piCur[17] ; |
---|
| 2226 | iCurAvg += piCur[18] ; |
---|
| 2227 | iCurAvg += piCur[19] ; |
---|
| 2228 | iCurAvg += piCur[20] ; |
---|
| 2229 | iCurAvg += piCur[21] ; |
---|
| 2230 | iCurAvg += piCur[22] ; |
---|
| 2231 | iCurAvg += piCur[23] ; |
---|
| 2232 | iCurAvg += piCur[24] ; |
---|
| 2233 | iCurAvg += piCur[25] ; |
---|
| 2234 | iCurAvg += piCur[26] ; |
---|
| 2235 | iCurAvg += piCur[27] ; |
---|
| 2236 | iCurAvg += piCur[28] ; |
---|
| 2237 | iCurAvg += piCur[29] ; |
---|
| 2238 | iCurAvg += piCur[30] ; |
---|
| 2239 | iCurAvg += piCur[31] ; |
---|
| 2240 | iCurAvg += piCur[32] ; |
---|
| 2241 | iCurAvg += piCur[33] ; |
---|
| 2242 | iCurAvg += piCur[34] ; |
---|
| 2243 | iCurAvg += piCur[35] ; |
---|
| 2244 | iCurAvg += piCur[36] ; |
---|
| 2245 | iCurAvg += piCur[37] ; |
---|
| 2246 | iCurAvg += piCur[38] ; |
---|
| 2247 | iCurAvg += piCur[39] ; |
---|
| 2248 | iCurAvg += piCur[40] ; |
---|
| 2249 | iCurAvg += piCur[41] ; |
---|
| 2250 | iCurAvg += piCur[42] ; |
---|
| 2251 | iCurAvg += piCur[43] ; |
---|
| 2252 | iCurAvg += piCur[44] ; |
---|
| 2253 | iCurAvg += piCur[45] ; |
---|
| 2254 | iCurAvg += piCur[46] ; |
---|
| 2255 | iCurAvg += piCur[47] ; |
---|
| 2256 | |
---|
| 2257 | piOrg += iStrideOrg; |
---|
| 2258 | piCur += iStrideCur; |
---|
| 2259 | uiRowCnt++; |
---|
| 2260 | } |
---|
| 2261 | |
---|
| 2262 | piOrg = pcDtParam->pOrg; |
---|
| 2263 | piCur = pcDtParam->pCur; |
---|
| 2264 | iRows = pcDtParam->iRows; |
---|
| 2265 | |
---|
| 2266 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/48) : 0; |
---|
| 2267 | |
---|
| 2268 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 2269 | { |
---|
| 2270 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
| 2271 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
| 2272 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
| 2273 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
| 2274 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
| 2275 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
| 2276 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
| 2277 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
| 2278 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
| 2279 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
| 2280 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
| 2281 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
| 2282 | uiSum += abs( piOrg[12] - piCur[12] - iDeltaC ); |
---|
| 2283 | uiSum += abs( piOrg[13] - piCur[13] - iDeltaC ); |
---|
| 2284 | uiSum += abs( piOrg[14] - piCur[14] - iDeltaC ); |
---|
| 2285 | uiSum += abs( piOrg[15] - piCur[15] - iDeltaC ); |
---|
| 2286 | uiSum += abs( piOrg[16] - piCur[16] - iDeltaC ); |
---|
| 2287 | uiSum += abs( piOrg[17] - piCur[17] - iDeltaC ); |
---|
| 2288 | uiSum += abs( piOrg[18] - piCur[18] - iDeltaC ); |
---|
| 2289 | uiSum += abs( piOrg[19] - piCur[19] - iDeltaC ); |
---|
| 2290 | uiSum += abs( piOrg[20] - piCur[20] - iDeltaC ); |
---|
| 2291 | uiSum += abs( piOrg[21] - piCur[21] - iDeltaC ); |
---|
| 2292 | uiSum += abs( piOrg[22] - piCur[22] - iDeltaC ); |
---|
| 2293 | uiSum += abs( piOrg[23] - piCur[23] - iDeltaC ); |
---|
| 2294 | uiSum += abs( piOrg[24] - piCur[24] - iDeltaC ); |
---|
| 2295 | uiSum += abs( piOrg[25] - piCur[25] - iDeltaC ); |
---|
| 2296 | uiSum += abs( piOrg[26] - piCur[26] - iDeltaC ); |
---|
| 2297 | uiSum += abs( piOrg[27] - piCur[27] - iDeltaC ); |
---|
| 2298 | uiSum += abs( piOrg[28] - piCur[28] - iDeltaC ); |
---|
| 2299 | uiSum += abs( piOrg[29] - piCur[29] - iDeltaC ); |
---|
| 2300 | uiSum += abs( piOrg[30] - piCur[30] - iDeltaC ); |
---|
| 2301 | uiSum += abs( piOrg[31] - piCur[31] - iDeltaC ); |
---|
| 2302 | uiSum += abs( piOrg[32] - piCur[32] - iDeltaC ); |
---|
| 2303 | uiSum += abs( piOrg[33] - piCur[33] - iDeltaC ); |
---|
| 2304 | uiSum += abs( piOrg[34] - piCur[34] - iDeltaC ); |
---|
| 2305 | uiSum += abs( piOrg[35] - piCur[35] - iDeltaC ); |
---|
| 2306 | uiSum += abs( piOrg[36] - piCur[36] - iDeltaC ); |
---|
| 2307 | uiSum += abs( piOrg[37] - piCur[37] - iDeltaC ); |
---|
| 2308 | uiSum += abs( piOrg[38] - piCur[38] - iDeltaC ); |
---|
| 2309 | uiSum += abs( piOrg[39] - piCur[39] - iDeltaC ); |
---|
| 2310 | uiSum += abs( piOrg[40] - piCur[40] - iDeltaC ); |
---|
| 2311 | uiSum += abs( piOrg[41] - piCur[41] - iDeltaC ); |
---|
| 2312 | uiSum += abs( piOrg[42] - piCur[42] - iDeltaC ); |
---|
| 2313 | uiSum += abs( piOrg[43] - piCur[43] - iDeltaC ); |
---|
| 2314 | uiSum += abs( piOrg[44] - piCur[44] - iDeltaC ); |
---|
| 2315 | uiSum += abs( piOrg[45] - piCur[45] - iDeltaC ); |
---|
| 2316 | uiSum += abs( piOrg[46] - piCur[46] - iDeltaC ); |
---|
| 2317 | uiSum += abs( piOrg[47] - piCur[47] - iDeltaC ); |
---|
| 2318 | |
---|
| 2319 | piOrg += iStrideOrg; |
---|
| 2320 | piCur += iStrideCur; |
---|
| 2321 | } |
---|
| 2322 | |
---|
| 2323 | uiSum <<= iSubShift; |
---|
| 2324 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
| 2325 | } |
---|
| 2326 | #endif |
---|
| 2327 | |
---|
| 2328 | #endif |
---|
[324] | 2329 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 2330 | // SSE |
---|
| 2331 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 2332 | |
---|
| 2333 | UInt TComRdCost::xGetSSE( DistParam* pcDtParam ) |
---|
| 2334 | { |
---|
| 2335 | if ( pcDtParam->bApplyWeight ) |
---|
| 2336 | { |
---|
| 2337 | return xGetSSEw( pcDtParam ); |
---|
| 2338 | } |
---|
| 2339 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2340 | Pel* piCur = pcDtParam->pCur; |
---|
| 2341 | Int iRows = pcDtParam->iRows; |
---|
| 2342 | Int iCols = pcDtParam->iCols; |
---|
| 2343 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2344 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2345 | |
---|
| 2346 | UInt uiSum = 0; |
---|
| 2347 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 2348 | |
---|
| 2349 | Int iTemp; |
---|
| 2350 | |
---|
| 2351 | for( ; iRows != 0; iRows-- ) |
---|
| 2352 | { |
---|
| 2353 | for (Int n = 0; n < iCols; n++ ) |
---|
| 2354 | { |
---|
| 2355 | iTemp = piOrg[n ] - piCur[n ]; |
---|
| 2356 | uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2357 | } |
---|
| 2358 | piOrg += iStrideOrg; |
---|
| 2359 | piCur += iStrideCur; |
---|
| 2360 | } |
---|
| 2361 | |
---|
| 2362 | return ( uiSum ); |
---|
| 2363 | } |
---|
| 2364 | |
---|
| 2365 | UInt TComRdCost::xGetSSE4( DistParam* pcDtParam ) |
---|
| 2366 | { |
---|
| 2367 | if ( pcDtParam->bApplyWeight ) |
---|
| 2368 | { |
---|
| 2369 | assert( pcDtParam->iCols == 4 ); |
---|
| 2370 | return xGetSSEw( pcDtParam ); |
---|
| 2371 | } |
---|
| 2372 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2373 | Pel* piCur = pcDtParam->pCur; |
---|
| 2374 | Int iRows = pcDtParam->iRows; |
---|
| 2375 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2376 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2377 | |
---|
| 2378 | UInt uiSum = 0; |
---|
| 2379 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 2380 | |
---|
| 2381 | Int iTemp; |
---|
| 2382 | |
---|
| 2383 | for( ; iRows != 0; iRows-- ) |
---|
| 2384 | { |
---|
| 2385 | |
---|
| 2386 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2387 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2388 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2389 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2390 | |
---|
| 2391 | piOrg += iStrideOrg; |
---|
| 2392 | piCur += iStrideCur; |
---|
| 2393 | } |
---|
| 2394 | |
---|
| 2395 | return ( uiSum ); |
---|
| 2396 | } |
---|
| 2397 | |
---|
| 2398 | UInt TComRdCost::xGetSSE8( DistParam* pcDtParam ) |
---|
| 2399 | { |
---|
| 2400 | if ( pcDtParam->bApplyWeight ) |
---|
| 2401 | { |
---|
| 2402 | assert( pcDtParam->iCols == 8 ); |
---|
| 2403 | return xGetSSEw( pcDtParam ); |
---|
| 2404 | } |
---|
| 2405 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2406 | Pel* piCur = pcDtParam->pCur; |
---|
| 2407 | Int iRows = pcDtParam->iRows; |
---|
| 2408 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2409 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2410 | |
---|
| 2411 | UInt uiSum = 0; |
---|
| 2412 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 2413 | |
---|
| 2414 | Int iTemp; |
---|
| 2415 | |
---|
| 2416 | for( ; iRows != 0; iRows-- ) |
---|
| 2417 | { |
---|
| 2418 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2419 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2420 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2421 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2422 | iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2423 | iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2424 | iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2425 | iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2426 | |
---|
| 2427 | piOrg += iStrideOrg; |
---|
| 2428 | piCur += iStrideCur; |
---|
| 2429 | } |
---|
| 2430 | |
---|
| 2431 | return ( uiSum ); |
---|
| 2432 | } |
---|
| 2433 | |
---|
| 2434 | UInt TComRdCost::xGetSSE16( DistParam* pcDtParam ) |
---|
| 2435 | { |
---|
| 2436 | if ( pcDtParam->bApplyWeight ) |
---|
| 2437 | { |
---|
| 2438 | assert( pcDtParam->iCols == 16 ); |
---|
| 2439 | return xGetSSEw( pcDtParam ); |
---|
| 2440 | } |
---|
| 2441 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2442 | Pel* piCur = pcDtParam->pCur; |
---|
| 2443 | Int iRows = pcDtParam->iRows; |
---|
| 2444 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2445 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2446 | |
---|
| 2447 | UInt uiSum = 0; |
---|
| 2448 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 2449 | |
---|
| 2450 | Int iTemp; |
---|
| 2451 | |
---|
| 2452 | for( ; iRows != 0; iRows-- ) |
---|
| 2453 | { |
---|
| 2454 | |
---|
| 2455 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2456 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2457 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2458 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2459 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2460 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2461 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2462 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2463 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2464 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2465 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2466 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2467 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2468 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2469 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2470 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2471 | |
---|
| 2472 | piOrg += iStrideOrg; |
---|
| 2473 | piCur += iStrideCur; |
---|
| 2474 | } |
---|
| 2475 | |
---|
| 2476 | return ( uiSum ); |
---|
| 2477 | } |
---|
| 2478 | |
---|
| 2479 | UInt TComRdCost::xGetSSE16N( DistParam* pcDtParam ) |
---|
| 2480 | { |
---|
| 2481 | if ( pcDtParam->bApplyWeight ) |
---|
| 2482 | { |
---|
| 2483 | return xGetSSEw( pcDtParam ); |
---|
| 2484 | } |
---|
| 2485 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2486 | Pel* piCur = pcDtParam->pCur; |
---|
| 2487 | Int iRows = pcDtParam->iRows; |
---|
| 2488 | Int iCols = pcDtParam->iCols; |
---|
| 2489 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2490 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2491 | |
---|
| 2492 | UInt uiSum = 0; |
---|
| 2493 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 2494 | Int iTemp; |
---|
| 2495 | |
---|
| 2496 | for( ; iRows != 0; iRows-- ) |
---|
| 2497 | { |
---|
| 2498 | for (Int n = 0; n < iCols; n+=16 ) |
---|
| 2499 | { |
---|
| 2500 | |
---|
| 2501 | iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2502 | iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2503 | iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2504 | iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2505 | iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2506 | iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2507 | iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2508 | iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2509 | iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2510 | iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2511 | iTemp = piOrg[n+10] - piCur[n+10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2512 | iTemp = piOrg[n+11] - piCur[n+11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2513 | iTemp = piOrg[n+12] - piCur[n+12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2514 | iTemp = piOrg[n+13] - piCur[n+13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2515 | iTemp = piOrg[n+14] - piCur[n+14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2516 | iTemp = piOrg[n+15] - piCur[n+15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2517 | |
---|
| 2518 | } |
---|
| 2519 | piOrg += iStrideOrg; |
---|
| 2520 | piCur += iStrideCur; |
---|
| 2521 | } |
---|
| 2522 | |
---|
| 2523 | return ( uiSum ); |
---|
| 2524 | } |
---|
| 2525 | |
---|
| 2526 | UInt TComRdCost::xGetSSE32( DistParam* pcDtParam ) |
---|
| 2527 | { |
---|
| 2528 | if ( pcDtParam->bApplyWeight ) |
---|
| 2529 | { |
---|
| 2530 | assert( pcDtParam->iCols == 32 ); |
---|
| 2531 | return xGetSSEw( pcDtParam ); |
---|
| 2532 | } |
---|
| 2533 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2534 | Pel* piCur = pcDtParam->pCur; |
---|
| 2535 | Int iRows = pcDtParam->iRows; |
---|
| 2536 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2537 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2538 | |
---|
| 2539 | UInt uiSum = 0; |
---|
| 2540 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 2541 | Int iTemp; |
---|
| 2542 | |
---|
| 2543 | for( ; iRows != 0; iRows-- ) |
---|
| 2544 | { |
---|
| 2545 | |
---|
| 2546 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2547 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2548 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2549 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2550 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2551 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2552 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2553 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2554 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2555 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2556 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2557 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2558 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2559 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2560 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2561 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2562 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2563 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2564 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2565 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2566 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2567 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2568 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2569 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2570 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2571 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2572 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2573 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2574 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2575 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2576 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2577 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2578 | |
---|
| 2579 | piOrg += iStrideOrg; |
---|
| 2580 | piCur += iStrideCur; |
---|
| 2581 | } |
---|
| 2582 | |
---|
| 2583 | return ( uiSum ); |
---|
| 2584 | } |
---|
| 2585 | |
---|
| 2586 | UInt TComRdCost::xGetSSE64( DistParam* pcDtParam ) |
---|
| 2587 | { |
---|
| 2588 | if ( pcDtParam->bApplyWeight ) |
---|
| 2589 | { |
---|
| 2590 | assert( pcDtParam->iCols == 64 ); |
---|
| 2591 | return xGetSSEw( pcDtParam ); |
---|
| 2592 | } |
---|
| 2593 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2594 | Pel* piCur = pcDtParam->pCur; |
---|
| 2595 | Int iRows = pcDtParam->iRows; |
---|
| 2596 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2597 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2598 | |
---|
| 2599 | UInt uiSum = 0; |
---|
| 2600 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
| 2601 | Int iTemp; |
---|
| 2602 | |
---|
| 2603 | for( ; iRows != 0; iRows-- ) |
---|
| 2604 | { |
---|
| 2605 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2606 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2607 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2608 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2609 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2610 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2611 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2612 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2613 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2614 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2615 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2616 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2617 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2618 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2619 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2620 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2621 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2622 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2623 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2624 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2625 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2626 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2627 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2628 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2629 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2630 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2631 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2632 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2633 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2634 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2635 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2636 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2637 | iTemp = piOrg[32] - piCur[32]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2638 | iTemp = piOrg[33] - piCur[33]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2639 | iTemp = piOrg[34] - piCur[34]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2640 | iTemp = piOrg[35] - piCur[35]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2641 | iTemp = piOrg[36] - piCur[36]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2642 | iTemp = piOrg[37] - piCur[37]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2643 | iTemp = piOrg[38] - piCur[38]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2644 | iTemp = piOrg[39] - piCur[39]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2645 | iTemp = piOrg[40] - piCur[40]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2646 | iTemp = piOrg[41] - piCur[41]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2647 | iTemp = piOrg[42] - piCur[42]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2648 | iTemp = piOrg[43] - piCur[43]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2649 | iTemp = piOrg[44] - piCur[44]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2650 | iTemp = piOrg[45] - piCur[45]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2651 | iTemp = piOrg[46] - piCur[46]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2652 | iTemp = piOrg[47] - piCur[47]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2653 | iTemp = piOrg[48] - piCur[48]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2654 | iTemp = piOrg[49] - piCur[49]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2655 | iTemp = piOrg[50] - piCur[50]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2656 | iTemp = piOrg[51] - piCur[51]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2657 | iTemp = piOrg[52] - piCur[52]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2658 | iTemp = piOrg[53] - piCur[53]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2659 | iTemp = piOrg[54] - piCur[54]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2660 | iTemp = piOrg[55] - piCur[55]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2661 | iTemp = piOrg[56] - piCur[56]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2662 | iTemp = piOrg[57] - piCur[57]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2663 | iTemp = piOrg[58] - piCur[58]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2664 | iTemp = piOrg[59] - piCur[59]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2665 | iTemp = piOrg[60] - piCur[60]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2666 | iTemp = piOrg[61] - piCur[61]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2667 | iTemp = piOrg[62] - piCur[62]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2668 | iTemp = piOrg[63] - piCur[63]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
| 2669 | |
---|
| 2670 | piOrg += iStrideOrg; |
---|
| 2671 | piCur += iStrideCur; |
---|
| 2672 | } |
---|
| 2673 | |
---|
| 2674 | return ( uiSum ); |
---|
| 2675 | } |
---|
[446] | 2676 | #if H_3D_VSO |
---|
| 2677 | //SAIT_VSO_EST_A0033 |
---|
| 2678 | UInt TComRdCost::getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride, Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y ) |
---|
| 2679 | { |
---|
| 2680 | Double dD; |
---|
| 2681 | Int iTemp; |
---|
[324] | 2682 | |
---|
[446] | 2683 | dD = ( (Double) ( dDM >> DISTORTION_PRECISION_ADJUSTMENT( g_bitDepthY - 8 ) ) ) * m_dDisparityCoeff; |
---|
| 2684 | |
---|
| 2685 | Double dTemp = ( 0.5 * fabs(dD) * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) ); |
---|
| 2686 | iTemp = (Int) (((dTemp) < 0)? (Int)((dTemp) - 0.5) : (Int)((dTemp) + 0.5)); |
---|
| 2687 | |
---|
| 2688 | return (UInt) ( (iTemp*iTemp)>>1 ); |
---|
| 2689 | } |
---|
| 2690 | |
---|
| 2691 | UInt TComRdCost::xGetVSD( DistParam* pcDtParam ) |
---|
| 2692 | { |
---|
| 2693 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2694 | Pel* piCur = pcDtParam->pCur; |
---|
| 2695 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
| 2696 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
| 2697 | Int iRows = pcDtParam->iRows; |
---|
| 2698 | Int iCols = pcDtParam->iCols; |
---|
| 2699 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2700 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2701 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
| 2702 | |
---|
| 2703 | UInt uiSum = 0; |
---|
| 2704 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
| 2705 | |
---|
| 2706 | Int dDM; |
---|
| 2707 | |
---|
| 2708 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
| 2709 | { |
---|
| 2710 | for (Int x = 0; x < iCols; x++ ) |
---|
| 2711 | { |
---|
| 2712 | dDM = (Int) ( piOrg[x ] - piCur[x ] ); |
---|
| 2713 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
| 2714 | } |
---|
| 2715 | piOrg += iStrideOrg; |
---|
| 2716 | piCur += iStrideCur; |
---|
| 2717 | } |
---|
| 2718 | |
---|
| 2719 | return ( uiSum ); |
---|
| 2720 | } |
---|
| 2721 | |
---|
| 2722 | UInt TComRdCost::xGetVSD4( DistParam* pcDtParam ) |
---|
| 2723 | { |
---|
| 2724 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2725 | Pel* piCur = pcDtParam->pCur; |
---|
| 2726 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
| 2727 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
| 2728 | Int iRows = pcDtParam->iRows; |
---|
| 2729 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2730 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2731 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
| 2732 | |
---|
| 2733 | UInt uiSum = 0; |
---|
| 2734 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
| 2735 | |
---|
| 2736 | Int dDM; |
---|
| 2737 | |
---|
| 2738 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
| 2739 | { |
---|
| 2740 | dDM = (Int) ( piOrg[0] - piCur[0] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 0, y ) ) >> uiShift; |
---|
| 2741 | dDM = (Int) ( piOrg[1] - piCur[1] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 1, y ) ) >> uiShift; |
---|
| 2742 | dDM = (Int) ( piOrg[2] - piCur[2] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 2, y ) ) >> uiShift; |
---|
| 2743 | dDM = (Int) ( piOrg[3] - piCur[3] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 3, y ) ) >> uiShift; |
---|
| 2744 | |
---|
| 2745 | piOrg += iStrideOrg; |
---|
| 2746 | piCur += iStrideCur; |
---|
| 2747 | } |
---|
| 2748 | |
---|
| 2749 | return ( uiSum ); |
---|
| 2750 | } |
---|
| 2751 | |
---|
| 2752 | UInt TComRdCost::xGetVSD8( DistParam* pcDtParam ) |
---|
| 2753 | { |
---|
| 2754 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2755 | Pel* piCur = pcDtParam->pCur; |
---|
| 2756 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
| 2757 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
| 2758 | Int iRows = pcDtParam->iRows; |
---|
| 2759 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2760 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2761 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
| 2762 | |
---|
| 2763 | UInt uiSum = 0; |
---|
| 2764 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
| 2765 | |
---|
| 2766 | Int dDM; |
---|
| 2767 | |
---|
| 2768 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
| 2769 | { |
---|
| 2770 | for (Int x = 0; x < 8; x++ ) |
---|
| 2771 | { |
---|
| 2772 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
| 2773 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
| 2774 | } |
---|
| 2775 | piOrg += iStrideOrg; |
---|
| 2776 | piCur += iStrideCur; |
---|
| 2777 | } |
---|
| 2778 | |
---|
| 2779 | return ( uiSum ); |
---|
| 2780 | } |
---|
| 2781 | |
---|
| 2782 | UInt TComRdCost::xGetVSD16( DistParam* pcDtParam ) |
---|
| 2783 | { |
---|
| 2784 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2785 | Pel* piCur = pcDtParam->pCur; |
---|
| 2786 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
| 2787 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
| 2788 | Int iRows = pcDtParam->iRows; |
---|
| 2789 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2790 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2791 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
| 2792 | |
---|
| 2793 | UInt uiSum = 0; |
---|
| 2794 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
| 2795 | |
---|
| 2796 | Int dDM; |
---|
| 2797 | |
---|
| 2798 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
| 2799 | { |
---|
| 2800 | for (Int x = 0; x < 16; x++ ) |
---|
| 2801 | { |
---|
| 2802 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
| 2803 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
| 2804 | } |
---|
| 2805 | piOrg += iStrideOrg; |
---|
| 2806 | piCur += iStrideCur; |
---|
| 2807 | } |
---|
| 2808 | |
---|
| 2809 | return ( uiSum ); |
---|
| 2810 | } |
---|
| 2811 | |
---|
| 2812 | UInt TComRdCost::xGetVSD16N( DistParam* pcDtParam ) |
---|
| 2813 | { |
---|
| 2814 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2815 | Pel* piCur = pcDtParam->pCur; |
---|
| 2816 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
| 2817 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
| 2818 | Int iRows = pcDtParam->iRows; |
---|
| 2819 | Int iCols = pcDtParam->iCols; |
---|
| 2820 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2821 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2822 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
| 2823 | |
---|
| 2824 | UInt uiSum = 0; |
---|
| 2825 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
| 2826 | |
---|
| 2827 | Int dDM; |
---|
| 2828 | |
---|
| 2829 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
| 2830 | { |
---|
| 2831 | for (Int x = 0; x < iCols; x+=16 ) |
---|
| 2832 | { |
---|
| 2833 | for ( Int k = 0 ; k < 16 ; k++ ) |
---|
| 2834 | { |
---|
| 2835 | dDM = (Int) ( piOrg[x+k] - piCur[x+k] ); |
---|
| 2836 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x+k, y ) >> uiShift; |
---|
| 2837 | } |
---|
| 2838 | } |
---|
| 2839 | piOrg += iStrideOrg; |
---|
| 2840 | piCur += iStrideCur; |
---|
| 2841 | } |
---|
| 2842 | |
---|
| 2843 | return ( uiSum ); |
---|
| 2844 | } |
---|
| 2845 | |
---|
| 2846 | UInt TComRdCost::xGetVSD32( DistParam* pcDtParam ) |
---|
| 2847 | { |
---|
| 2848 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2849 | Pel* piCur = pcDtParam->pCur; |
---|
| 2850 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
| 2851 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
| 2852 | Int iRows = pcDtParam->iRows; |
---|
| 2853 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2854 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2855 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
| 2856 | |
---|
| 2857 | UInt uiSum = 0; |
---|
| 2858 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
| 2859 | |
---|
| 2860 | Int dDM; |
---|
| 2861 | |
---|
| 2862 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
| 2863 | { |
---|
| 2864 | for (Int x = 0; x < 32 ; x++ ) |
---|
| 2865 | { |
---|
| 2866 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
| 2867 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
| 2868 | } |
---|
| 2869 | piOrg += iStrideOrg; |
---|
| 2870 | piCur += iStrideCur; |
---|
| 2871 | } |
---|
| 2872 | |
---|
| 2873 | return ( uiSum ); |
---|
| 2874 | } |
---|
| 2875 | |
---|
| 2876 | UInt TComRdCost::xGetVSD64( DistParam* pcDtParam ) |
---|
| 2877 | { |
---|
| 2878 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 2879 | Pel* piCur = pcDtParam->pCur; |
---|
| 2880 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
| 2881 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
| 2882 | Int iRows = pcDtParam->iRows; |
---|
| 2883 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 2884 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 2885 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
| 2886 | |
---|
| 2887 | UInt uiSum = 0; |
---|
| 2888 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
| 2889 | |
---|
| 2890 | Int dDM; |
---|
| 2891 | |
---|
| 2892 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
| 2893 | { |
---|
| 2894 | for (Int x = 0; x < 64; x++ ) |
---|
| 2895 | { |
---|
| 2896 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
| 2897 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
| 2898 | } |
---|
| 2899 | piOrg += iStrideOrg; |
---|
| 2900 | piCur += iStrideCur; |
---|
| 2901 | } |
---|
| 2902 | |
---|
| 2903 | return ( uiSum ); |
---|
| 2904 | } |
---|
| 2905 | |
---|
| 2906 | #endif |
---|
| 2907 | |
---|
[324] | 2908 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 2909 | // HADAMARD with step (used in fractional search) |
---|
| 2910 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 2911 | |
---|
| 2912 | UInt TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
| 2913 | { |
---|
| 2914 | Int satd = 0, diff[4], m[4]; |
---|
| 2915 | assert( iStep == 1 ); |
---|
| 2916 | diff[0] = piOrg[0 ] - piCur[0]; |
---|
| 2917 | diff[1] = piOrg[1 ] - piCur[1]; |
---|
| 2918 | diff[2] = piOrg[iStrideOrg ] - piCur[0 + iStrideCur]; |
---|
| 2919 | diff[3] = piOrg[iStrideOrg + 1] - piCur[1 + iStrideCur]; |
---|
| 2920 | m[0] = diff[0] + diff[2]; |
---|
| 2921 | m[1] = diff[1] + diff[3]; |
---|
| 2922 | m[2] = diff[0] - diff[2]; |
---|
| 2923 | m[3] = diff[1] - diff[3]; |
---|
| 2924 | |
---|
| 2925 | satd += abs(m[0] + m[1]); |
---|
| 2926 | satd += abs(m[0] - m[1]); |
---|
| 2927 | satd += abs(m[2] + m[3]); |
---|
| 2928 | satd += abs(m[2] - m[3]); |
---|
| 2929 | |
---|
| 2930 | return satd; |
---|
| 2931 | } |
---|
| 2932 | |
---|
| 2933 | UInt TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
| 2934 | { |
---|
| 2935 | Int k, satd = 0, diff[16], m[16], d[16]; |
---|
| 2936 | |
---|
| 2937 | assert( iStep == 1 ); |
---|
| 2938 | for( k = 0; k < 16; k+=4 ) |
---|
| 2939 | { |
---|
| 2940 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
| 2941 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
| 2942 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
| 2943 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
| 2944 | |
---|
| 2945 | piCur += iStrideCur; |
---|
| 2946 | piOrg += iStrideOrg; |
---|
| 2947 | } |
---|
| 2948 | |
---|
| 2949 | /*===== hadamard transform =====*/ |
---|
| 2950 | m[ 0] = diff[ 0] + diff[12]; |
---|
| 2951 | m[ 1] = diff[ 1] + diff[13]; |
---|
| 2952 | m[ 2] = diff[ 2] + diff[14]; |
---|
| 2953 | m[ 3] = diff[ 3] + diff[15]; |
---|
| 2954 | m[ 4] = diff[ 4] + diff[ 8]; |
---|
| 2955 | m[ 5] = diff[ 5] + diff[ 9]; |
---|
| 2956 | m[ 6] = diff[ 6] + diff[10]; |
---|
| 2957 | m[ 7] = diff[ 7] + diff[11]; |
---|
| 2958 | m[ 8] = diff[ 4] - diff[ 8]; |
---|
| 2959 | m[ 9] = diff[ 5] - diff[ 9]; |
---|
| 2960 | m[10] = diff[ 6] - diff[10]; |
---|
| 2961 | m[11] = diff[ 7] - diff[11]; |
---|
| 2962 | m[12] = diff[ 0] - diff[12]; |
---|
| 2963 | m[13] = diff[ 1] - diff[13]; |
---|
| 2964 | m[14] = diff[ 2] - diff[14]; |
---|
| 2965 | m[15] = diff[ 3] - diff[15]; |
---|
| 2966 | |
---|
| 2967 | d[ 0] = m[ 0] + m[ 4]; |
---|
| 2968 | d[ 1] = m[ 1] + m[ 5]; |
---|
| 2969 | d[ 2] = m[ 2] + m[ 6]; |
---|
| 2970 | d[ 3] = m[ 3] + m[ 7]; |
---|
| 2971 | d[ 4] = m[ 8] + m[12]; |
---|
| 2972 | d[ 5] = m[ 9] + m[13]; |
---|
| 2973 | d[ 6] = m[10] + m[14]; |
---|
| 2974 | d[ 7] = m[11] + m[15]; |
---|
| 2975 | d[ 8] = m[ 0] - m[ 4]; |
---|
| 2976 | d[ 9] = m[ 1] - m[ 5]; |
---|
| 2977 | d[10] = m[ 2] - m[ 6]; |
---|
| 2978 | d[11] = m[ 3] - m[ 7]; |
---|
| 2979 | d[12] = m[12] - m[ 8]; |
---|
| 2980 | d[13] = m[13] - m[ 9]; |
---|
| 2981 | d[14] = m[14] - m[10]; |
---|
| 2982 | d[15] = m[15] - m[11]; |
---|
| 2983 | |
---|
| 2984 | m[ 0] = d[ 0] + d[ 3]; |
---|
| 2985 | m[ 1] = d[ 1] + d[ 2]; |
---|
| 2986 | m[ 2] = d[ 1] - d[ 2]; |
---|
| 2987 | m[ 3] = d[ 0] - d[ 3]; |
---|
| 2988 | m[ 4] = d[ 4] + d[ 7]; |
---|
| 2989 | m[ 5] = d[ 5] + d[ 6]; |
---|
| 2990 | m[ 6] = d[ 5] - d[ 6]; |
---|
| 2991 | m[ 7] = d[ 4] - d[ 7]; |
---|
| 2992 | m[ 8] = d[ 8] + d[11]; |
---|
| 2993 | m[ 9] = d[ 9] + d[10]; |
---|
| 2994 | m[10] = d[ 9] - d[10]; |
---|
| 2995 | m[11] = d[ 8] - d[11]; |
---|
| 2996 | m[12] = d[12] + d[15]; |
---|
| 2997 | m[13] = d[13] + d[14]; |
---|
| 2998 | m[14] = d[13] - d[14]; |
---|
| 2999 | m[15] = d[12] - d[15]; |
---|
| 3000 | |
---|
| 3001 | d[ 0] = m[ 0] + m[ 1]; |
---|
| 3002 | d[ 1] = m[ 0] - m[ 1]; |
---|
| 3003 | d[ 2] = m[ 2] + m[ 3]; |
---|
| 3004 | d[ 3] = m[ 3] - m[ 2]; |
---|
| 3005 | d[ 4] = m[ 4] + m[ 5]; |
---|
| 3006 | d[ 5] = m[ 4] - m[ 5]; |
---|
| 3007 | d[ 6] = m[ 6] + m[ 7]; |
---|
| 3008 | d[ 7] = m[ 7] - m[ 6]; |
---|
| 3009 | d[ 8] = m[ 8] + m[ 9]; |
---|
| 3010 | d[ 9] = m[ 8] - m[ 9]; |
---|
| 3011 | d[10] = m[10] + m[11]; |
---|
| 3012 | d[11] = m[11] - m[10]; |
---|
| 3013 | d[12] = m[12] + m[13]; |
---|
| 3014 | d[13] = m[12] - m[13]; |
---|
| 3015 | d[14] = m[14] + m[15]; |
---|
| 3016 | d[15] = m[15] - m[14]; |
---|
| 3017 | |
---|
| 3018 | for (k=0; k<16; ++k) |
---|
| 3019 | { |
---|
| 3020 | satd += abs(d[k]); |
---|
| 3021 | } |
---|
| 3022 | satd = ((satd+1)>>1); |
---|
| 3023 | |
---|
| 3024 | return satd; |
---|
| 3025 | } |
---|
| 3026 | |
---|
| 3027 | UInt TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
| 3028 | { |
---|
| 3029 | Int k, i, j, jj, sad=0; |
---|
| 3030 | Int diff[64], m1[8][8], m2[8][8], m3[8][8]; |
---|
| 3031 | assert( iStep == 1 ); |
---|
| 3032 | for( k = 0; k < 64; k += 8 ) |
---|
| 3033 | { |
---|
| 3034 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
| 3035 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
| 3036 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
| 3037 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
| 3038 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
| 3039 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
| 3040 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
| 3041 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
| 3042 | |
---|
| 3043 | piCur += iStrideCur; |
---|
| 3044 | piOrg += iStrideOrg; |
---|
| 3045 | } |
---|
| 3046 | |
---|
| 3047 | //horizontal |
---|
| 3048 | for (j=0; j < 8; j++) |
---|
| 3049 | { |
---|
| 3050 | jj = j << 3; |
---|
| 3051 | m2[j][0] = diff[jj ] + diff[jj+4]; |
---|
| 3052 | m2[j][1] = diff[jj+1] + diff[jj+5]; |
---|
| 3053 | m2[j][2] = diff[jj+2] + diff[jj+6]; |
---|
| 3054 | m2[j][3] = diff[jj+3] + diff[jj+7]; |
---|
| 3055 | m2[j][4] = diff[jj ] - diff[jj+4]; |
---|
| 3056 | m2[j][5] = diff[jj+1] - diff[jj+5]; |
---|
| 3057 | m2[j][6] = diff[jj+2] - diff[jj+6]; |
---|
| 3058 | m2[j][7] = diff[jj+3] - diff[jj+7]; |
---|
| 3059 | |
---|
| 3060 | m1[j][0] = m2[j][0] + m2[j][2]; |
---|
| 3061 | m1[j][1] = m2[j][1] + m2[j][3]; |
---|
| 3062 | m1[j][2] = m2[j][0] - m2[j][2]; |
---|
| 3063 | m1[j][3] = m2[j][1] - m2[j][3]; |
---|
| 3064 | m1[j][4] = m2[j][4] + m2[j][6]; |
---|
| 3065 | m1[j][5] = m2[j][5] + m2[j][7]; |
---|
| 3066 | m1[j][6] = m2[j][4] - m2[j][6]; |
---|
| 3067 | m1[j][7] = m2[j][5] - m2[j][7]; |
---|
| 3068 | |
---|
| 3069 | m2[j][0] = m1[j][0] + m1[j][1]; |
---|
| 3070 | m2[j][1] = m1[j][0] - m1[j][1]; |
---|
| 3071 | m2[j][2] = m1[j][2] + m1[j][3]; |
---|
| 3072 | m2[j][3] = m1[j][2] - m1[j][3]; |
---|
| 3073 | m2[j][4] = m1[j][4] + m1[j][5]; |
---|
| 3074 | m2[j][5] = m1[j][4] - m1[j][5]; |
---|
| 3075 | m2[j][6] = m1[j][6] + m1[j][7]; |
---|
| 3076 | m2[j][7] = m1[j][6] - m1[j][7]; |
---|
| 3077 | } |
---|
| 3078 | |
---|
| 3079 | //vertical |
---|
| 3080 | for (i=0; i < 8; i++) |
---|
| 3081 | { |
---|
| 3082 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
| 3083 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
| 3084 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
| 3085 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
| 3086 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
| 3087 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
| 3088 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
| 3089 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
| 3090 | |
---|
| 3091 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
| 3092 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
| 3093 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
| 3094 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
| 3095 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
| 3096 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
| 3097 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
| 3098 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
| 3099 | |
---|
| 3100 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
| 3101 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
| 3102 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
| 3103 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
| 3104 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
| 3105 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
| 3106 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
| 3107 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
| 3108 | } |
---|
| 3109 | |
---|
| 3110 | for (i = 0; i < 8; i++) |
---|
| 3111 | { |
---|
| 3112 | for (j = 0; j < 8; j++) |
---|
| 3113 | { |
---|
| 3114 | sad += abs(m2[i][j]); |
---|
| 3115 | } |
---|
| 3116 | } |
---|
| 3117 | |
---|
| 3118 | sad=((sad+2)>>2); |
---|
| 3119 | |
---|
| 3120 | return sad; |
---|
| 3121 | } |
---|
| 3122 | |
---|
| 3123 | #if NS_HAD |
---|
| 3124 | UInt TComRdCost::xCalcHADs16x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
| 3125 | { |
---|
| 3126 | Int k, i, j, jj, sad=0; |
---|
| 3127 | Int diff[64], m1[4][16], m2[4][16]; |
---|
| 3128 | assert( iStep == 1 ); |
---|
| 3129 | for( k = 0; k < 64; k += 16 ) |
---|
| 3130 | { |
---|
| 3131 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
| 3132 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
| 3133 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
| 3134 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
| 3135 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
| 3136 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
| 3137 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
| 3138 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
| 3139 | |
---|
| 3140 | diff[k+8] = piOrg[8] - piCur[8] ; |
---|
| 3141 | diff[k+9] = piOrg[9] - piCur[9] ; |
---|
| 3142 | diff[k+10] = piOrg[10] - piCur[10]; |
---|
| 3143 | diff[k+11] = piOrg[11] - piCur[11]; |
---|
| 3144 | diff[k+12] = piOrg[12] - piCur[12]; |
---|
| 3145 | diff[k+13] = piOrg[13] - piCur[13]; |
---|
| 3146 | diff[k+14] = piOrg[14] - piCur[14]; |
---|
| 3147 | diff[k+15] = piOrg[15] - piCur[15]; |
---|
| 3148 | |
---|
| 3149 | piCur += iStrideCur; |
---|
| 3150 | piOrg += iStrideOrg; |
---|
| 3151 | } |
---|
| 3152 | |
---|
| 3153 | //horizontal |
---|
| 3154 | for (j=0; j < 4; j++) |
---|
| 3155 | { |
---|
| 3156 | jj = j << 4; |
---|
| 3157 | |
---|
| 3158 | m2[j][0] = diff[jj ] + diff[jj+8]; |
---|
| 3159 | m2[j][1] = diff[jj+1] + diff[jj+9]; |
---|
| 3160 | m2[j][2] = diff[jj+2] + diff[jj+10]; |
---|
| 3161 | m2[j][3] = diff[jj+3] + diff[jj+11]; |
---|
| 3162 | m2[j][4] = diff[jj+4] + diff[jj+12]; |
---|
| 3163 | m2[j][5] = diff[jj+5] + diff[jj+13]; |
---|
| 3164 | m2[j][6] = diff[jj+6] + diff[jj+14]; |
---|
| 3165 | m2[j][7] = diff[jj+7] + diff[jj+15]; |
---|
| 3166 | m2[j][8] = diff[jj ] - diff[jj+8]; |
---|
| 3167 | m2[j][9] = diff[jj+1] - diff[jj+9]; |
---|
| 3168 | m2[j][10] = diff[jj+2] - diff[jj+10]; |
---|
| 3169 | m2[j][11] = diff[jj+3] - diff[jj+11]; |
---|
| 3170 | m2[j][12] = diff[jj+4] - diff[jj+12]; |
---|
| 3171 | m2[j][13] = diff[jj+5] - diff[jj+13]; |
---|
| 3172 | m2[j][14] = diff[jj+6] - diff[jj+14]; |
---|
| 3173 | m2[j][15] = diff[jj+7] - diff[jj+15]; |
---|
| 3174 | |
---|
| 3175 | m1[j][0] = m2[j][0] + m2[j][4]; |
---|
| 3176 | m1[j][1] = m2[j][1] + m2[j][5]; |
---|
| 3177 | m1[j][2] = m2[j][2] + m2[j][6]; |
---|
| 3178 | m1[j][3] = m2[j][3] + m2[j][7]; |
---|
| 3179 | m1[j][4] = m2[j][0] - m2[j][4]; |
---|
| 3180 | m1[j][5] = m2[j][1] - m2[j][5]; |
---|
| 3181 | m1[j][6] = m2[j][2] - m2[j][6]; |
---|
| 3182 | m1[j][7] = m2[j][3] - m2[j][7]; |
---|
| 3183 | m1[j][8] = m2[j][8] + m2[j][12]; |
---|
| 3184 | m1[j][9] = m2[j][9] + m2[j][13]; |
---|
| 3185 | m1[j][10] = m2[j][10] + m2[j][14]; |
---|
| 3186 | m1[j][11] = m2[j][11] + m2[j][15]; |
---|
| 3187 | m1[j][12] = m2[j][8] - m2[j][12]; |
---|
| 3188 | m1[j][13] = m2[j][9] - m2[j][13]; |
---|
| 3189 | m1[j][14] = m2[j][10] - m2[j][14]; |
---|
| 3190 | m1[j][15] = m2[j][11] - m2[j][15]; |
---|
| 3191 | |
---|
| 3192 | m2[j][0] = m1[j][0] + m1[j][2]; |
---|
| 3193 | m2[j][1] = m1[j][1] + m1[j][3]; |
---|
| 3194 | m2[j][2] = m1[j][0] - m1[j][2]; |
---|
| 3195 | m2[j][3] = m1[j][1] - m1[j][3]; |
---|
| 3196 | m2[j][4] = m1[j][4] + m1[j][6]; |
---|
| 3197 | m2[j][5] = m1[j][5] + m1[j][7]; |
---|
| 3198 | m2[j][6] = m1[j][4] - m1[j][6]; |
---|
| 3199 | m2[j][7] = m1[j][5] - m1[j][7]; |
---|
| 3200 | m2[j][8] = m1[j][8] + m1[j][10]; |
---|
| 3201 | m2[j][9] = m1[j][9] + m1[j][11]; |
---|
| 3202 | m2[j][10] = m1[j][8] - m1[j][10]; |
---|
| 3203 | m2[j][11] = m1[j][9] - m1[j][11]; |
---|
| 3204 | m2[j][12] = m1[j][12] + m1[j][14]; |
---|
| 3205 | m2[j][13] = m1[j][13] + m1[j][15]; |
---|
| 3206 | m2[j][14] = m1[j][12] - m1[j][14]; |
---|
| 3207 | m2[j][15] = m1[j][13] - m1[j][15]; |
---|
| 3208 | |
---|
| 3209 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
| 3210 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
| 3211 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
| 3212 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
| 3213 | m1[j][4] = m2[j][4] + m2[j][5]; |
---|
| 3214 | m1[j][5] = m2[j][4] - m2[j][5]; |
---|
| 3215 | m1[j][6] = m2[j][6] + m2[j][7]; |
---|
| 3216 | m1[j][7] = m2[j][6] - m2[j][7]; |
---|
| 3217 | m1[j][8] = m2[j][8] + m2[j][9]; |
---|
| 3218 | m1[j][9] = m2[j][8] - m2[j][9]; |
---|
| 3219 | m1[j][10] = m2[j][10] + m2[j][11]; |
---|
| 3220 | m1[j][11] = m2[j][10] - m2[j][11]; |
---|
| 3221 | m1[j][12] = m2[j][12] + m2[j][13]; |
---|
| 3222 | m1[j][13] = m2[j][12] - m2[j][13]; |
---|
| 3223 | m1[j][14] = m2[j][14] + m2[j][15]; |
---|
| 3224 | m1[j][15] = m2[j][14] - m2[j][15]; |
---|
| 3225 | } |
---|
| 3226 | |
---|
| 3227 | //vertical |
---|
| 3228 | for (i=0; i < 16; i++) |
---|
| 3229 | { |
---|
| 3230 | m2[0][i] = m1[0][i] + m1[2][i]; |
---|
| 3231 | m2[1][i] = m1[1][i] + m1[3][i]; |
---|
| 3232 | m2[2][i] = m1[0][i] - m1[2][i]; |
---|
| 3233 | m2[3][i] = m1[1][i] - m1[3][i]; |
---|
| 3234 | |
---|
| 3235 | m1[0][i] = m2[0][i] + m2[1][i]; |
---|
| 3236 | m1[1][i] = m2[0][i] - m2[1][i]; |
---|
| 3237 | m1[2][i] = m2[2][i] + m2[3][i]; |
---|
| 3238 | m1[3][i] = m2[2][i] - m2[3][i]; |
---|
| 3239 | } |
---|
| 3240 | |
---|
| 3241 | for (i = 0; i < 4; i++) |
---|
| 3242 | { |
---|
| 3243 | for (j = 0; j < 16; j++) |
---|
| 3244 | { |
---|
| 3245 | sad += abs(m1[i][j]); |
---|
| 3246 | } |
---|
| 3247 | } |
---|
| 3248 | |
---|
| 3249 | sad=((sad+2)>>2); |
---|
| 3250 | |
---|
| 3251 | return sad; |
---|
| 3252 | } |
---|
| 3253 | |
---|
| 3254 | UInt TComRdCost::xCalcHADs4x16( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
| 3255 | { |
---|
| 3256 | Int k, i, j, jj, sad=0; |
---|
| 3257 | Int diff[64], m1[16][4], m2[16][4], m3[16][4]; |
---|
| 3258 | assert( iStep == 1 ); |
---|
| 3259 | for( k = 0; k < 64; k += 4 ) |
---|
| 3260 | { |
---|
| 3261 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
| 3262 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
| 3263 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
| 3264 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
| 3265 | |
---|
| 3266 | piCur += iStrideCur; |
---|
| 3267 | piOrg += iStrideOrg; |
---|
| 3268 | } |
---|
| 3269 | |
---|
| 3270 | //horizontal |
---|
| 3271 | for (j=0; j < 16; j++) |
---|
| 3272 | { |
---|
| 3273 | jj = j << 2; |
---|
| 3274 | m2[j][0] = diff[jj ] + diff[jj+2]; |
---|
| 3275 | m2[j][1] = diff[jj+1] + diff[jj+3]; |
---|
| 3276 | m2[j][2] = diff[jj ] - diff[jj+2]; |
---|
| 3277 | m2[j][3] = diff[jj+1] - diff[jj+3]; |
---|
| 3278 | |
---|
| 3279 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
| 3280 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
| 3281 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
| 3282 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
| 3283 | } |
---|
| 3284 | |
---|
| 3285 | //vertical |
---|
| 3286 | for (i=0; i < 4; i++) |
---|
| 3287 | { |
---|
| 3288 | m2[0][i] = m1[0][i] + m1[8][i]; |
---|
| 3289 | m2[1][i] = m1[1][i] + m1[9][i]; |
---|
| 3290 | m2[2][i] = m1[2][i] + m1[10][i]; |
---|
| 3291 | m2[3][i] = m1[3][i] + m1[11][i]; |
---|
| 3292 | m2[4][i] = m1[4][i] + m1[12][i]; |
---|
| 3293 | m2[5][i] = m1[5][i] + m1[13][i]; |
---|
| 3294 | m2[6][i] = m1[6][i] + m1[14][i]; |
---|
| 3295 | m2[7][i] = m1[7][i] + m1[15][i]; |
---|
| 3296 | m2[8][i] = m1[0][i] - m1[8][i]; |
---|
| 3297 | m2[9][i] = m1[1][i] - m1[9][i]; |
---|
| 3298 | m2[10][i] = m1[2][i] - m1[10][i]; |
---|
| 3299 | m2[11][i] = m1[3][i] - m1[11][i]; |
---|
| 3300 | m2[12][i] = m1[4][i] - m1[12][i]; |
---|
| 3301 | m2[13][i] = m1[5][i] - m1[13][i]; |
---|
| 3302 | m2[14][i] = m1[6][i] - m1[14][i]; |
---|
| 3303 | m2[15][i] = m1[7][i] - m1[15][i]; |
---|
| 3304 | |
---|
| 3305 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
| 3306 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
| 3307 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
| 3308 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
| 3309 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
| 3310 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
| 3311 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
| 3312 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
| 3313 | m3[8][i] = m2[8][i] + m2[12][i]; |
---|
| 3314 | m3[9][i] = m2[9][i] + m2[13][i]; |
---|
| 3315 | m3[10][i] = m2[10][i] + m2[14][i]; |
---|
| 3316 | m3[11][i] = m2[11][i] + m2[15][i]; |
---|
| 3317 | m3[12][i] = m2[8][i] - m2[12][i]; |
---|
| 3318 | m3[13][i] = m2[9][i] - m2[13][i]; |
---|
| 3319 | m3[14][i] = m2[10][i] - m2[14][i]; |
---|
| 3320 | m3[15][i] = m2[11][i] - m2[15][i]; |
---|
| 3321 | |
---|
| 3322 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
| 3323 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
| 3324 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
| 3325 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
| 3326 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
| 3327 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
| 3328 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
| 3329 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
| 3330 | m1[8][i] = m3[8][i] + m3[10][i]; |
---|
| 3331 | m1[9][i] = m3[9][i] + m3[11][i]; |
---|
| 3332 | m1[10][i] = m3[8][i] - m3[10][i]; |
---|
| 3333 | m1[11][i] = m3[9][i] - m3[11][i]; |
---|
| 3334 | m1[12][i] = m3[12][i] + m3[14][i]; |
---|
| 3335 | m1[13][i] = m3[13][i] + m3[15][i]; |
---|
| 3336 | m1[14][i] = m3[12][i] - m3[14][i]; |
---|
| 3337 | m1[15][i] = m3[13][i] - m3[15][i]; |
---|
| 3338 | |
---|
| 3339 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
| 3340 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
| 3341 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
| 3342 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
| 3343 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
| 3344 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
| 3345 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
| 3346 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
| 3347 | m2[8][i] = m1[8][i] + m1[9][i]; |
---|
| 3348 | m2[9][i] = m1[8][i] - m1[9][i]; |
---|
| 3349 | m2[10][i] = m1[10][i] + m1[11][i]; |
---|
| 3350 | m2[11][i] = m1[10][i] - m1[11][i]; |
---|
| 3351 | m2[12][i] = m1[12][i] + m1[13][i]; |
---|
| 3352 | m2[13][i] = m1[12][i] - m1[13][i]; |
---|
| 3353 | m2[14][i] = m1[14][i] + m1[15][i]; |
---|
| 3354 | m2[15][i] = m1[14][i] - m1[15][i]; |
---|
| 3355 | } |
---|
| 3356 | |
---|
| 3357 | for (i = 0; i < 16; i++) |
---|
| 3358 | { |
---|
| 3359 | for (j = 0; j < 4; j++) |
---|
| 3360 | { |
---|
| 3361 | sad += abs(m2[i][j]); |
---|
| 3362 | } |
---|
| 3363 | } |
---|
| 3364 | |
---|
| 3365 | sad=((sad+2)>>2); |
---|
| 3366 | |
---|
| 3367 | return sad; |
---|
| 3368 | } |
---|
| 3369 | #endif |
---|
| 3370 | |
---|
| 3371 | UInt TComRdCost::xGetHADs4( DistParam* pcDtParam ) |
---|
| 3372 | { |
---|
| 3373 | if ( pcDtParam->bApplyWeight ) |
---|
| 3374 | { |
---|
| 3375 | return xGetHADs4w( pcDtParam ); |
---|
| 3376 | } |
---|
| 3377 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 3378 | Pel* piCur = pcDtParam->pCur; |
---|
| 3379 | Int iRows = pcDtParam->iRows; |
---|
| 3380 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 3381 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 3382 | Int iStep = pcDtParam->iStep; |
---|
| 3383 | Int y; |
---|
| 3384 | Int iOffsetOrg = iStrideOrg<<2; |
---|
| 3385 | Int iOffsetCur = iStrideCur<<2; |
---|
| 3386 | |
---|
| 3387 | UInt uiSum = 0; |
---|
| 3388 | |
---|
| 3389 | for ( y=0; y<iRows; y+= 4 ) |
---|
| 3390 | { |
---|
| 3391 | uiSum += xCalcHADs4x4( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
| 3392 | piOrg += iOffsetOrg; |
---|
| 3393 | piCur += iOffsetCur; |
---|
| 3394 | } |
---|
| 3395 | |
---|
| 3396 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 3397 | } |
---|
| 3398 | |
---|
| 3399 | UInt TComRdCost::xGetHADs8( DistParam* pcDtParam ) |
---|
| 3400 | { |
---|
| 3401 | if ( pcDtParam->bApplyWeight ) |
---|
| 3402 | { |
---|
| 3403 | return xGetHADs8w( pcDtParam ); |
---|
| 3404 | } |
---|
| 3405 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 3406 | Pel* piCur = pcDtParam->pCur; |
---|
| 3407 | Int iRows = pcDtParam->iRows; |
---|
| 3408 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 3409 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 3410 | Int iStep = pcDtParam->iStep; |
---|
| 3411 | Int y; |
---|
| 3412 | |
---|
| 3413 | UInt uiSum = 0; |
---|
| 3414 | |
---|
| 3415 | if ( iRows == 4 ) |
---|
| 3416 | { |
---|
| 3417 | uiSum += xCalcHADs4x4( piOrg+0, piCur , iStrideOrg, iStrideCur, iStep ); |
---|
| 3418 | uiSum += xCalcHADs4x4( piOrg+4, piCur+4*iStep, iStrideOrg, iStrideCur, iStep ); |
---|
| 3419 | } |
---|
| 3420 | else |
---|
| 3421 | { |
---|
| 3422 | Int iOffsetOrg = iStrideOrg<<3; |
---|
| 3423 | Int iOffsetCur = iStrideCur<<3; |
---|
| 3424 | for ( y=0; y<iRows; y+= 8 ) |
---|
| 3425 | { |
---|
| 3426 | uiSum += xCalcHADs8x8( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
| 3427 | piOrg += iOffsetOrg; |
---|
| 3428 | piCur += iOffsetCur; |
---|
| 3429 | } |
---|
| 3430 | } |
---|
| 3431 | |
---|
| 3432 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 3433 | } |
---|
| 3434 | |
---|
| 3435 | UInt TComRdCost::xGetHADs( DistParam* pcDtParam ) |
---|
| 3436 | { |
---|
| 3437 | if ( pcDtParam->bApplyWeight ) |
---|
| 3438 | { |
---|
| 3439 | return xGetHADsw( pcDtParam ); |
---|
| 3440 | } |
---|
[504] | 3441 | #if H_3D_IC |
---|
| 3442 | if( pcDtParam->bUseIC ) |
---|
| 3443 | { |
---|
| 3444 | return xGetHADsic( pcDtParam ); |
---|
| 3445 | } |
---|
| 3446 | #endif |
---|
[324] | 3447 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 3448 | Pel* piCur = pcDtParam->pCur; |
---|
| 3449 | Int iRows = pcDtParam->iRows; |
---|
| 3450 | Int iCols = pcDtParam->iCols; |
---|
| 3451 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 3452 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 3453 | Int iStep = pcDtParam->iStep; |
---|
| 3454 | |
---|
| 3455 | Int x, y; |
---|
| 3456 | |
---|
| 3457 | UInt uiSum = 0; |
---|
| 3458 | |
---|
| 3459 | #if NS_HAD |
---|
| 3460 | if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) ) |
---|
| 3461 | #else |
---|
| 3462 | if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) |
---|
| 3463 | #endif |
---|
| 3464 | { |
---|
| 3465 | Int iOffsetOrg = iStrideOrg<<3; |
---|
| 3466 | Int iOffsetCur = iStrideCur<<3; |
---|
| 3467 | for ( y=0; y<iRows; y+= 8 ) |
---|
| 3468 | { |
---|
| 3469 | for ( x=0; x<iCols; x+= 8 ) |
---|
| 3470 | { |
---|
| 3471 | uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 3472 | } |
---|
| 3473 | piOrg += iOffsetOrg; |
---|
| 3474 | piCur += iOffsetCur; |
---|
| 3475 | } |
---|
| 3476 | } |
---|
| 3477 | #if NS_HAD |
---|
| 3478 | else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD ) |
---|
| 3479 | { |
---|
| 3480 | Int iOffsetOrg = iStrideOrg<<2; |
---|
| 3481 | Int iOffsetCur = iStrideCur<<2; |
---|
| 3482 | for ( y=0; y<iRows; y+= 4 ) |
---|
| 3483 | { |
---|
| 3484 | for ( x=0; x<iCols; x+= 16 ) |
---|
| 3485 | { |
---|
| 3486 | uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 3487 | } |
---|
| 3488 | piOrg += iOffsetOrg; |
---|
| 3489 | piCur += iOffsetCur; |
---|
| 3490 | } |
---|
| 3491 | } |
---|
| 3492 | else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD ) |
---|
| 3493 | { |
---|
| 3494 | Int iOffsetOrg = iStrideOrg<<4; |
---|
| 3495 | Int iOffsetCur = iStrideCur<<4; |
---|
| 3496 | for ( y=0; y<iRows; y+= 16 ) |
---|
| 3497 | { |
---|
| 3498 | for ( x=0; x<iCols; x+= 4 ) |
---|
| 3499 | { |
---|
| 3500 | uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 3501 | } |
---|
| 3502 | piOrg += iOffsetOrg; |
---|
| 3503 | piCur += iOffsetCur; |
---|
| 3504 | } |
---|
| 3505 | } |
---|
| 3506 | #endif |
---|
| 3507 | else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) |
---|
| 3508 | { |
---|
| 3509 | Int iOffsetOrg = iStrideOrg<<2; |
---|
| 3510 | Int iOffsetCur = iStrideCur<<2; |
---|
| 3511 | |
---|
| 3512 | for ( y=0; y<iRows; y+= 4 ) |
---|
| 3513 | { |
---|
| 3514 | for ( x=0; x<iCols; x+= 4 ) |
---|
| 3515 | { |
---|
| 3516 | uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 3517 | } |
---|
| 3518 | piOrg += iOffsetOrg; |
---|
| 3519 | piCur += iOffsetCur; |
---|
| 3520 | } |
---|
| 3521 | } |
---|
| 3522 | else if( ( iRows % 2 == 0) && (iCols % 2 == 0) ) |
---|
| 3523 | { |
---|
| 3524 | Int iOffsetOrg = iStrideOrg<<1; |
---|
| 3525 | Int iOffsetCur = iStrideCur<<1; |
---|
| 3526 | for ( y=0; y<iRows; y+=2 ) |
---|
| 3527 | { |
---|
| 3528 | for ( x=0; x<iCols; x+=2 ) |
---|
| 3529 | { |
---|
| 3530 | uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 3531 | } |
---|
| 3532 | piOrg += iOffsetOrg; |
---|
| 3533 | piCur += iOffsetCur; |
---|
| 3534 | } |
---|
| 3535 | } |
---|
| 3536 | else |
---|
| 3537 | { |
---|
| 3538 | assert(false); |
---|
| 3539 | } |
---|
| 3540 | |
---|
| 3541 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
| 3542 | } |
---|
[504] | 3543 | |
---|
| 3544 | #if H_3D_IC |
---|
| 3545 | UInt TComRdCost::xGetHADsic( DistParam* pcDtParam ) |
---|
| 3546 | { |
---|
| 3547 | if ( pcDtParam->bApplyWeight ) |
---|
| 3548 | { |
---|
| 3549 | return xGetHADsw( pcDtParam ); |
---|
| 3550 | } |
---|
| 3551 | Pel* piOrg = pcDtParam->pOrg; |
---|
| 3552 | Pel* piCur = pcDtParam->pCur; |
---|
| 3553 | Int iRows = pcDtParam->iRows; |
---|
| 3554 | Int iCols = pcDtParam->iCols; |
---|
| 3555 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 3556 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 3557 | Int iStep = pcDtParam->iStep; |
---|
| 3558 | |
---|
| 3559 | Int x, y; |
---|
| 3560 | |
---|
| 3561 | UInt uiSum = 0; |
---|
| 3562 | |
---|
| 3563 | Int iOrigAvg = 0, iCurAvg = 0; |
---|
| 3564 | Int iDeltaC; |
---|
| 3565 | |
---|
| 3566 | for ( y=0; y<iRows; y++ ) |
---|
| 3567 | { |
---|
| 3568 | for ( x=0; x<iCols; x++ ) |
---|
| 3569 | { |
---|
| 3570 | iOrigAvg += piOrg[x]; |
---|
| 3571 | iCurAvg += piCur[x]; |
---|
| 3572 | } |
---|
| 3573 | piOrg += iStrideOrg; |
---|
| 3574 | piCur += iStrideCur; |
---|
| 3575 | } |
---|
| 3576 | |
---|
| 3577 | piOrg = pcDtParam->pOrg; |
---|
| 3578 | piCur = pcDtParam->pCur; |
---|
| 3579 | |
---|
| 3580 | iDeltaC = (iOrigAvg - iCurAvg)/iRows/iCols; |
---|
| 3581 | |
---|
| 3582 | for ( y=0; y<iRows; y++ ) |
---|
| 3583 | { |
---|
| 3584 | for ( x=0; x<iCols; x++ ) |
---|
| 3585 | { |
---|
| 3586 | piOrg[x] -= iDeltaC; |
---|
| 3587 | } |
---|
| 3588 | piOrg += iStrideOrg; |
---|
| 3589 | } |
---|
| 3590 | |
---|
| 3591 | piOrg = pcDtParam->pOrg; |
---|
| 3592 | |
---|
| 3593 | #if NS_HAD |
---|
| 3594 | if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) ) |
---|
| 3595 | #else |
---|
| 3596 | if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) |
---|
| 3597 | #endif |
---|
| 3598 | { |
---|
| 3599 | Int iOffsetOrg = iStrideOrg<<3; |
---|
| 3600 | Int iOffsetCur = iStrideCur<<3; |
---|
| 3601 | for ( y=0; y<iRows; y+= 8 ) |
---|
| 3602 | { |
---|
| 3603 | for ( x=0; x<iCols; x+= 8 ) |
---|
| 3604 | { |
---|
| 3605 | uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 3606 | } |
---|
| 3607 | piOrg += iOffsetOrg; |
---|
| 3608 | piCur += iOffsetCur; |
---|
| 3609 | } |
---|
| 3610 | } |
---|
| 3611 | #if NS_HAD |
---|
| 3612 | else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD ) |
---|
| 3613 | { |
---|
| 3614 | Int iOffsetOrg = iStrideOrg<<2; |
---|
| 3615 | Int iOffsetCur = iStrideCur<<2; |
---|
| 3616 | for ( y=0; y<iRows; y+= 4 ) |
---|
| 3617 | { |
---|
| 3618 | for ( x=0; x<iCols; x+= 16 ) |
---|
| 3619 | { |
---|
| 3620 | uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 3621 | } |
---|
| 3622 | piOrg += iOffsetOrg; |
---|
| 3623 | piCur += iOffsetCur; |
---|
| 3624 | } |
---|
| 3625 | } |
---|
| 3626 | else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD ) |
---|
| 3627 | { |
---|
| 3628 | Int iOffsetOrg = iStrideOrg<<4; |
---|
| 3629 | Int iOffsetCur = iStrideCur<<4; |
---|
| 3630 | for ( y=0; y<iRows; y+= 16 ) |
---|
| 3631 | { |
---|
| 3632 | for ( x=0; x<iCols; x+= 4 ) |
---|
| 3633 | { |
---|
| 3634 | uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 3635 | } |
---|
| 3636 | piOrg += iOffsetOrg; |
---|
| 3637 | piCur += iOffsetCur; |
---|
| 3638 | } |
---|
| 3639 | } |
---|
| 3640 | #endif |
---|
| 3641 | else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) |
---|
| 3642 | { |
---|
| 3643 | Int iOffsetOrg = iStrideOrg<<2; |
---|
| 3644 | Int iOffsetCur = iStrideCur<<2; |
---|
| 3645 | |
---|
| 3646 | for ( y=0; y<iRows; y+= 4 ) |
---|
| 3647 | { |
---|
| 3648 | for ( x=0; x<iCols; x+= 4 ) |
---|
| 3649 | { |
---|
| 3650 | uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 3651 | } |
---|
| 3652 | piOrg += iOffsetOrg; |
---|
| 3653 | piCur += iOffsetCur; |
---|
| 3654 | } |
---|
| 3655 | } |
---|
| 3656 | else if( ( iRows % 2 == 0) && (iCols % 2 == 0) ) |
---|
| 3657 | { |
---|
| 3658 | Int iOffsetOrg = iStrideOrg<<1; |
---|
| 3659 | Int iOffsetCur = iStrideCur<<1; |
---|
| 3660 | for ( y=0; y<iRows; y+=2 ) |
---|
| 3661 | { |
---|
| 3662 | for ( x=0; x<iCols; x+=2 ) |
---|
| 3663 | { |
---|
| 3664 | uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 3665 | } |
---|
| 3666 | piOrg += iOffsetOrg; |
---|
| 3667 | piCur += iOffsetCur; |
---|
| 3668 | } |
---|
| 3669 | } |
---|
| 3670 | else |
---|
| 3671 | { |
---|
| 3672 | assert(false); |
---|
| 3673 | } |
---|
| 3674 | |
---|
| 3675 | piOrg = pcDtParam->pOrg; |
---|
| 3676 | |
---|
| 3677 | for ( y=0; y<iRows; y++ ) |
---|
| 3678 | { |
---|
| 3679 | for ( x=0; x<iCols; x++ ) |
---|
| 3680 | { |
---|
| 3681 | piOrg[x] += iDeltaC; |
---|
| 3682 | } |
---|
| 3683 | piOrg += iStrideOrg; |
---|
| 3684 | } |
---|
| 3685 | |
---|
| 3686 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
| 3687 | } |
---|
| 3688 | #endif |
---|
| 3689 | |
---|
[446] | 3690 | #if H_3D_VSO |
---|
| 3691 | Void TComRdCost::setLambdaVSO( Double dLambdaVSO ) |
---|
| 3692 | { |
---|
| 3693 | m_dLambdaVSO = dLambdaVSO; |
---|
| 3694 | m_dSqrtLambdaVSO = sqrt(m_dLambdaVSO); |
---|
| 3695 | m_uiLambdaMotionSADVSO = (UInt)floor(65536.0 * m_dSqrtLambdaVSO); |
---|
| 3696 | m_uiLambdaMotionSSEVSO = (UInt)floor(65536.0 * m_dLambdaVSO ); |
---|
| 3697 | } |
---|
[324] | 3698 | |
---|
[446] | 3699 | Dist TComRdCost::xGetDistVSOMode4( Int iStartPosX, Int iStartPosY, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD ) |
---|
| 3700 | { |
---|
| 3701 | AOT(bSAD); |
---|
| 3702 | #if H_3D_VSO_EARLY_SKIP |
---|
| 3703 | RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur, piOrg, iOrgStride); |
---|
| 3704 | #else |
---|
| 3705 | RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur ); |
---|
| 3706 | #endif |
---|
| 3707 | |
---|
| 3708 | RMDist iDistMin = (RMDist) RDO_DIST_MIN; |
---|
| 3709 | iDistMin = m_bAllowNegDist ? RDO_DIST_MIN : 0; |
---|
| 3710 | |
---|
| 3711 | iDist = std::min( iDist, (RMDist) RDO_DIST_MAX); |
---|
| 3712 | iDist = std::max( iDist, iDistMin); |
---|
| 3713 | return (Dist) iDist; |
---|
| 3714 | } |
---|
| 3715 | |
---|
| 3716 | |
---|
| 3717 | Dist TComRdCost::getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHAD ) |
---|
| 3718 | { |
---|
| 3719 | assert( m_bUseVSO ); |
---|
| 3720 | assert( this->m_fpDistortFuncVSO != 0 ); |
---|
| 3721 | |
---|
| 3722 | Int iPosX; |
---|
| 3723 | Int iPosY; |
---|
| 3724 | |
---|
| 3725 | pcCU->getPosInPic( uiAbsPartIndex, iPosX, iPosY ); |
---|
| 3726 | |
---|
| 3727 | Dist dist = (this->*m_fpDistortFuncVSO) ( iPosX, iPosY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight, bHAD ); |
---|
| 3728 | |
---|
| 3729 | if ( m_bUseWVSO ) |
---|
| 3730 | { |
---|
| 3731 | Int iDWeight = m_iDWeight * m_iDWeight; |
---|
| 3732 | Int iVSOWeight = m_iVSOWeight * m_iVSOWeight; |
---|
| 3733 | Dist distDepth; |
---|
| 3734 | |
---|
| 3735 | if ( !bHAD ) |
---|
| 3736 | { |
---|
| 3737 | distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
| 3738 | } |
---|
| 3739 | else |
---|
| 3740 | { |
---|
| 3741 | distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
| 3742 | } |
---|
| 3743 | |
---|
| 3744 | dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight); |
---|
| 3745 | } |
---|
| 3746 | return dist; |
---|
| 3747 | }; |
---|
| 3748 | |
---|
| 3749 | |
---|
| 3750 | Void TComRdCost::setVSOMode( UInt uiIn ) |
---|
| 3751 | { |
---|
| 3752 | m_uiVSOMode = uiIn; |
---|
| 3753 | switch (m_uiVSOMode ) |
---|
| 3754 | { |
---|
| 3755 | case 4: |
---|
| 3756 | m_fpDistortFuncVSO = &TComRdCost::xGetDistVSOMode4; |
---|
| 3757 | break; |
---|
| 3758 | default: |
---|
| 3759 | assert(0); |
---|
| 3760 | break; |
---|
| 3761 | } |
---|
| 3762 | } |
---|
| 3763 | |
---|
| 3764 | |
---|
| 3765 | Double TComRdCost::calcRdCostVSO( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
| 3766 | { |
---|
| 3767 | assert( m_bUseLambdaScaleVSO ); |
---|
| 3768 | |
---|
| 3769 | Double dRdCost = 0.0; |
---|
| 3770 | Double dLambda = 0.0; |
---|
| 3771 | |
---|
| 3772 | switch ( eDFunc ) |
---|
| 3773 | { |
---|
| 3774 | case DF_SSE: |
---|
| 3775 | assert(0); |
---|
| 3776 | break; |
---|
| 3777 | case DF_SAD: |
---|
| 3778 | dLambda = (Double)m_uiLambdaMotionSADVSO; |
---|
| 3779 | break; |
---|
| 3780 | case DF_DEFAULT: |
---|
| 3781 | dLambda = m_dLambdaVSO; |
---|
| 3782 | break; |
---|
| 3783 | case DF_SSE_FRAME: |
---|
| 3784 | dLambda = m_dFrameLambdaVSO; |
---|
| 3785 | break; |
---|
| 3786 | default: |
---|
| 3787 | assert (0); |
---|
| 3788 | break; |
---|
| 3789 | } |
---|
| 3790 | |
---|
| 3791 | if (bFlag) |
---|
| 3792 | { |
---|
| 3793 | // Intra8x8, Intra4x4 Block only... |
---|
| 3794 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
| 3795 | dRdCost = (Double)(uiBits); |
---|
| 3796 | #else |
---|
| 3797 | dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda)); |
---|
| 3798 | #endif |
---|
| 3799 | } |
---|
| 3800 | else |
---|
| 3801 | { |
---|
| 3802 | if (eDFunc == DF_SAD) |
---|
| 3803 | { |
---|
| 3804 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16)); |
---|
| 3805 | dRdCost = (Double)(Dist)floor(dRdCost); |
---|
| 3806 | } |
---|
| 3807 | else |
---|
| 3808 | { |
---|
| 3809 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
| 3810 | dRdCost = (Double)(uiBits); |
---|
| 3811 | #else |
---|
| 3812 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5))); |
---|
| 3813 | dRdCost = (Double)(Dist)floor(dRdCost); |
---|
| 3814 | #endif |
---|
| 3815 | } |
---|
| 3816 | } |
---|
| 3817 | |
---|
| 3818 | return dRdCost; |
---|
| 3819 | } |
---|
| 3820 | |
---|
| 3821 | Void TComRdCost::setRenModelData( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight ) |
---|
| 3822 | { |
---|
| 3823 | UInt iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]]; |
---|
| 3824 | UInt iBlkY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]]; |
---|
| 3825 | |
---|
| 3826 | Int iStartPosX = iBlkX + pcCU->getCUPelX(); |
---|
| 3827 | Int iStartPosY = iBlkY + pcCU->getCUPelY(); |
---|
| 3828 | |
---|
| 3829 | m_pcRenModel->setData( iStartPosX, iStartPosY, iBlkWidth, iBlkHeight, iStride, piData ); |
---|
| 3830 | } |
---|
| 3831 | |
---|
| 3832 | Void TComRdCost::setAllowNegDist( Bool bAllowNegDist ) |
---|
| 3833 | { |
---|
| 3834 | m_bAllowNegDist = bAllowNegDist; |
---|
| 3835 | } |
---|
| 3836 | #endif |
---|
| 3837 | |
---|
[324] | 3838 | //! \} |
---|