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