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