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