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