[313] | 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 |
---|
[494] | 4 | * granted under this license. |
---|
[313] | 5 | * |
---|
[1259] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[313] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file TComRdCost.cpp |
---|
| 35 | \brief RD cost computation class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include <math.h> |
---|
| 39 | #include <assert.h> |
---|
[1312] | 40 | #include <limits> |
---|
[313] | 41 | #include "TComRom.h" |
---|
| 42 | #include "TComRdCost.h" |
---|
| 43 | |
---|
| 44 | //! \ingroup TLibCommon |
---|
| 45 | //! \{ |
---|
| 46 | |
---|
| 47 | TComRdCost::TComRdCost() |
---|
| 48 | { |
---|
| 49 | init(); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | TComRdCost::~TComRdCost() |
---|
| 53 | { |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | // Calculate RD functions |
---|
[1389] | 57 | Double TComRdCost::calcRdCost( Double numBits, Double distortion, DFunc eDFunc ) |
---|
[313] | 58 | { |
---|
[1389] | 59 | Double lambda = 1.0; |
---|
[494] | 60 | |
---|
[313] | 61 | switch ( eDFunc ) |
---|
| 62 | { |
---|
| 63 | case DF_SSE: |
---|
| 64 | assert(0); |
---|
| 65 | break; |
---|
| 66 | case DF_SAD: |
---|
[1389] | 67 | lambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate. |
---|
[313] | 68 | break; |
---|
| 69 | case DF_DEFAULT: |
---|
[1389] | 70 | lambda = m_dLambda; |
---|
[313] | 71 | break; |
---|
| 72 | case DF_SSE_FRAME: |
---|
[1389] | 73 | lambda = m_dFrameLambda; |
---|
[313] | 74 | break; |
---|
| 75 | default: |
---|
| 76 | assert (0); |
---|
| 77 | break; |
---|
| 78 | } |
---|
[494] | 79 | |
---|
[1389] | 80 | if (eDFunc == DF_SAD) |
---|
[313] | 81 | { |
---|
[1029] | 82 | if (m_costMode != COST_STANDARD_LOSSY) |
---|
| 83 | { |
---|
[1389] | 84 | return ((distortion * 65536.0) / lambda) + numBits; // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. |
---|
[1029] | 85 | } |
---|
| 86 | else |
---|
| 87 | { |
---|
[1389] | 88 | return distortion + (((numBits * lambda) ) / 65536.0); |
---|
[1029] | 89 | } |
---|
[313] | 90 | } |
---|
| 91 | else |
---|
| 92 | { |
---|
[1029] | 93 | if (m_costMode != COST_STANDARD_LOSSY) |
---|
| 94 | { |
---|
[1389] | 95 | return (distortion / lambda) + numBits; // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. |
---|
[1029] | 96 | } |
---|
| 97 | else |
---|
| 98 | { |
---|
[1389] | 99 | return distortion + (numBits * lambda); |
---|
[1029] | 100 | } |
---|
[313] | 101 | } |
---|
| 102 | } |
---|
| 103 | |
---|
[1287] | 104 | Void TComRdCost::setLambda( Double dLambda, const BitDepths &bitDepths ) |
---|
[313] | 105 | { |
---|
| 106 | m_dLambda = dLambda; |
---|
| 107 | m_sqrtLambda = sqrt(m_dLambda); |
---|
[1029] | 108 | m_dLambdaMotionSAD[0] = 65536.0 * m_sqrtLambda; |
---|
| 109 | m_dLambdaMotionSSE[0] = 65536.0 * m_dLambda; |
---|
| 110 | #if FULL_NBIT |
---|
| 111 | dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0)); |
---|
| 112 | #else |
---|
[1287] | 113 | dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (bitDepths.recon[CHANNEL_TYPE_LUMA] - 8)) / 3.0)); |
---|
[1029] | 114 | #endif |
---|
| 115 | m_dLambdaMotionSAD[1] = 65536.0 * sqrt(dLambda); |
---|
| 116 | m_dLambdaMotionSSE[1] = 65536.0 * dLambda; |
---|
[313] | 117 | } |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | // Initalize Function Pointer by [eDFunc] |
---|
| 121 | Void TComRdCost::init() |
---|
| 122 | { |
---|
[1029] | 123 | m_afpDistortFunc[DF_DEFAULT] = NULL; // for DF_DEFAULT |
---|
[494] | 124 | |
---|
[1029] | 125 | m_afpDistortFunc[DF_SSE ] = TComRdCost::xGetSSE; |
---|
| 126 | m_afpDistortFunc[DF_SSE4 ] = TComRdCost::xGetSSE4; |
---|
| 127 | m_afpDistortFunc[DF_SSE8 ] = TComRdCost::xGetSSE8; |
---|
| 128 | m_afpDistortFunc[DF_SSE16 ] = TComRdCost::xGetSSE16; |
---|
| 129 | m_afpDistortFunc[DF_SSE32 ] = TComRdCost::xGetSSE32; |
---|
| 130 | m_afpDistortFunc[DF_SSE64 ] = TComRdCost::xGetSSE64; |
---|
| 131 | m_afpDistortFunc[DF_SSE16N ] = TComRdCost::xGetSSE16N; |
---|
[494] | 132 | |
---|
[1029] | 133 | m_afpDistortFunc[DF_SAD ] = TComRdCost::xGetSAD; |
---|
| 134 | m_afpDistortFunc[DF_SAD4 ] = TComRdCost::xGetSAD4; |
---|
| 135 | m_afpDistortFunc[DF_SAD8 ] = TComRdCost::xGetSAD8; |
---|
| 136 | m_afpDistortFunc[DF_SAD16 ] = TComRdCost::xGetSAD16; |
---|
| 137 | m_afpDistortFunc[DF_SAD32 ] = TComRdCost::xGetSAD32; |
---|
| 138 | m_afpDistortFunc[DF_SAD64 ] = TComRdCost::xGetSAD64; |
---|
| 139 | m_afpDistortFunc[DF_SAD16N ] = TComRdCost::xGetSAD16N; |
---|
[494] | 140 | |
---|
[1029] | 141 | m_afpDistortFunc[DF_SADS ] = TComRdCost::xGetSAD; |
---|
| 142 | m_afpDistortFunc[DF_SADS4 ] = TComRdCost::xGetSAD4; |
---|
| 143 | m_afpDistortFunc[DF_SADS8 ] = TComRdCost::xGetSAD8; |
---|
| 144 | m_afpDistortFunc[DF_SADS16 ] = TComRdCost::xGetSAD16; |
---|
| 145 | m_afpDistortFunc[DF_SADS32 ] = TComRdCost::xGetSAD32; |
---|
| 146 | m_afpDistortFunc[DF_SADS64 ] = TComRdCost::xGetSAD64; |
---|
| 147 | m_afpDistortFunc[DF_SADS16N] = TComRdCost::xGetSAD16N; |
---|
[494] | 148 | |
---|
[1029] | 149 | m_afpDistortFunc[DF_SAD12 ] = TComRdCost::xGetSAD12; |
---|
| 150 | m_afpDistortFunc[DF_SAD24 ] = TComRdCost::xGetSAD24; |
---|
| 151 | m_afpDistortFunc[DF_SAD48 ] = TComRdCost::xGetSAD48; |
---|
[313] | 152 | |
---|
[1029] | 153 | m_afpDistortFunc[DF_SADS12 ] = TComRdCost::xGetSAD12; |
---|
| 154 | m_afpDistortFunc[DF_SADS24 ] = TComRdCost::xGetSAD24; |
---|
| 155 | m_afpDistortFunc[DF_SADS48 ] = TComRdCost::xGetSAD48; |
---|
[1341] | 156 | |
---|
[1029] | 157 | m_afpDistortFunc[DF_HADS ] = TComRdCost::xGetHADs; |
---|
| 158 | m_afpDistortFunc[DF_HADS4 ] = TComRdCost::xGetHADs; |
---|
| 159 | m_afpDistortFunc[DF_HADS8 ] = TComRdCost::xGetHADs; |
---|
| 160 | m_afpDistortFunc[DF_HADS16 ] = TComRdCost::xGetHADs; |
---|
| 161 | m_afpDistortFunc[DF_HADS32 ] = TComRdCost::xGetHADs; |
---|
| 162 | m_afpDistortFunc[DF_HADS64 ] = TComRdCost::xGetHADs; |
---|
| 163 | m_afpDistortFunc[DF_HADS16N] = TComRdCost::xGetHADs; |
---|
[494] | 164 | |
---|
[1029] | 165 | m_costMode = COST_STANDARD_LOSSY; |
---|
| 166 | |
---|
[1469] | 167 | m_motionLambda = 0; |
---|
[1029] | 168 | m_iCostScale = 0; |
---|
[313] | 169 | } |
---|
| 170 | |
---|
[1312] | 171 | // Static member function |
---|
| 172 | UInt TComRdCost::xGetExpGolombNumberOfBits( Int iVal ) |
---|
[313] | 173 | { |
---|
[1312] | 174 | assert(iVal != std::numeric_limits<Int>::min()); |
---|
[313] | 175 | UInt uiLength = 1; |
---|
[1312] | 176 | UInt uiTemp = ( iVal <= 0) ? (UInt(-iVal)<<1)+1: UInt(iVal<<1); |
---|
[494] | 177 | |
---|
[313] | 178 | while ( 1 != uiTemp ) |
---|
| 179 | { |
---|
| 180 | uiTemp >>= 1; |
---|
| 181 | uiLength += 2; |
---|
| 182 | } |
---|
[494] | 183 | |
---|
[313] | 184 | return uiLength; |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | Void TComRdCost::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam ) |
---|
| 188 | { |
---|
| 189 | // set Block Width / Height |
---|
| 190 | rcDistParam.iCols = uiBlkWidth; |
---|
| 191 | rcDistParam.iRows = uiBlkHeight; |
---|
| 192 | rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
[494] | 193 | |
---|
[313] | 194 | // initialize |
---|
| 195 | rcDistParam.iSubShift = 0; |
---|
[1397] | 196 | rcDistParam.m_maximumDistortionForEarlyExit = std::numeric_limits<Distortion>::max(); |
---|
[313] | 197 | } |
---|
| 198 | |
---|
| 199 | // Setting the Distortion Parameter for Inter (ME) |
---|
[1395] | 200 | Void TComRdCost::setDistParam( const TComPattern* const pcPatternKey, const Pel* piRefY, Int iRefStride, DistParam& rcDistParam ) |
---|
[313] | 201 | { |
---|
| 202 | // set Original & Curr Pointer / Stride |
---|
| 203 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
| 204 | rcDistParam.pCur = piRefY; |
---|
[494] | 205 | |
---|
[313] | 206 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
| 207 | rcDistParam.iStrideCur = iRefStride; |
---|
[494] | 208 | |
---|
[313] | 209 | // set Block Width / Height |
---|
| 210 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
| 211 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
| 212 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
[1397] | 213 | rcDistParam.m_maximumDistortionForEarlyExit = std::numeric_limits<Distortion>::max(); |
---|
[494] | 214 | |
---|
[313] | 215 | if (rcDistParam.iCols == 12) |
---|
| 216 | { |
---|
[1029] | 217 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD12]; |
---|
[313] | 218 | } |
---|
| 219 | else if (rcDistParam.iCols == 24) |
---|
| 220 | { |
---|
[1029] | 221 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD24]; |
---|
[313] | 222 | } |
---|
| 223 | else if (rcDistParam.iCols == 48) |
---|
| 224 | { |
---|
[1029] | 225 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD48]; |
---|
[313] | 226 | } |
---|
| 227 | |
---|
| 228 | // initialize |
---|
| 229 | rcDistParam.iSubShift = 0; |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | // Setting the Distortion Parameter for Inter (subpel ME with step) |
---|
[1395] | 233 | Void TComRdCost::setDistParam( const TComPattern* const pcPatternKey, const Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME ) |
---|
[313] | 234 | { |
---|
| 235 | // set Original & Curr Pointer / Stride |
---|
| 236 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
| 237 | rcDistParam.pCur = piRefY; |
---|
[494] | 238 | |
---|
[313] | 239 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
| 240 | rcDistParam.iStrideCur = iRefStride * iStep; |
---|
[494] | 241 | |
---|
[313] | 242 | // set Step for interpolated buffer |
---|
| 243 | rcDistParam.iStep = iStep; |
---|
[494] | 244 | |
---|
[313] | 245 | // set Block Width / Height |
---|
| 246 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
| 247 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
[494] | 248 | |
---|
[1397] | 249 | rcDistParam.m_maximumDistortionForEarlyExit = std::numeric_limits<Distortion>::max(); |
---|
| 250 | |
---|
[313] | 251 | // set distortion function |
---|
| 252 | if ( !bHADME ) |
---|
| 253 | { |
---|
| 254 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
| 255 | if (rcDistParam.iCols == 12) |
---|
| 256 | { |
---|
[1029] | 257 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS12]; |
---|
[313] | 258 | } |
---|
| 259 | else if (rcDistParam.iCols == 24) |
---|
| 260 | { |
---|
[1029] | 261 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS24]; |
---|
[313] | 262 | } |
---|
| 263 | else if (rcDistParam.iCols == 48) |
---|
| 264 | { |
---|
[1029] | 265 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS48]; |
---|
[313] | 266 | } |
---|
| 267 | } |
---|
| 268 | else |
---|
| 269 | { |
---|
| 270 | rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
| 271 | } |
---|
[494] | 272 | |
---|
[313] | 273 | // initialize |
---|
| 274 | rcDistParam.iSubShift = 0; |
---|
| 275 | } |
---|
| 276 | |
---|
[1395] | 277 | Void TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, const Pel* p1, Int iStride1, const Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard ) |
---|
[313] | 278 | { |
---|
[1395] | 279 | rcDP.pOrg = p1; |
---|
| 280 | rcDP.pCur = p2; |
---|
| 281 | rcDP.iStrideOrg = iStride1; |
---|
| 282 | rcDP.iStrideCur = iStride2; |
---|
| 283 | rcDP.iCols = iWidth; |
---|
| 284 | rcDP.iRows = iHeight; |
---|
| 285 | rcDP.iStep = 1; |
---|
| 286 | rcDP.iSubShift = 0; |
---|
| 287 | rcDP.bitDepth = bitDepth; |
---|
| 288 | rcDP.DistFunc = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ]; |
---|
[1397] | 289 | rcDP.m_maximumDistortionForEarlyExit = std::numeric_limits<Distortion>::max(); |
---|
[313] | 290 | } |
---|
| 291 | |
---|
[1395] | 292 | Distortion TComRdCost::calcHAD( Int bitDepth, const Pel* pi0, Int iStride0, const Pel* pi1, Int iStride1, Int iWidth, Int iHeight ) |
---|
[313] | 293 | { |
---|
[1029] | 294 | Distortion uiSum = 0; |
---|
[313] | 295 | Int x, y; |
---|
[494] | 296 | |
---|
[313] | 297 | if ( ( (iWidth % 8) == 0 ) && ( (iHeight % 8) == 0 ) ) |
---|
| 298 | { |
---|
| 299 | for ( y=0; y<iHeight; y+= 8 ) |
---|
| 300 | { |
---|
| 301 | for ( x=0; x<iWidth; x+= 8 ) |
---|
| 302 | { |
---|
| 303 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
| 304 | } |
---|
| 305 | pi0 += iStride0*8; |
---|
| 306 | pi1 += iStride1*8; |
---|
| 307 | } |
---|
| 308 | } |
---|
[595] | 309 | else |
---|
[313] | 310 | { |
---|
[1029] | 311 | assert ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) ); |
---|
| 312 | |
---|
[313] | 313 | for ( y=0; y<iHeight; y+= 4 ) |
---|
| 314 | { |
---|
| 315 | for ( x=0; x<iWidth; x+= 4 ) |
---|
| 316 | { |
---|
| 317 | uiSum += xCalcHADs4x4( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
| 318 | } |
---|
| 319 | pi0 += iStride0*4; |
---|
| 320 | pi1 += iStride1*4; |
---|
| 321 | } |
---|
| 322 | } |
---|
[494] | 323 | |
---|
[1029] | 324 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8) ); |
---|
[313] | 325 | } |
---|
| 326 | |
---|
[1395] | 327 | Distortion TComRdCost::getDistPart( Int bitDepth, const Pel* piCur, Int iCurStride, const Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc ) |
---|
[313] | 328 | { |
---|
| 329 | DistParam cDtParam; |
---|
| 330 | setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam ); |
---|
| 331 | cDtParam.pOrg = piOrg; |
---|
| 332 | cDtParam.pCur = piCur; |
---|
| 333 | cDtParam.iStrideOrg = iOrgStride; |
---|
| 334 | cDtParam.iStrideCur = iCurStride; |
---|
| 335 | cDtParam.iStep = 1; |
---|
| 336 | |
---|
| 337 | cDtParam.bApplyWeight = false; |
---|
[1029] | 338 | cDtParam.compIdx = MAX_NUM_COMPONENT; // just for assert: to be sure it was set before use |
---|
| 339 | cDtParam.bitDepth = bitDepth; |
---|
[313] | 340 | |
---|
[1029] | 341 | if (isChroma(compID)) |
---|
[313] | 342 | { |
---|
[1029] | 343 | return ((Distortion) (m_distortionWeight[compID] * cDtParam.DistFunc( &cDtParam ))); |
---|
[313] | 344 | } |
---|
| 345 | else |
---|
| 346 | { |
---|
| 347 | return cDtParam.DistFunc( &cDtParam ); |
---|
| 348 | } |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | // ==================================================================================================================== |
---|
| 352 | // Distortion functions |
---|
| 353 | // ==================================================================================================================== |
---|
| 354 | |
---|
| 355 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 356 | // SAD |
---|
| 357 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 358 | |
---|
[1029] | 359 | Distortion TComRdCost::xGetSAD( DistParam* pcDtParam ) |
---|
[313] | 360 | { |
---|
| 361 | if ( pcDtParam->bApplyWeight ) |
---|
| 362 | { |
---|
[1029] | 363 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
[313] | 364 | } |
---|
[1397] | 365 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 366 | const Pel* piCur = pcDtParam->pCur; |
---|
| 367 | const Int iCols = pcDtParam->iCols; |
---|
| 368 | const Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 369 | const Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 370 | const UInt distortionShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth - 8); |
---|
[494] | 371 | |
---|
[1029] | 372 | Distortion uiSum = 0; |
---|
[494] | 373 | |
---|
[1397] | 374 | for(Int iRows = pcDtParam->iRows ; iRows != 0; iRows-- ) |
---|
[313] | 375 | { |
---|
| 376 | for (Int n = 0; n < iCols; n++ ) |
---|
| 377 | { |
---|
| 378 | uiSum += abs( piOrg[n] - piCur[n] ); |
---|
| 379 | } |
---|
[1397] | 380 | if (pcDtParam->m_maximumDistortionForEarlyExit < ( uiSum >> distortionShift )) |
---|
| 381 | { |
---|
| 382 | return ( uiSum >> distortionShift ); |
---|
| 383 | } |
---|
[313] | 384 | piOrg += iStrideOrg; |
---|
| 385 | piCur += iStrideCur; |
---|
| 386 | } |
---|
[494] | 387 | |
---|
[1397] | 388 | return ( uiSum >> distortionShift ); |
---|
[313] | 389 | } |
---|
| 390 | |
---|
[1029] | 391 | Distortion TComRdCost::xGetSAD4( DistParam* pcDtParam ) |
---|
[313] | 392 | { |
---|
[494] | 393 | if ( pcDtParam->bApplyWeight ) |
---|
[313] | 394 | { |
---|
[1029] | 395 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
[313] | 396 | } |
---|
[1029] | 397 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 398 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 399 | Int iRows = pcDtParam->iRows; |
---|
| 400 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 401 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 402 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 403 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
[494] | 404 | |
---|
[1029] | 405 | Distortion uiSum = 0; |
---|
[494] | 406 | |
---|
[313] | 407 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 408 | { |
---|
| 409 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 410 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 411 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 412 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
[494] | 413 | |
---|
[313] | 414 | piOrg += iStrideOrg; |
---|
| 415 | piCur += iStrideCur; |
---|
| 416 | } |
---|
[494] | 417 | |
---|
[313] | 418 | uiSum <<= iSubShift; |
---|
[1029] | 419 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
[313] | 420 | } |
---|
| 421 | |
---|
[1029] | 422 | Distortion TComRdCost::xGetSAD8( DistParam* pcDtParam ) |
---|
[313] | 423 | { |
---|
| 424 | if ( pcDtParam->bApplyWeight ) |
---|
| 425 | { |
---|
[1029] | 426 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
[313] | 427 | } |
---|
[1029] | 428 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 429 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 430 | Int iRows = pcDtParam->iRows; |
---|
| 431 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 432 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 433 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 434 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
[494] | 435 | |
---|
[1029] | 436 | Distortion uiSum = 0; |
---|
[494] | 437 | |
---|
[313] | 438 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 439 | { |
---|
| 440 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 441 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 442 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 443 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 444 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 445 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 446 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 447 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
[494] | 448 | |
---|
[313] | 449 | piOrg += iStrideOrg; |
---|
| 450 | piCur += iStrideCur; |
---|
| 451 | } |
---|
[494] | 452 | |
---|
[313] | 453 | uiSum <<= iSubShift; |
---|
[1029] | 454 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
[313] | 455 | } |
---|
| 456 | |
---|
[1029] | 457 | Distortion TComRdCost::xGetSAD16( DistParam* pcDtParam ) |
---|
[313] | 458 | { |
---|
| 459 | if ( pcDtParam->bApplyWeight ) |
---|
| 460 | { |
---|
[1029] | 461 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
[313] | 462 | } |
---|
[1029] | 463 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 464 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 465 | Int iRows = pcDtParam->iRows; |
---|
| 466 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 467 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 468 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 469 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
[494] | 470 | |
---|
[1029] | 471 | Distortion uiSum = 0; |
---|
[494] | 472 | |
---|
[313] | 473 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 474 | { |
---|
| 475 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 476 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 477 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 478 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 479 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 480 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 481 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 482 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 483 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 484 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 485 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 486 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 487 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 488 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 489 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 490 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
[494] | 491 | |
---|
[313] | 492 | piOrg += iStrideOrg; |
---|
| 493 | piCur += iStrideCur; |
---|
| 494 | } |
---|
[494] | 495 | |
---|
[313] | 496 | uiSum <<= iSubShift; |
---|
[1029] | 497 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
[313] | 498 | } |
---|
| 499 | |
---|
[1029] | 500 | Distortion TComRdCost::xGetSAD12( DistParam* pcDtParam ) |
---|
[313] | 501 | { |
---|
| 502 | if ( pcDtParam->bApplyWeight ) |
---|
| 503 | { |
---|
[1029] | 504 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
[313] | 505 | } |
---|
[1029] | 506 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 507 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 508 | Int iRows = pcDtParam->iRows; |
---|
| 509 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 510 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 511 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 512 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
[494] | 513 | |
---|
[1029] | 514 | Distortion uiSum = 0; |
---|
[494] | 515 | |
---|
[313] | 516 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 517 | { |
---|
| 518 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 519 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 520 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 521 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 522 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 523 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 524 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 525 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 526 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 527 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 528 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 529 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
[494] | 530 | |
---|
[313] | 531 | piOrg += iStrideOrg; |
---|
| 532 | piCur += iStrideCur; |
---|
| 533 | } |
---|
[494] | 534 | |
---|
[313] | 535 | uiSum <<= iSubShift; |
---|
[1029] | 536 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
[313] | 537 | } |
---|
| 538 | |
---|
[1029] | 539 | Distortion TComRdCost::xGetSAD16N( DistParam* pcDtParam ) |
---|
[313] | 540 | { |
---|
[1029] | 541 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 542 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 543 | Int iRows = pcDtParam->iRows; |
---|
| 544 | Int iCols = pcDtParam->iCols; |
---|
| 545 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 546 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 547 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 548 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
[494] | 549 | |
---|
[1029] | 550 | Distortion uiSum = 0; |
---|
[494] | 551 | |
---|
[313] | 552 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 553 | { |
---|
| 554 | for (Int n = 0; n < iCols; n+=16 ) |
---|
| 555 | { |
---|
| 556 | uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] ); |
---|
| 557 | uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] ); |
---|
| 558 | uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] ); |
---|
| 559 | uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] ); |
---|
| 560 | uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] ); |
---|
| 561 | uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] ); |
---|
| 562 | uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] ); |
---|
| 563 | uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] ); |
---|
| 564 | uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] ); |
---|
| 565 | uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] ); |
---|
| 566 | uiSum += abs( piOrg[n+10] - piCur[n+10] ); |
---|
| 567 | uiSum += abs( piOrg[n+11] - piCur[n+11] ); |
---|
| 568 | uiSum += abs( piOrg[n+12] - piCur[n+12] ); |
---|
| 569 | uiSum += abs( piOrg[n+13] - piCur[n+13] ); |
---|
| 570 | uiSum += abs( piOrg[n+14] - piCur[n+14] ); |
---|
| 571 | uiSum += abs( piOrg[n+15] - piCur[n+15] ); |
---|
| 572 | } |
---|
| 573 | piOrg += iStrideOrg; |
---|
| 574 | piCur += iStrideCur; |
---|
| 575 | } |
---|
[494] | 576 | |
---|
[313] | 577 | uiSum <<= iSubShift; |
---|
[1029] | 578 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
[313] | 579 | } |
---|
| 580 | |
---|
[1029] | 581 | Distortion TComRdCost::xGetSAD32( DistParam* pcDtParam ) |
---|
[313] | 582 | { |
---|
| 583 | if ( pcDtParam->bApplyWeight ) |
---|
| 584 | { |
---|
[1029] | 585 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
[313] | 586 | } |
---|
[1029] | 587 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 588 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 589 | Int iRows = pcDtParam->iRows; |
---|
| 590 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 591 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 592 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 593 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
[494] | 594 | |
---|
[1029] | 595 | Distortion uiSum = 0; |
---|
[494] | 596 | |
---|
[313] | 597 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 598 | { |
---|
| 599 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 600 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 601 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 602 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 603 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 604 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 605 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 606 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 607 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 608 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 609 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 610 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 611 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 612 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 613 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 614 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 615 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 616 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 617 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 618 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 619 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 620 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 621 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 622 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 623 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
| 624 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
| 625 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
| 626 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
| 627 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
| 628 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
| 629 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
| 630 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
[494] | 631 | |
---|
[313] | 632 | piOrg += iStrideOrg; |
---|
| 633 | piCur += iStrideCur; |
---|
| 634 | } |
---|
[494] | 635 | |
---|
[313] | 636 | uiSum <<= iSubShift; |
---|
[1029] | 637 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
[313] | 638 | } |
---|
| 639 | |
---|
[1029] | 640 | Distortion TComRdCost::xGetSAD24( DistParam* pcDtParam ) |
---|
[313] | 641 | { |
---|
| 642 | if ( pcDtParam->bApplyWeight ) |
---|
| 643 | { |
---|
[1029] | 644 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
[313] | 645 | } |
---|
[1029] | 646 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 647 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 648 | Int iRows = pcDtParam->iRows; |
---|
| 649 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 650 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 651 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 652 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
[494] | 653 | |
---|
[1029] | 654 | Distortion uiSum = 0; |
---|
[494] | 655 | |
---|
[313] | 656 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 657 | { |
---|
| 658 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 659 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 660 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 661 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 662 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 663 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 664 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 665 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 666 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 667 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 668 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 669 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 670 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 671 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 672 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 673 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 674 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 675 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 676 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 677 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 678 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 679 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 680 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 681 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
[494] | 682 | |
---|
[313] | 683 | piOrg += iStrideOrg; |
---|
| 684 | piCur += iStrideCur; |
---|
| 685 | } |
---|
[494] | 686 | |
---|
[313] | 687 | uiSum <<= iSubShift; |
---|
[1029] | 688 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
[313] | 689 | } |
---|
| 690 | |
---|
[1029] | 691 | Distortion TComRdCost::xGetSAD64( DistParam* pcDtParam ) |
---|
[313] | 692 | { |
---|
| 693 | if ( pcDtParam->bApplyWeight ) |
---|
| 694 | { |
---|
[1029] | 695 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
[313] | 696 | } |
---|
[1029] | 697 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 698 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 699 | Int iRows = pcDtParam->iRows; |
---|
| 700 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 701 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 702 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 703 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
[494] | 704 | |
---|
[1029] | 705 | Distortion uiSum = 0; |
---|
[494] | 706 | |
---|
[313] | 707 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 708 | { |
---|
| 709 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 710 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 711 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 712 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 713 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 714 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 715 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 716 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 717 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 718 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 719 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 720 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 721 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 722 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 723 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 724 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 725 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 726 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 727 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 728 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 729 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 730 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 731 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 732 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 733 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
| 734 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
| 735 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
| 736 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
| 737 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
| 738 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
| 739 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
| 740 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
| 741 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
| 742 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
| 743 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
| 744 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
| 745 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
| 746 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
| 747 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
| 748 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
| 749 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
| 750 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
| 751 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
| 752 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
| 753 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
| 754 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
| 755 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
| 756 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
| 757 | uiSum += abs( piOrg[48] - piCur[48] ); |
---|
| 758 | uiSum += abs( piOrg[49] - piCur[49] ); |
---|
| 759 | uiSum += abs( piOrg[50] - piCur[50] ); |
---|
| 760 | uiSum += abs( piOrg[51] - piCur[51] ); |
---|
| 761 | uiSum += abs( piOrg[52] - piCur[52] ); |
---|
| 762 | uiSum += abs( piOrg[53] - piCur[53] ); |
---|
| 763 | uiSum += abs( piOrg[54] - piCur[54] ); |
---|
| 764 | uiSum += abs( piOrg[55] - piCur[55] ); |
---|
| 765 | uiSum += abs( piOrg[56] - piCur[56] ); |
---|
| 766 | uiSum += abs( piOrg[57] - piCur[57] ); |
---|
| 767 | uiSum += abs( piOrg[58] - piCur[58] ); |
---|
| 768 | uiSum += abs( piOrg[59] - piCur[59] ); |
---|
| 769 | uiSum += abs( piOrg[60] - piCur[60] ); |
---|
| 770 | uiSum += abs( piOrg[61] - piCur[61] ); |
---|
| 771 | uiSum += abs( piOrg[62] - piCur[62] ); |
---|
| 772 | uiSum += abs( piOrg[63] - piCur[63] ); |
---|
[494] | 773 | |
---|
[313] | 774 | piOrg += iStrideOrg; |
---|
| 775 | piCur += iStrideCur; |
---|
| 776 | } |
---|
[494] | 777 | |
---|
[313] | 778 | uiSum <<= iSubShift; |
---|
[1029] | 779 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
[313] | 780 | } |
---|
| 781 | |
---|
[1029] | 782 | Distortion TComRdCost::xGetSAD48( DistParam* pcDtParam ) |
---|
[313] | 783 | { |
---|
| 784 | if ( pcDtParam->bApplyWeight ) |
---|
| 785 | { |
---|
[1029] | 786 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
[313] | 787 | } |
---|
[1029] | 788 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 789 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 790 | Int iRows = pcDtParam->iRows; |
---|
| 791 | Int iSubShift = pcDtParam->iSubShift; |
---|
| 792 | Int iSubStep = ( 1 << iSubShift ); |
---|
| 793 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
| 794 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
[494] | 795 | |
---|
[1029] | 796 | Distortion uiSum = 0; |
---|
[494] | 797 | |
---|
[313] | 798 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
| 799 | { |
---|
| 800 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
| 801 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
| 802 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
| 803 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
| 804 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
| 805 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
| 806 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
| 807 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
| 808 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
| 809 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
| 810 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
| 811 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
| 812 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
| 813 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
| 814 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
| 815 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
| 816 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
| 817 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
| 818 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
| 819 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
| 820 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
| 821 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
| 822 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
| 823 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
| 824 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
| 825 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
| 826 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
| 827 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
| 828 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
| 829 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
| 830 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
| 831 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
| 832 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
| 833 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
| 834 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
| 835 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
| 836 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
| 837 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
| 838 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
| 839 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
| 840 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
| 841 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
| 842 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
| 843 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
| 844 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
| 845 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
| 846 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
| 847 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
[494] | 848 | |
---|
[313] | 849 | piOrg += iStrideOrg; |
---|
| 850 | piCur += iStrideCur; |
---|
| 851 | } |
---|
[494] | 852 | |
---|
[313] | 853 | uiSum <<= iSubShift; |
---|
[1029] | 854 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
[313] | 855 | } |
---|
| 856 | |
---|
| 857 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 858 | // SSE |
---|
| 859 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 860 | |
---|
[1029] | 861 | Distortion TComRdCost::xGetSSE( DistParam* pcDtParam ) |
---|
[313] | 862 | { |
---|
| 863 | if ( pcDtParam->bApplyWeight ) |
---|
| 864 | { |
---|
[1029] | 865 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
[313] | 866 | } |
---|
[1029] | 867 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 868 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 869 | Int iRows = pcDtParam->iRows; |
---|
| 870 | Int iCols = pcDtParam->iCols; |
---|
| 871 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 872 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
[494] | 873 | |
---|
[1029] | 874 | Distortion uiSum = 0; |
---|
| 875 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
[494] | 876 | |
---|
[1029] | 877 | Intermediate_Int iTemp; |
---|
[494] | 878 | |
---|
[313] | 879 | for( ; iRows != 0; iRows-- ) |
---|
| 880 | { |
---|
| 881 | for (Int n = 0; n < iCols; n++ ) |
---|
| 882 | { |
---|
| 883 | iTemp = piOrg[n ] - piCur[n ]; |
---|
[1029] | 884 | uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
[313] | 885 | } |
---|
| 886 | piOrg += iStrideOrg; |
---|
| 887 | piCur += iStrideCur; |
---|
| 888 | } |
---|
[494] | 889 | |
---|
[313] | 890 | return ( uiSum ); |
---|
| 891 | } |
---|
| 892 | |
---|
[1029] | 893 | Distortion TComRdCost::xGetSSE4( DistParam* pcDtParam ) |
---|
[313] | 894 | { |
---|
| 895 | if ( pcDtParam->bApplyWeight ) |
---|
| 896 | { |
---|
| 897 | assert( pcDtParam->iCols == 4 ); |
---|
[1029] | 898 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
[313] | 899 | } |
---|
[1029] | 900 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 901 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 902 | Int iRows = pcDtParam->iRows; |
---|
| 903 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 904 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
[494] | 905 | |
---|
[1029] | 906 | Distortion uiSum = 0; |
---|
| 907 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
[494] | 908 | |
---|
[1029] | 909 | Intermediate_Int iTemp; |
---|
[494] | 910 | |
---|
[313] | 911 | for( ; iRows != 0; iRows-- ) |
---|
| 912 | { |
---|
[494] | 913 | |
---|
[1029] | 914 | iTemp = piOrg[0] - piCur[0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 915 | iTemp = piOrg[1] - piCur[1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 916 | iTemp = piOrg[2] - piCur[2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 917 | iTemp = piOrg[3] - piCur[3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
[494] | 918 | |
---|
[313] | 919 | piOrg += iStrideOrg; |
---|
| 920 | piCur += iStrideCur; |
---|
| 921 | } |
---|
[494] | 922 | |
---|
[313] | 923 | return ( uiSum ); |
---|
| 924 | } |
---|
| 925 | |
---|
[1029] | 926 | Distortion TComRdCost::xGetSSE8( DistParam* pcDtParam ) |
---|
[313] | 927 | { |
---|
| 928 | if ( pcDtParam->bApplyWeight ) |
---|
| 929 | { |
---|
| 930 | assert( pcDtParam->iCols == 8 ); |
---|
[1029] | 931 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
[313] | 932 | } |
---|
[1029] | 933 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 934 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 935 | Int iRows = pcDtParam->iRows; |
---|
| 936 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 937 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
[494] | 938 | |
---|
[1029] | 939 | Distortion uiSum = 0; |
---|
| 940 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
[494] | 941 | |
---|
[1029] | 942 | Intermediate_Int iTemp; |
---|
[494] | 943 | |
---|
[313] | 944 | for( ; iRows != 0; iRows-- ) |
---|
| 945 | { |
---|
[1029] | 946 | iTemp = piOrg[0] - piCur[0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 947 | iTemp = piOrg[1] - piCur[1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 948 | iTemp = piOrg[2] - piCur[2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 949 | iTemp = piOrg[3] - piCur[3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 950 | iTemp = piOrg[4] - piCur[4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 951 | iTemp = piOrg[5] - piCur[5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 952 | iTemp = piOrg[6] - piCur[6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 953 | iTemp = piOrg[7] - piCur[7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
[494] | 954 | |
---|
[313] | 955 | piOrg += iStrideOrg; |
---|
| 956 | piCur += iStrideCur; |
---|
| 957 | } |
---|
[494] | 958 | |
---|
[313] | 959 | return ( uiSum ); |
---|
| 960 | } |
---|
| 961 | |
---|
[1029] | 962 | Distortion TComRdCost::xGetSSE16( DistParam* pcDtParam ) |
---|
[313] | 963 | { |
---|
| 964 | if ( pcDtParam->bApplyWeight ) |
---|
| 965 | { |
---|
| 966 | assert( pcDtParam->iCols == 16 ); |
---|
[1029] | 967 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
[313] | 968 | } |
---|
[1029] | 969 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 970 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 971 | Int iRows = pcDtParam->iRows; |
---|
| 972 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 973 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
[494] | 974 | |
---|
[1029] | 975 | Distortion uiSum = 0; |
---|
| 976 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
[494] | 977 | |
---|
[1029] | 978 | Intermediate_Int iTemp; |
---|
[494] | 979 | |
---|
[313] | 980 | for( ; iRows != 0; iRows-- ) |
---|
| 981 | { |
---|
[494] | 982 | |
---|
[1029] | 983 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 984 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 985 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 986 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 987 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 988 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 989 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 990 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 991 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 992 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 993 | iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 994 | iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 995 | iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 996 | iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 997 | iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 998 | iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
[494] | 999 | |
---|
[313] | 1000 | piOrg += iStrideOrg; |
---|
| 1001 | piCur += iStrideCur; |
---|
| 1002 | } |
---|
[494] | 1003 | |
---|
[313] | 1004 | return ( uiSum ); |
---|
| 1005 | } |
---|
| 1006 | |
---|
[1029] | 1007 | Distortion TComRdCost::xGetSSE16N( DistParam* pcDtParam ) |
---|
[313] | 1008 | { |
---|
| 1009 | if ( pcDtParam->bApplyWeight ) |
---|
| 1010 | { |
---|
[1029] | 1011 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
[313] | 1012 | } |
---|
[1029] | 1013 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 1014 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 1015 | Int iRows = pcDtParam->iRows; |
---|
| 1016 | Int iCols = pcDtParam->iCols; |
---|
| 1017 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1018 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
[494] | 1019 | |
---|
[1029] | 1020 | Distortion uiSum = 0; |
---|
| 1021 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
[494] | 1022 | |
---|
[1029] | 1023 | Intermediate_Int iTemp; |
---|
| 1024 | |
---|
[313] | 1025 | for( ; iRows != 0; iRows-- ) |
---|
| 1026 | { |
---|
| 1027 | for (Int n = 0; n < iCols; n+=16 ) |
---|
| 1028 | { |
---|
[494] | 1029 | |
---|
[1029] | 1030 | iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1031 | iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1032 | iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1033 | iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1034 | iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1035 | iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1036 | iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1037 | iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1038 | iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1039 | iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1040 | iTemp = piOrg[n+10] - piCur[n+10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1041 | iTemp = piOrg[n+11] - piCur[n+11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1042 | iTemp = piOrg[n+12] - piCur[n+12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1043 | iTemp = piOrg[n+13] - piCur[n+13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1044 | iTemp = piOrg[n+14] - piCur[n+14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1045 | iTemp = piOrg[n+15] - piCur[n+15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
[494] | 1046 | |
---|
[313] | 1047 | } |
---|
| 1048 | piOrg += iStrideOrg; |
---|
| 1049 | piCur += iStrideCur; |
---|
| 1050 | } |
---|
[494] | 1051 | |
---|
[313] | 1052 | return ( uiSum ); |
---|
| 1053 | } |
---|
| 1054 | |
---|
[1029] | 1055 | Distortion TComRdCost::xGetSSE32( DistParam* pcDtParam ) |
---|
[313] | 1056 | { |
---|
| 1057 | if ( pcDtParam->bApplyWeight ) |
---|
| 1058 | { |
---|
| 1059 | assert( pcDtParam->iCols == 32 ); |
---|
[1029] | 1060 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
[313] | 1061 | } |
---|
[1029] | 1062 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 1063 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 1064 | Int iRows = pcDtParam->iRows; |
---|
| 1065 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1066 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
[494] | 1067 | |
---|
[1029] | 1068 | Distortion uiSum = 0; |
---|
| 1069 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
[494] | 1070 | |
---|
[1029] | 1071 | Intermediate_Int iTemp; |
---|
| 1072 | |
---|
[313] | 1073 | for( ; iRows != 0; iRows-- ) |
---|
| 1074 | { |
---|
[494] | 1075 | |
---|
[1029] | 1076 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1077 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1078 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1079 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1080 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1081 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1082 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1083 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1084 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1085 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1086 | iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1087 | iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1088 | iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1089 | iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1090 | iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1091 | iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1092 | iTemp = piOrg[16] - piCur[16]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1093 | iTemp = piOrg[17] - piCur[17]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1094 | iTemp = piOrg[18] - piCur[18]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1095 | iTemp = piOrg[19] - piCur[19]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1096 | iTemp = piOrg[20] - piCur[20]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1097 | iTemp = piOrg[21] - piCur[21]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1098 | iTemp = piOrg[22] - piCur[22]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1099 | iTemp = piOrg[23] - piCur[23]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1100 | iTemp = piOrg[24] - piCur[24]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1101 | iTemp = piOrg[25] - piCur[25]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1102 | iTemp = piOrg[26] - piCur[26]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1103 | iTemp = piOrg[27] - piCur[27]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1104 | iTemp = piOrg[28] - piCur[28]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1105 | iTemp = piOrg[29] - piCur[29]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1106 | iTemp = piOrg[30] - piCur[30]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1107 | iTemp = piOrg[31] - piCur[31]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
[494] | 1108 | |
---|
[313] | 1109 | piOrg += iStrideOrg; |
---|
| 1110 | piCur += iStrideCur; |
---|
| 1111 | } |
---|
[494] | 1112 | |
---|
[313] | 1113 | return ( uiSum ); |
---|
| 1114 | } |
---|
| 1115 | |
---|
[1029] | 1116 | Distortion TComRdCost::xGetSSE64( DistParam* pcDtParam ) |
---|
[313] | 1117 | { |
---|
| 1118 | if ( pcDtParam->bApplyWeight ) |
---|
| 1119 | { |
---|
| 1120 | assert( pcDtParam->iCols == 64 ); |
---|
[1029] | 1121 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
[313] | 1122 | } |
---|
[1029] | 1123 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 1124 | const Pel* piCur = pcDtParam->pCur; |
---|
[313] | 1125 | Int iRows = pcDtParam->iRows; |
---|
| 1126 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1127 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
[494] | 1128 | |
---|
[1029] | 1129 | Distortion uiSum = 0; |
---|
| 1130 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
[494] | 1131 | |
---|
[1029] | 1132 | Intermediate_Int iTemp; |
---|
| 1133 | |
---|
[313] | 1134 | for( ; iRows != 0; iRows-- ) |
---|
| 1135 | { |
---|
[1029] | 1136 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1137 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1138 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1139 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1140 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1141 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1142 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1143 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1144 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1145 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1146 | iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1147 | iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1148 | iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1149 | iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1150 | iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1151 | iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1152 | iTemp = piOrg[16] - piCur[16]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1153 | iTemp = piOrg[17] - piCur[17]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1154 | iTemp = piOrg[18] - piCur[18]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1155 | iTemp = piOrg[19] - piCur[19]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1156 | iTemp = piOrg[20] - piCur[20]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1157 | iTemp = piOrg[21] - piCur[21]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1158 | iTemp = piOrg[22] - piCur[22]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1159 | iTemp = piOrg[23] - piCur[23]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1160 | iTemp = piOrg[24] - piCur[24]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1161 | iTemp = piOrg[25] - piCur[25]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1162 | iTemp = piOrg[26] - piCur[26]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1163 | iTemp = piOrg[27] - piCur[27]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1164 | iTemp = piOrg[28] - piCur[28]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1165 | iTemp = piOrg[29] - piCur[29]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1166 | iTemp = piOrg[30] - piCur[30]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1167 | iTemp = piOrg[31] - piCur[31]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1168 | iTemp = piOrg[32] - piCur[32]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1169 | iTemp = piOrg[33] - piCur[33]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1170 | iTemp = piOrg[34] - piCur[34]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1171 | iTemp = piOrg[35] - piCur[35]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1172 | iTemp = piOrg[36] - piCur[36]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1173 | iTemp = piOrg[37] - piCur[37]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1174 | iTemp = piOrg[38] - piCur[38]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1175 | iTemp = piOrg[39] - piCur[39]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1176 | iTemp = piOrg[40] - piCur[40]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1177 | iTemp = piOrg[41] - piCur[41]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1178 | iTemp = piOrg[42] - piCur[42]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1179 | iTemp = piOrg[43] - piCur[43]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1180 | iTemp = piOrg[44] - piCur[44]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1181 | iTemp = piOrg[45] - piCur[45]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1182 | iTemp = piOrg[46] - piCur[46]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1183 | iTemp = piOrg[47] - piCur[47]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1184 | iTemp = piOrg[48] - piCur[48]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1185 | iTemp = piOrg[49] - piCur[49]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1186 | iTemp = piOrg[50] - piCur[50]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1187 | iTemp = piOrg[51] - piCur[51]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1188 | iTemp = piOrg[52] - piCur[52]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1189 | iTemp = piOrg[53] - piCur[53]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1190 | iTemp = piOrg[54] - piCur[54]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1191 | iTemp = piOrg[55] - piCur[55]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1192 | iTemp = piOrg[56] - piCur[56]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1193 | iTemp = piOrg[57] - piCur[57]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1194 | iTemp = piOrg[58] - piCur[58]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1195 | iTemp = piOrg[59] - piCur[59]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1196 | iTemp = piOrg[60] - piCur[60]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1197 | iTemp = piOrg[61] - piCur[61]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1198 | iTemp = piOrg[62] - piCur[62]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
| 1199 | iTemp = piOrg[63] - piCur[63]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
[494] | 1200 | |
---|
[313] | 1201 | piOrg += iStrideOrg; |
---|
| 1202 | piCur += iStrideCur; |
---|
| 1203 | } |
---|
[494] | 1204 | |
---|
[313] | 1205 | return ( uiSum ); |
---|
| 1206 | } |
---|
| 1207 | |
---|
| 1208 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 1209 | // HADAMARD with step (used in fractional search) |
---|
| 1210 | // -------------------------------------------------------------------------------------------------------------------- |
---|
| 1211 | |
---|
[1395] | 1212 | Distortion TComRdCost::xCalcHADs2x2( const Pel *piOrg, const Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
[313] | 1213 | { |
---|
[1029] | 1214 | Distortion satd = 0; |
---|
| 1215 | TCoeff diff[4], m[4]; |
---|
[313] | 1216 | assert( iStep == 1 ); |
---|
| 1217 | diff[0] = piOrg[0 ] - piCur[0]; |
---|
| 1218 | diff[1] = piOrg[1 ] - piCur[1]; |
---|
| 1219 | diff[2] = piOrg[iStrideOrg ] - piCur[0 + iStrideCur]; |
---|
| 1220 | diff[3] = piOrg[iStrideOrg + 1] - piCur[1 + iStrideCur]; |
---|
| 1221 | m[0] = diff[0] + diff[2]; |
---|
| 1222 | m[1] = diff[1] + diff[3]; |
---|
| 1223 | m[2] = diff[0] - diff[2]; |
---|
| 1224 | m[3] = diff[1] - diff[3]; |
---|
[494] | 1225 | |
---|
[313] | 1226 | satd += abs(m[0] + m[1]); |
---|
| 1227 | satd += abs(m[0] - m[1]); |
---|
| 1228 | satd += abs(m[2] + m[3]); |
---|
| 1229 | satd += abs(m[2] - m[3]); |
---|
[494] | 1230 | |
---|
[313] | 1231 | return satd; |
---|
| 1232 | } |
---|
| 1233 | |
---|
[1395] | 1234 | Distortion TComRdCost::xCalcHADs4x4( const Pel *piOrg, const Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
[313] | 1235 | { |
---|
[1029] | 1236 | Int k; |
---|
| 1237 | Distortion satd = 0; |
---|
| 1238 | TCoeff diff[16], m[16], d[16]; |
---|
[494] | 1239 | |
---|
[313] | 1240 | assert( iStep == 1 ); |
---|
| 1241 | for( k = 0; k < 16; k+=4 ) |
---|
| 1242 | { |
---|
| 1243 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
| 1244 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
| 1245 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
| 1246 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
[494] | 1247 | |
---|
[313] | 1248 | piCur += iStrideCur; |
---|
| 1249 | piOrg += iStrideOrg; |
---|
| 1250 | } |
---|
[494] | 1251 | |
---|
[313] | 1252 | /*===== hadamard transform =====*/ |
---|
| 1253 | m[ 0] = diff[ 0] + diff[12]; |
---|
| 1254 | m[ 1] = diff[ 1] + diff[13]; |
---|
| 1255 | m[ 2] = diff[ 2] + diff[14]; |
---|
| 1256 | m[ 3] = diff[ 3] + diff[15]; |
---|
| 1257 | m[ 4] = diff[ 4] + diff[ 8]; |
---|
| 1258 | m[ 5] = diff[ 5] + diff[ 9]; |
---|
| 1259 | m[ 6] = diff[ 6] + diff[10]; |
---|
| 1260 | m[ 7] = diff[ 7] + diff[11]; |
---|
| 1261 | m[ 8] = diff[ 4] - diff[ 8]; |
---|
| 1262 | m[ 9] = diff[ 5] - diff[ 9]; |
---|
| 1263 | m[10] = diff[ 6] - diff[10]; |
---|
| 1264 | m[11] = diff[ 7] - diff[11]; |
---|
| 1265 | m[12] = diff[ 0] - diff[12]; |
---|
| 1266 | m[13] = diff[ 1] - diff[13]; |
---|
| 1267 | m[14] = diff[ 2] - diff[14]; |
---|
| 1268 | m[15] = diff[ 3] - diff[15]; |
---|
[494] | 1269 | |
---|
[313] | 1270 | d[ 0] = m[ 0] + m[ 4]; |
---|
| 1271 | d[ 1] = m[ 1] + m[ 5]; |
---|
| 1272 | d[ 2] = m[ 2] + m[ 6]; |
---|
| 1273 | d[ 3] = m[ 3] + m[ 7]; |
---|
| 1274 | d[ 4] = m[ 8] + m[12]; |
---|
| 1275 | d[ 5] = m[ 9] + m[13]; |
---|
| 1276 | d[ 6] = m[10] + m[14]; |
---|
| 1277 | d[ 7] = m[11] + m[15]; |
---|
| 1278 | d[ 8] = m[ 0] - m[ 4]; |
---|
| 1279 | d[ 9] = m[ 1] - m[ 5]; |
---|
| 1280 | d[10] = m[ 2] - m[ 6]; |
---|
| 1281 | d[11] = m[ 3] - m[ 7]; |
---|
| 1282 | d[12] = m[12] - m[ 8]; |
---|
| 1283 | d[13] = m[13] - m[ 9]; |
---|
| 1284 | d[14] = m[14] - m[10]; |
---|
| 1285 | d[15] = m[15] - m[11]; |
---|
[494] | 1286 | |
---|
[313] | 1287 | m[ 0] = d[ 0] + d[ 3]; |
---|
| 1288 | m[ 1] = d[ 1] + d[ 2]; |
---|
| 1289 | m[ 2] = d[ 1] - d[ 2]; |
---|
| 1290 | m[ 3] = d[ 0] - d[ 3]; |
---|
| 1291 | m[ 4] = d[ 4] + d[ 7]; |
---|
| 1292 | m[ 5] = d[ 5] + d[ 6]; |
---|
| 1293 | m[ 6] = d[ 5] - d[ 6]; |
---|
| 1294 | m[ 7] = d[ 4] - d[ 7]; |
---|
| 1295 | m[ 8] = d[ 8] + d[11]; |
---|
| 1296 | m[ 9] = d[ 9] + d[10]; |
---|
| 1297 | m[10] = d[ 9] - d[10]; |
---|
| 1298 | m[11] = d[ 8] - d[11]; |
---|
| 1299 | m[12] = d[12] + d[15]; |
---|
| 1300 | m[13] = d[13] + d[14]; |
---|
| 1301 | m[14] = d[13] - d[14]; |
---|
| 1302 | m[15] = d[12] - d[15]; |
---|
[494] | 1303 | |
---|
[313] | 1304 | d[ 0] = m[ 0] + m[ 1]; |
---|
| 1305 | d[ 1] = m[ 0] - m[ 1]; |
---|
| 1306 | d[ 2] = m[ 2] + m[ 3]; |
---|
| 1307 | d[ 3] = m[ 3] - m[ 2]; |
---|
| 1308 | d[ 4] = m[ 4] + m[ 5]; |
---|
| 1309 | d[ 5] = m[ 4] - m[ 5]; |
---|
| 1310 | d[ 6] = m[ 6] + m[ 7]; |
---|
| 1311 | d[ 7] = m[ 7] - m[ 6]; |
---|
| 1312 | d[ 8] = m[ 8] + m[ 9]; |
---|
| 1313 | d[ 9] = m[ 8] - m[ 9]; |
---|
| 1314 | d[10] = m[10] + m[11]; |
---|
| 1315 | d[11] = m[11] - m[10]; |
---|
| 1316 | d[12] = m[12] + m[13]; |
---|
| 1317 | d[13] = m[12] - m[13]; |
---|
| 1318 | d[14] = m[14] + m[15]; |
---|
| 1319 | d[15] = m[15] - m[14]; |
---|
[494] | 1320 | |
---|
[313] | 1321 | for (k=0; k<16; ++k) |
---|
| 1322 | { |
---|
| 1323 | satd += abs(d[k]); |
---|
| 1324 | } |
---|
| 1325 | satd = ((satd+1)>>1); |
---|
[494] | 1326 | |
---|
[313] | 1327 | return satd; |
---|
| 1328 | } |
---|
| 1329 | |
---|
[1395] | 1330 | Distortion TComRdCost::xCalcHADs8x8( const Pel *piOrg, const Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
[313] | 1331 | { |
---|
[1029] | 1332 | Int k, i, j, jj; |
---|
| 1333 | Distortion sad = 0; |
---|
| 1334 | TCoeff diff[64], m1[8][8], m2[8][8], m3[8][8]; |
---|
[313] | 1335 | assert( iStep == 1 ); |
---|
| 1336 | for( k = 0; k < 64; k += 8 ) |
---|
| 1337 | { |
---|
| 1338 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
| 1339 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
| 1340 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
| 1341 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
| 1342 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
| 1343 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
| 1344 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
| 1345 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
[494] | 1346 | |
---|
[313] | 1347 | piCur += iStrideCur; |
---|
| 1348 | piOrg += iStrideOrg; |
---|
| 1349 | } |
---|
[494] | 1350 | |
---|
[313] | 1351 | //horizontal |
---|
| 1352 | for (j=0; j < 8; j++) |
---|
| 1353 | { |
---|
| 1354 | jj = j << 3; |
---|
| 1355 | m2[j][0] = diff[jj ] + diff[jj+4]; |
---|
| 1356 | m2[j][1] = diff[jj+1] + diff[jj+5]; |
---|
| 1357 | m2[j][2] = diff[jj+2] + diff[jj+6]; |
---|
| 1358 | m2[j][3] = diff[jj+3] + diff[jj+7]; |
---|
| 1359 | m2[j][4] = diff[jj ] - diff[jj+4]; |
---|
| 1360 | m2[j][5] = diff[jj+1] - diff[jj+5]; |
---|
| 1361 | m2[j][6] = diff[jj+2] - diff[jj+6]; |
---|
| 1362 | m2[j][7] = diff[jj+3] - diff[jj+7]; |
---|
[494] | 1363 | |
---|
[313] | 1364 | m1[j][0] = m2[j][0] + m2[j][2]; |
---|
| 1365 | m1[j][1] = m2[j][1] + m2[j][3]; |
---|
| 1366 | m1[j][2] = m2[j][0] - m2[j][2]; |
---|
| 1367 | m1[j][3] = m2[j][1] - m2[j][3]; |
---|
| 1368 | m1[j][4] = m2[j][4] + m2[j][6]; |
---|
| 1369 | m1[j][5] = m2[j][5] + m2[j][7]; |
---|
| 1370 | m1[j][6] = m2[j][4] - m2[j][6]; |
---|
| 1371 | m1[j][7] = m2[j][5] - m2[j][7]; |
---|
[494] | 1372 | |
---|
[313] | 1373 | m2[j][0] = m1[j][0] + m1[j][1]; |
---|
| 1374 | m2[j][1] = m1[j][0] - m1[j][1]; |
---|
| 1375 | m2[j][2] = m1[j][2] + m1[j][3]; |
---|
| 1376 | m2[j][3] = m1[j][2] - m1[j][3]; |
---|
| 1377 | m2[j][4] = m1[j][4] + m1[j][5]; |
---|
| 1378 | m2[j][5] = m1[j][4] - m1[j][5]; |
---|
| 1379 | m2[j][6] = m1[j][6] + m1[j][7]; |
---|
| 1380 | m2[j][7] = m1[j][6] - m1[j][7]; |
---|
| 1381 | } |
---|
[494] | 1382 | |
---|
[313] | 1383 | //vertical |
---|
| 1384 | for (i=0; i < 8; i++) |
---|
| 1385 | { |
---|
| 1386 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
| 1387 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
| 1388 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
| 1389 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
| 1390 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
| 1391 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
| 1392 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
| 1393 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
[494] | 1394 | |
---|
[313] | 1395 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
| 1396 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
| 1397 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
| 1398 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
| 1399 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
| 1400 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
| 1401 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
| 1402 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
[494] | 1403 | |
---|
[313] | 1404 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
| 1405 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
| 1406 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
| 1407 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
| 1408 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
| 1409 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
| 1410 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
| 1411 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
| 1412 | } |
---|
[494] | 1413 | |
---|
[313] | 1414 | for (i = 0; i < 8; i++) |
---|
| 1415 | { |
---|
| 1416 | for (j = 0; j < 8; j++) |
---|
| 1417 | { |
---|
| 1418 | sad += abs(m2[i][j]); |
---|
| 1419 | } |
---|
| 1420 | } |
---|
[494] | 1421 | |
---|
[313] | 1422 | sad=((sad+2)>>2); |
---|
[494] | 1423 | |
---|
[313] | 1424 | return sad; |
---|
| 1425 | } |
---|
| 1426 | |
---|
[494] | 1427 | |
---|
[1029] | 1428 | Distortion TComRdCost::xGetHADs( DistParam* pcDtParam ) |
---|
[313] | 1429 | { |
---|
| 1430 | if ( pcDtParam->bApplyWeight ) |
---|
| 1431 | { |
---|
[1029] | 1432 | return TComRdCostWeightPrediction::xGetHADsw( pcDtParam ); |
---|
[313] | 1433 | } |
---|
[1395] | 1434 | const Pel* piOrg = pcDtParam->pOrg; |
---|
| 1435 | const Pel* piCur = pcDtParam->pCur; |
---|
| 1436 | const Int iRows = pcDtParam->iRows; |
---|
| 1437 | const Int iCols = pcDtParam->iCols; |
---|
| 1438 | const Int iStrideCur = pcDtParam->iStrideCur; |
---|
| 1439 | const Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
| 1440 | const Int iStep = pcDtParam->iStep; |
---|
[494] | 1441 | |
---|
[313] | 1442 | Int x, y; |
---|
[494] | 1443 | |
---|
[1029] | 1444 | Distortion uiSum = 0; |
---|
[494] | 1445 | |
---|
[313] | 1446 | if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) |
---|
| 1447 | { |
---|
| 1448 | Int iOffsetOrg = iStrideOrg<<3; |
---|
| 1449 | Int iOffsetCur = iStrideCur<<3; |
---|
| 1450 | for ( y=0; y<iRows; y+= 8 ) |
---|
| 1451 | { |
---|
| 1452 | for ( x=0; x<iCols; x+= 8 ) |
---|
| 1453 | { |
---|
| 1454 | uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 1455 | } |
---|
| 1456 | piOrg += iOffsetOrg; |
---|
| 1457 | piCur += iOffsetCur; |
---|
| 1458 | } |
---|
| 1459 | } |
---|
| 1460 | else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) |
---|
| 1461 | { |
---|
| 1462 | Int iOffsetOrg = iStrideOrg<<2; |
---|
| 1463 | Int iOffsetCur = iStrideCur<<2; |
---|
[494] | 1464 | |
---|
[313] | 1465 | for ( y=0; y<iRows; y+= 4 ) |
---|
| 1466 | { |
---|
| 1467 | for ( x=0; x<iCols; x+= 4 ) |
---|
| 1468 | { |
---|
| 1469 | uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 1470 | } |
---|
| 1471 | piOrg += iOffsetOrg; |
---|
| 1472 | piCur += iOffsetCur; |
---|
| 1473 | } |
---|
| 1474 | } |
---|
| 1475 | else if( ( iRows % 2 == 0) && (iCols % 2 == 0) ) |
---|
| 1476 | { |
---|
| 1477 | Int iOffsetOrg = iStrideOrg<<1; |
---|
| 1478 | Int iOffsetCur = iStrideCur<<1; |
---|
| 1479 | for ( y=0; y<iRows; y+=2 ) |
---|
| 1480 | { |
---|
| 1481 | for ( x=0; x<iCols; x+=2 ) |
---|
| 1482 | { |
---|
| 1483 | uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
| 1484 | } |
---|
| 1485 | piOrg += iOffsetOrg; |
---|
| 1486 | piCur += iOffsetCur; |
---|
| 1487 | } |
---|
| 1488 | } |
---|
| 1489 | else |
---|
| 1490 | { |
---|
| 1491 | assert(false); |
---|
| 1492 | } |
---|
[494] | 1493 | |
---|
[1029] | 1494 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
[313] | 1495 | } |
---|
| 1496 | |
---|
| 1497 | //! \} |
---|