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-2012, 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 "TComRom.h" |
---|
41 | #include "TComRdCost.h" |
---|
42 | |
---|
43 | //! \ingroup TLibCommon |
---|
44 | //! \{ |
---|
45 | |
---|
46 | TComRdCost::TComRdCost() |
---|
47 | { |
---|
48 | init(); |
---|
49 | } |
---|
50 | |
---|
51 | TComRdCost::~TComRdCost() |
---|
52 | { |
---|
53 | #if !FIX203 |
---|
54 | xUninit(); |
---|
55 | #endif |
---|
56 | } |
---|
57 | |
---|
58 | // Calculate RD functions |
---|
59 | Double TComRdCost::calcRdCost( UInt uiBits, UInt uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
60 | { |
---|
61 | Double dRdCost = 0.0; |
---|
62 | Double dLambda = 0.0; |
---|
63 | |
---|
64 | switch ( eDFunc ) |
---|
65 | { |
---|
66 | case DF_SSE: |
---|
67 | assert(0); |
---|
68 | break; |
---|
69 | case DF_SAD: |
---|
70 | dLambda = (Double)m_uiLambdaMotionSAD; |
---|
71 | break; |
---|
72 | case DF_DEFAULT: |
---|
73 | dLambda = m_dLambda; |
---|
74 | break; |
---|
75 | case DF_SSE_FRAME: |
---|
76 | dLambda = m_dFrameLambda; |
---|
77 | break; |
---|
78 | default: |
---|
79 | assert (0); |
---|
80 | break; |
---|
81 | } |
---|
82 | |
---|
83 | if (bFlag) |
---|
84 | { |
---|
85 | // Intra8x8, Intra4x4 Block only... |
---|
86 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
87 | dRdCost = (Double)(uiBits); |
---|
88 | #else |
---|
89 | dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda)); |
---|
90 | #endif |
---|
91 | } |
---|
92 | else |
---|
93 | { |
---|
94 | if (eDFunc == DF_SAD) |
---|
95 | { |
---|
96 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16)); |
---|
97 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
98 | } |
---|
99 | else |
---|
100 | { |
---|
101 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
102 | dRdCost = (Double)(uiBits); |
---|
103 | #else |
---|
104 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5))); |
---|
105 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
106 | #endif |
---|
107 | } |
---|
108 | } |
---|
109 | |
---|
110 | return dRdCost; |
---|
111 | } |
---|
112 | |
---|
113 | Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
114 | { |
---|
115 | Double dRdCost = 0.0; |
---|
116 | Double dLambda = 0.0; |
---|
117 | |
---|
118 | switch ( eDFunc ) |
---|
119 | { |
---|
120 | case DF_SSE: |
---|
121 | assert(0); |
---|
122 | break; |
---|
123 | case DF_SAD: |
---|
124 | dLambda = (Double)m_uiLambdaMotionSAD; |
---|
125 | break; |
---|
126 | case DF_DEFAULT: |
---|
127 | dLambda = m_dLambda; |
---|
128 | break; |
---|
129 | case DF_SSE_FRAME: |
---|
130 | dLambda = m_dFrameLambda; |
---|
131 | break; |
---|
132 | default: |
---|
133 | assert (0); |
---|
134 | break; |
---|
135 | } |
---|
136 | |
---|
137 | if (bFlag) |
---|
138 | { |
---|
139 | // Intra8x8, Intra4x4 Block only... |
---|
140 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
141 | dRdCost = (Double)(uiBits); |
---|
142 | #else |
---|
143 | dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda)); |
---|
144 | #endif |
---|
145 | } |
---|
146 | else |
---|
147 | { |
---|
148 | if (eDFunc == DF_SAD) |
---|
149 | { |
---|
150 | dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5)>>16)); |
---|
151 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
152 | } |
---|
153 | else |
---|
154 | { |
---|
155 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
156 | dRdCost = (Double)(uiBits); |
---|
157 | #else |
---|
158 | dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5))); |
---|
159 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
160 | #endif |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | return dRdCost; |
---|
165 | } |
---|
166 | |
---|
167 | Void TComRdCost::setLambda( Double dLambda ) |
---|
168 | { |
---|
169 | m_dLambda = dLambda; |
---|
170 | m_sqrtLambda = sqrt(m_dLambda); |
---|
171 | m_uiLambdaMotionSAD = (UInt)floor(65536.0 * m_sqrtLambda); |
---|
172 | m_uiLambdaMotionSSE = (UInt)floor(65536.0 * m_dLambda ); |
---|
173 | } |
---|
174 | |
---|
175 | |
---|
176 | // Initalize Function Pointer by [eDFunc] |
---|
177 | Void TComRdCost::init() |
---|
178 | { |
---|
179 | m_afpDistortFunc[0] = NULL; // for DF_DEFAULT |
---|
180 | |
---|
181 | m_afpDistortFunc[1] = TComRdCost::xGetSSE; |
---|
182 | m_afpDistortFunc[2] = TComRdCost::xGetSSE4; |
---|
183 | m_afpDistortFunc[3] = TComRdCost::xGetSSE8; |
---|
184 | m_afpDistortFunc[4] = TComRdCost::xGetSSE16; |
---|
185 | m_afpDistortFunc[5] = TComRdCost::xGetSSE32; |
---|
186 | m_afpDistortFunc[6] = TComRdCost::xGetSSE64; |
---|
187 | m_afpDistortFunc[7] = TComRdCost::xGetSSE16N; |
---|
188 | |
---|
189 | m_afpDistortFunc[8] = TComRdCost::xGetSAD; |
---|
190 | m_afpDistortFunc[9] = TComRdCost::xGetSAD4; |
---|
191 | m_afpDistortFunc[10] = TComRdCost::xGetSAD8; |
---|
192 | m_afpDistortFunc[11] = TComRdCost::xGetSAD16; |
---|
193 | m_afpDistortFunc[12] = TComRdCost::xGetSAD32; |
---|
194 | m_afpDistortFunc[13] = TComRdCost::xGetSAD64; |
---|
195 | m_afpDistortFunc[14] = TComRdCost::xGetSAD16N; |
---|
196 | |
---|
197 | m_afpDistortFunc[15] = TComRdCost::xGetSAD; |
---|
198 | m_afpDistortFunc[16] = TComRdCost::xGetSAD4; |
---|
199 | m_afpDistortFunc[17] = TComRdCost::xGetSAD8; |
---|
200 | m_afpDistortFunc[18] = TComRdCost::xGetSAD16; |
---|
201 | m_afpDistortFunc[19] = TComRdCost::xGetSAD32; |
---|
202 | m_afpDistortFunc[20] = TComRdCost::xGetSAD64; |
---|
203 | m_afpDistortFunc[21] = TComRdCost::xGetSAD16N; |
---|
204 | |
---|
205 | #if AMP_SAD |
---|
206 | m_afpDistortFunc[43] = TComRdCost::xGetSAD12; |
---|
207 | m_afpDistortFunc[44] = TComRdCost::xGetSAD24; |
---|
208 | m_afpDistortFunc[45] = TComRdCost::xGetSAD48; |
---|
209 | |
---|
210 | m_afpDistortFunc[46] = TComRdCost::xGetSAD12; |
---|
211 | m_afpDistortFunc[47] = TComRdCost::xGetSAD24; |
---|
212 | m_afpDistortFunc[48] = TComRdCost::xGetSAD48; |
---|
213 | #endif |
---|
214 | m_afpDistortFunc[22] = TComRdCost::xGetHADs; |
---|
215 | m_afpDistortFunc[23] = TComRdCost::xGetHADs; |
---|
216 | m_afpDistortFunc[24] = TComRdCost::xGetHADs; |
---|
217 | m_afpDistortFunc[25] = TComRdCost::xGetHADs; |
---|
218 | m_afpDistortFunc[26] = TComRdCost::xGetHADs; |
---|
219 | m_afpDistortFunc[27] = TComRdCost::xGetHADs; |
---|
220 | m_afpDistortFunc[28] = TComRdCost::xGetHADs; |
---|
221 | |
---|
222 | #if !FIX203 |
---|
223 | m_puiComponentCostOriginP = NULL; |
---|
224 | m_puiComponentCost = NULL; |
---|
225 | m_puiVerCost = NULL; |
---|
226 | m_puiHorCost = NULL; |
---|
227 | #endif |
---|
228 | m_uiCost = 0; |
---|
229 | m_iCostScale = 0; |
---|
230 | #if !FIX203 |
---|
231 | m_iSearchLimit = 0xdeaddead; |
---|
232 | #endif |
---|
233 | } |
---|
234 | |
---|
235 | #if !FIX203 |
---|
236 | Void TComRdCost::initRateDistortionModel( Int iSubPelSearchLimit ) |
---|
237 | { |
---|
238 | // make it larger |
---|
239 | iSubPelSearchLimit += 4; |
---|
240 | iSubPelSearchLimit *= 8; |
---|
241 | |
---|
242 | if( m_iSearchLimit != iSubPelSearchLimit ) |
---|
243 | { |
---|
244 | xUninit(); |
---|
245 | |
---|
246 | m_iSearchLimit = iSubPelSearchLimit; |
---|
247 | |
---|
248 | m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ]; |
---|
249 | iSubPelSearchLimit *= 2; |
---|
250 | |
---|
251 | m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit; |
---|
252 | |
---|
253 | for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++) |
---|
254 | { |
---|
255 | m_puiComponentCost[n] = xGetComponentBits( n ); |
---|
256 | } |
---|
257 | } |
---|
258 | } |
---|
259 | |
---|
260 | Void TComRdCost::xUninit() |
---|
261 | { |
---|
262 | if( NULL != m_puiComponentCostOriginP ) |
---|
263 | { |
---|
264 | delete [] m_puiComponentCostOriginP; |
---|
265 | m_puiComponentCostOriginP = NULL; |
---|
266 | } |
---|
267 | } |
---|
268 | #endif |
---|
269 | |
---|
270 | UInt TComRdCost::xGetComponentBits( Int iVal ) |
---|
271 | { |
---|
272 | UInt uiLength = 1; |
---|
273 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
274 | |
---|
275 | assert ( uiTemp ); |
---|
276 | |
---|
277 | while ( 1 != uiTemp ) |
---|
278 | { |
---|
279 | uiTemp >>= 1; |
---|
280 | uiLength += 2; |
---|
281 | } |
---|
282 | |
---|
283 | return uiLength; |
---|
284 | } |
---|
285 | |
---|
286 | Void TComRdCost::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam ) |
---|
287 | { |
---|
288 | // set Block Width / Height |
---|
289 | rcDistParam.iCols = uiBlkWidth; |
---|
290 | rcDistParam.iRows = uiBlkHeight; |
---|
291 | rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
292 | |
---|
293 | // initialize |
---|
294 | rcDistParam.iSubShift = 0; |
---|
295 | } |
---|
296 | |
---|
297 | // Setting the Distortion Parameter for Inter (ME) |
---|
298 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam ) |
---|
299 | { |
---|
300 | // set Original & Curr Pointer / Stride |
---|
301 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
302 | rcDistParam.pCur = piRefY; |
---|
303 | |
---|
304 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
305 | rcDistParam.iStrideCur = iRefStride; |
---|
306 | |
---|
307 | // set Block Width / Height |
---|
308 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
309 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
310 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
311 | |
---|
312 | #if AMP_SAD |
---|
313 | if (rcDistParam.iCols == 12) |
---|
314 | { |
---|
315 | rcDistParam.DistFunc = m_afpDistortFunc[43 ]; |
---|
316 | } |
---|
317 | else if (rcDistParam.iCols == 24) |
---|
318 | { |
---|
319 | rcDistParam.DistFunc = m_afpDistortFunc[44 ]; |
---|
320 | } |
---|
321 | else if (rcDistParam.iCols == 48) |
---|
322 | { |
---|
323 | rcDistParam.DistFunc = m_afpDistortFunc[45 ]; |
---|
324 | } |
---|
325 | #endif |
---|
326 | |
---|
327 | // initialize |
---|
328 | rcDistParam.iSubShift = 0; |
---|
329 | } |
---|
330 | |
---|
331 | // Setting the Distortion Parameter for Inter (subpel ME with step) |
---|
332 | #if NS_HAD |
---|
333 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME, Bool bUseNSHAD ) |
---|
334 | #else |
---|
335 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME ) |
---|
336 | #endif |
---|
337 | { |
---|
338 | // set Original & Curr Pointer / Stride |
---|
339 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
340 | rcDistParam.pCur = piRefY; |
---|
341 | |
---|
342 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
343 | rcDistParam.iStrideCur = iRefStride * iStep; |
---|
344 | |
---|
345 | // set Step for interpolated buffer |
---|
346 | rcDistParam.iStep = iStep; |
---|
347 | |
---|
348 | // set Block Width / Height |
---|
349 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
350 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
351 | #if NS_HAD |
---|
352 | rcDistParam.bUseNSHAD = bUseNSHAD; |
---|
353 | #endif |
---|
354 | |
---|
355 | // set distortion function |
---|
356 | if ( !bHADME ) |
---|
357 | { |
---|
358 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
359 | #if AMP_SAD |
---|
360 | if (rcDistParam.iCols == 12) |
---|
361 | { |
---|
362 | rcDistParam.DistFunc = m_afpDistortFunc[46 ]; |
---|
363 | } |
---|
364 | else if (rcDistParam.iCols == 24) |
---|
365 | { |
---|
366 | rcDistParam.DistFunc = m_afpDistortFunc[47 ]; |
---|
367 | } |
---|
368 | else if (rcDistParam.iCols == 48) |
---|
369 | { |
---|
370 | rcDistParam.DistFunc = m_afpDistortFunc[48 ]; |
---|
371 | } |
---|
372 | #endif |
---|
373 | } |
---|
374 | else |
---|
375 | { |
---|
376 | rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
377 | } |
---|
378 | |
---|
379 | // initialize |
---|
380 | rcDistParam.iSubShift = 0; |
---|
381 | } |
---|
382 | |
---|
383 | Void |
---|
384 | #if NS_HAD |
---|
385 | TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard, Bool bUseNSHAD ) |
---|
386 | #else |
---|
387 | TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard ) |
---|
388 | #endif |
---|
389 | { |
---|
390 | rcDP.pOrg = p1; |
---|
391 | rcDP.pCur = p2; |
---|
392 | rcDP.iStrideOrg = iStride1; |
---|
393 | rcDP.iStrideCur = iStride2; |
---|
394 | rcDP.iCols = iWidth; |
---|
395 | rcDP.iRows = iHeight; |
---|
396 | rcDP.iStep = 1; |
---|
397 | rcDP.iSubShift = 0; |
---|
398 | rcDP.DistFunc = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ]; |
---|
399 | #if NS_HAD |
---|
400 | rcDP.bUseNSHAD = bUseNSHAD; |
---|
401 | #endif |
---|
402 | } |
---|
403 | |
---|
404 | UInt TComRdCost::calcHAD( Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight ) |
---|
405 | { |
---|
406 | UInt uiSum = 0; |
---|
407 | Int x, y; |
---|
408 | |
---|
409 | if ( ( (iWidth % 8) == 0 ) && ( (iHeight % 8) == 0 ) ) |
---|
410 | { |
---|
411 | for ( y=0; y<iHeight; y+= 8 ) |
---|
412 | { |
---|
413 | for ( x=0; x<iWidth; x+= 8 ) |
---|
414 | { |
---|
415 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
416 | } |
---|
417 | pi0 += iStride0*8; |
---|
418 | pi1 += iStride1*8; |
---|
419 | } |
---|
420 | } |
---|
421 | else if ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) ) |
---|
422 | { |
---|
423 | for ( y=0; y<iHeight; y+= 4 ) |
---|
424 | { |
---|
425 | for ( x=0; x<iWidth; x+= 4 ) |
---|
426 | { |
---|
427 | uiSum += xCalcHADs4x4( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
428 | } |
---|
429 | pi0 += iStride0*4; |
---|
430 | pi1 += iStride1*4; |
---|
431 | } |
---|
432 | } |
---|
433 | else |
---|
434 | { |
---|
435 | for ( y=0; y<iHeight; y+= 2 ) |
---|
436 | { |
---|
437 | for ( x=0; x<iWidth; x+= 2 ) |
---|
438 | { |
---|
439 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
440 | } |
---|
441 | pi0 += iStride0*2; |
---|
442 | pi1 += iStride1*2; |
---|
443 | } |
---|
444 | } |
---|
445 | |
---|
446 | return ( uiSum >> g_uiBitIncrement ); |
---|
447 | } |
---|
448 | |
---|
449 | #if WEIGHTED_CHROMA_DISTORTION |
---|
450 | UInt TComRdCost::getDistPart( Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bWeighted, DFunc eDFunc ) |
---|
451 | #else |
---|
452 | UInt TComRdCost::getDistPart( Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc ) |
---|
453 | #endif |
---|
454 | { |
---|
455 | DistParam cDtParam; |
---|
456 | setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam ); |
---|
457 | cDtParam.pOrg = piOrg; |
---|
458 | cDtParam.pCur = piCur; |
---|
459 | cDtParam.iStrideOrg = iOrgStride; |
---|
460 | cDtParam.iStrideCur = iCurStride; |
---|
461 | cDtParam.iStep = 1; |
---|
462 | |
---|
463 | cDtParam.bApplyWeight = false; |
---|
464 | cDtParam.uiComp = 255; // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed. |
---|
465 | |
---|
466 | #if WEIGHTED_CHROMA_DISTORTION |
---|
467 | if (bWeighted) |
---|
468 | { |
---|
469 | return ((int) (m_chromaDistortionWeight * cDtParam.DistFunc( &cDtParam ))); |
---|
470 | } |
---|
471 | else |
---|
472 | { |
---|
473 | return cDtParam.DistFunc( &cDtParam ); |
---|
474 | } |
---|
475 | #else |
---|
476 | return cDtParam.DistFunc( &cDtParam ); |
---|
477 | #endif |
---|
478 | } |
---|
479 | |
---|
480 | |
---|
481 | |
---|
482 | // ==================================================================================================================== |
---|
483 | // Distortion functions |
---|
484 | // ==================================================================================================================== |
---|
485 | |
---|
486 | // -------------------------------------------------------------------------------------------------------------------- |
---|
487 | // SAD |
---|
488 | // -------------------------------------------------------------------------------------------------------------------- |
---|
489 | |
---|
490 | UInt TComRdCost::xGetSAD( DistParam* pcDtParam ) |
---|
491 | { |
---|
492 | if ( pcDtParam->bApplyWeight ) |
---|
493 | { |
---|
494 | return xGetSADw( pcDtParam ); |
---|
495 | } |
---|
496 | Pel* piOrg = pcDtParam->pOrg; |
---|
497 | Pel* piCur = pcDtParam->pCur; |
---|
498 | Int iRows = pcDtParam->iRows; |
---|
499 | Int iCols = pcDtParam->iCols; |
---|
500 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
501 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
502 | |
---|
503 | UInt uiSum = 0; |
---|
504 | |
---|
505 | for( ; iRows != 0; iRows-- ) |
---|
506 | { |
---|
507 | for (Int n = 0; n < iCols; n++ ) |
---|
508 | { |
---|
509 | uiSum += abs( piOrg[n] - piCur[n] ); |
---|
510 | } |
---|
511 | piOrg += iStrideOrg; |
---|
512 | piCur += iStrideCur; |
---|
513 | } |
---|
514 | |
---|
515 | return ( uiSum >> g_uiBitIncrement ); |
---|
516 | } |
---|
517 | |
---|
518 | UInt TComRdCost::xGetSAD4( DistParam* pcDtParam ) |
---|
519 | { |
---|
520 | if ( pcDtParam->bApplyWeight ) |
---|
521 | { |
---|
522 | return xGetSADw( pcDtParam ); |
---|
523 | } |
---|
524 | Pel* piOrg = pcDtParam->pOrg; |
---|
525 | Pel* piCur = pcDtParam->pCur; |
---|
526 | Int iRows = pcDtParam->iRows; |
---|
527 | Int iSubShift = pcDtParam->iSubShift; |
---|
528 | Int iSubStep = ( 1 << iSubShift ); |
---|
529 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
530 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
531 | |
---|
532 | UInt uiSum = 0; |
---|
533 | |
---|
534 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
535 | { |
---|
536 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
537 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
538 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
539 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
540 | |
---|
541 | piOrg += iStrideOrg; |
---|
542 | piCur += iStrideCur; |
---|
543 | } |
---|
544 | |
---|
545 | uiSum <<= iSubShift; |
---|
546 | return ( uiSum >> g_uiBitIncrement ); |
---|
547 | } |
---|
548 | |
---|
549 | UInt TComRdCost::xGetSAD8( DistParam* pcDtParam ) |
---|
550 | { |
---|
551 | if ( pcDtParam->bApplyWeight ) |
---|
552 | { |
---|
553 | return xGetSADw( pcDtParam ); |
---|
554 | } |
---|
555 | Pel* piOrg = pcDtParam->pOrg; |
---|
556 | Pel* piCur = pcDtParam->pCur; |
---|
557 | Int iRows = pcDtParam->iRows; |
---|
558 | Int iSubShift = pcDtParam->iSubShift; |
---|
559 | Int iSubStep = ( 1 << iSubShift ); |
---|
560 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
561 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
562 | |
---|
563 | UInt uiSum = 0; |
---|
564 | |
---|
565 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
566 | { |
---|
567 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
568 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
569 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
570 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
571 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
572 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
573 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
574 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
575 | |
---|
576 | piOrg += iStrideOrg; |
---|
577 | piCur += iStrideCur; |
---|
578 | } |
---|
579 | |
---|
580 | uiSum <<= iSubShift; |
---|
581 | return ( uiSum >> g_uiBitIncrement ); |
---|
582 | } |
---|
583 | |
---|
584 | UInt TComRdCost::xGetSAD16( DistParam* pcDtParam ) |
---|
585 | { |
---|
586 | if ( pcDtParam->bApplyWeight ) |
---|
587 | { |
---|
588 | return xGetSADw( pcDtParam ); |
---|
589 | } |
---|
590 | Pel* piOrg = pcDtParam->pOrg; |
---|
591 | Pel* piCur = pcDtParam->pCur; |
---|
592 | Int iRows = pcDtParam->iRows; |
---|
593 | Int iSubShift = pcDtParam->iSubShift; |
---|
594 | Int iSubStep = ( 1 << iSubShift ); |
---|
595 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
596 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
597 | |
---|
598 | UInt uiSum = 0; |
---|
599 | |
---|
600 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
601 | { |
---|
602 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
603 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
604 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
605 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
606 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
607 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
608 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
609 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
610 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
611 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
612 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
613 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
614 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
615 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
616 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
617 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
618 | |
---|
619 | piOrg += iStrideOrg; |
---|
620 | piCur += iStrideCur; |
---|
621 | } |
---|
622 | |
---|
623 | uiSum <<= iSubShift; |
---|
624 | return ( uiSum >> g_uiBitIncrement ); |
---|
625 | } |
---|
626 | |
---|
627 | #if AMP_SAD |
---|
628 | UInt TComRdCost::xGetSAD12( DistParam* pcDtParam ) |
---|
629 | { |
---|
630 | if ( pcDtParam->bApplyWeight ) |
---|
631 | { |
---|
632 | return xGetSADw( pcDtParam ); |
---|
633 | } |
---|
634 | Pel* piOrg = pcDtParam->pOrg; |
---|
635 | Pel* piCur = pcDtParam->pCur; |
---|
636 | Int iRows = pcDtParam->iRows; |
---|
637 | Int iSubShift = pcDtParam->iSubShift; |
---|
638 | Int iSubStep = ( 1 << iSubShift ); |
---|
639 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
640 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
641 | |
---|
642 | UInt uiSum = 0; |
---|
643 | |
---|
644 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
645 | { |
---|
646 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
647 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
648 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
649 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
650 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
651 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
652 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
653 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
654 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
655 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
656 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
657 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
658 | |
---|
659 | piOrg += iStrideOrg; |
---|
660 | piCur += iStrideCur; |
---|
661 | } |
---|
662 | |
---|
663 | uiSum <<= iSubShift; |
---|
664 | return ( uiSum >> g_uiBitIncrement ); |
---|
665 | } |
---|
666 | #endif |
---|
667 | |
---|
668 | UInt TComRdCost::xGetSAD16N( DistParam* pcDtParam ) |
---|
669 | { |
---|
670 | Pel* piOrg = pcDtParam->pOrg; |
---|
671 | Pel* piCur = pcDtParam->pCur; |
---|
672 | Int iRows = pcDtParam->iRows; |
---|
673 | Int iCols = pcDtParam->iCols; |
---|
674 | Int iSubShift = pcDtParam->iSubShift; |
---|
675 | Int iSubStep = ( 1 << iSubShift ); |
---|
676 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
677 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
678 | |
---|
679 | UInt uiSum = 0; |
---|
680 | |
---|
681 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
682 | { |
---|
683 | for (Int n = 0; n < iCols; n+=16 ) |
---|
684 | { |
---|
685 | uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] ); |
---|
686 | uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] ); |
---|
687 | uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] ); |
---|
688 | uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] ); |
---|
689 | uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] ); |
---|
690 | uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] ); |
---|
691 | uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] ); |
---|
692 | uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] ); |
---|
693 | uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] ); |
---|
694 | uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] ); |
---|
695 | uiSum += abs( piOrg[n+10] - piCur[n+10] ); |
---|
696 | uiSum += abs( piOrg[n+11] - piCur[n+11] ); |
---|
697 | uiSum += abs( piOrg[n+12] - piCur[n+12] ); |
---|
698 | uiSum += abs( piOrg[n+13] - piCur[n+13] ); |
---|
699 | uiSum += abs( piOrg[n+14] - piCur[n+14] ); |
---|
700 | uiSum += abs( piOrg[n+15] - piCur[n+15] ); |
---|
701 | } |
---|
702 | piOrg += iStrideOrg; |
---|
703 | piCur += iStrideCur; |
---|
704 | } |
---|
705 | |
---|
706 | uiSum <<= iSubShift; |
---|
707 | return ( uiSum >> g_uiBitIncrement ); |
---|
708 | } |
---|
709 | |
---|
710 | UInt TComRdCost::xGetSAD32( DistParam* pcDtParam ) |
---|
711 | { |
---|
712 | if ( pcDtParam->bApplyWeight ) |
---|
713 | { |
---|
714 | return xGetSADw( pcDtParam ); |
---|
715 | } |
---|
716 | Pel* piOrg = pcDtParam->pOrg; |
---|
717 | Pel* piCur = pcDtParam->pCur; |
---|
718 | Int iRows = pcDtParam->iRows; |
---|
719 | Int iSubShift = pcDtParam->iSubShift; |
---|
720 | Int iSubStep = ( 1 << iSubShift ); |
---|
721 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
722 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
723 | |
---|
724 | UInt uiSum = 0; |
---|
725 | |
---|
726 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
727 | { |
---|
728 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
729 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
730 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
731 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
732 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
733 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
734 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
735 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
736 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
737 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
738 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
739 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
740 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
741 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
742 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
743 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
744 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
745 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
746 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
747 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
748 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
749 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
750 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
751 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
752 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
753 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
754 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
755 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
756 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
757 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
758 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
759 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
760 | |
---|
761 | piOrg += iStrideOrg; |
---|
762 | piCur += iStrideCur; |
---|
763 | } |
---|
764 | |
---|
765 | uiSum <<= iSubShift; |
---|
766 | return ( uiSum >> g_uiBitIncrement ); |
---|
767 | } |
---|
768 | |
---|
769 | #if AMP_SAD |
---|
770 | UInt TComRdCost::xGetSAD24( DistParam* pcDtParam ) |
---|
771 | { |
---|
772 | if ( pcDtParam->bApplyWeight ) |
---|
773 | { |
---|
774 | return xGetSADw( pcDtParam ); |
---|
775 | } |
---|
776 | Pel* piOrg = pcDtParam->pOrg; |
---|
777 | Pel* piCur = pcDtParam->pCur; |
---|
778 | Int iRows = pcDtParam->iRows; |
---|
779 | Int iSubShift = pcDtParam->iSubShift; |
---|
780 | Int iSubStep = ( 1 << iSubShift ); |
---|
781 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
782 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
783 | |
---|
784 | UInt uiSum = 0; |
---|
785 | |
---|
786 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
787 | { |
---|
788 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
789 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
790 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
791 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
792 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
793 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
794 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
795 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
796 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
797 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
798 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
799 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
800 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
801 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
802 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
803 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
804 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
805 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
806 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
807 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
808 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
809 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
810 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
811 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
812 | |
---|
813 | piOrg += iStrideOrg; |
---|
814 | piCur += iStrideCur; |
---|
815 | } |
---|
816 | |
---|
817 | uiSum <<= iSubShift; |
---|
818 | return ( uiSum >> g_uiBitIncrement ); |
---|
819 | } |
---|
820 | |
---|
821 | #endif |
---|
822 | |
---|
823 | UInt TComRdCost::xGetSAD64( DistParam* pcDtParam ) |
---|
824 | { |
---|
825 | if ( pcDtParam->bApplyWeight ) |
---|
826 | { |
---|
827 | return xGetSADw( pcDtParam ); |
---|
828 | } |
---|
829 | Pel* piOrg = pcDtParam->pOrg; |
---|
830 | Pel* piCur = pcDtParam->pCur; |
---|
831 | Int iRows = pcDtParam->iRows; |
---|
832 | Int iSubShift = pcDtParam->iSubShift; |
---|
833 | Int iSubStep = ( 1 << iSubShift ); |
---|
834 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
835 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
836 | |
---|
837 | UInt uiSum = 0; |
---|
838 | |
---|
839 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
840 | { |
---|
841 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
842 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
843 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
844 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
845 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
846 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
847 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
848 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
849 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
850 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
851 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
852 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
853 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
854 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
855 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
856 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
857 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
858 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
859 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
860 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
861 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
862 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
863 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
864 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
865 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
866 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
867 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
868 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
869 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
870 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
871 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
872 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
873 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
874 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
875 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
876 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
877 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
878 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
879 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
880 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
881 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
882 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
883 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
884 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
885 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
886 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
887 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
888 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
889 | uiSum += abs( piOrg[48] - piCur[48] ); |
---|
890 | uiSum += abs( piOrg[49] - piCur[49] ); |
---|
891 | uiSum += abs( piOrg[50] - piCur[50] ); |
---|
892 | uiSum += abs( piOrg[51] - piCur[51] ); |
---|
893 | uiSum += abs( piOrg[52] - piCur[52] ); |
---|
894 | uiSum += abs( piOrg[53] - piCur[53] ); |
---|
895 | uiSum += abs( piOrg[54] - piCur[54] ); |
---|
896 | uiSum += abs( piOrg[55] - piCur[55] ); |
---|
897 | uiSum += abs( piOrg[56] - piCur[56] ); |
---|
898 | uiSum += abs( piOrg[57] - piCur[57] ); |
---|
899 | uiSum += abs( piOrg[58] - piCur[58] ); |
---|
900 | uiSum += abs( piOrg[59] - piCur[59] ); |
---|
901 | uiSum += abs( piOrg[60] - piCur[60] ); |
---|
902 | uiSum += abs( piOrg[61] - piCur[61] ); |
---|
903 | uiSum += abs( piOrg[62] - piCur[62] ); |
---|
904 | uiSum += abs( piOrg[63] - piCur[63] ); |
---|
905 | |
---|
906 | piOrg += iStrideOrg; |
---|
907 | piCur += iStrideCur; |
---|
908 | } |
---|
909 | |
---|
910 | uiSum <<= iSubShift; |
---|
911 | return ( uiSum >> g_uiBitIncrement ); |
---|
912 | } |
---|
913 | |
---|
914 | #if AMP_SAD |
---|
915 | UInt TComRdCost::xGetSAD48( DistParam* pcDtParam ) |
---|
916 | { |
---|
917 | if ( pcDtParam->bApplyWeight ) |
---|
918 | { |
---|
919 | return xGetSADw( pcDtParam ); |
---|
920 | } |
---|
921 | Pel* piOrg = pcDtParam->pOrg; |
---|
922 | 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 | UInt 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 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
950 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
951 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
952 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
953 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
954 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
955 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
956 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
957 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
958 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
959 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
960 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
961 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
962 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
963 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
964 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
965 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
966 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
967 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
968 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
969 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
970 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
971 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
972 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
973 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
974 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
975 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
976 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
977 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
978 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
979 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
980 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
981 | |
---|
982 | piOrg += iStrideOrg; |
---|
983 | piCur += iStrideCur; |
---|
984 | } |
---|
985 | |
---|
986 | uiSum <<= iSubShift; |
---|
987 | return ( uiSum >> g_uiBitIncrement ); |
---|
988 | } |
---|
989 | #endif |
---|
990 | |
---|
991 | // -------------------------------------------------------------------------------------------------------------------- |
---|
992 | // SSE |
---|
993 | // -------------------------------------------------------------------------------------------------------------------- |
---|
994 | |
---|
995 | #if IBDI_DISTORTION |
---|
996 | UInt TComRdCost::xGetSSE( DistParam* pcDtParam ) |
---|
997 | { |
---|
998 | Pel* piOrg = pcDtParam->pOrg; |
---|
999 | Pel* piCur = pcDtParam->pCur; |
---|
1000 | Int iRows = pcDtParam->iRows; |
---|
1001 | Int iCols = pcDtParam->iCols; |
---|
1002 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1003 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1004 | |
---|
1005 | UInt uiSum = 0; |
---|
1006 | Int iShift = g_uiBitIncrement; |
---|
1007 | Int iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0; |
---|
1008 | |
---|
1009 | Int iTemp; |
---|
1010 | |
---|
1011 | for( ; iRows != 0; iRows-- ) |
---|
1012 | { |
---|
1013 | for (Int n = 0; n < iCols; n++ ) |
---|
1014 | { |
---|
1015 | iTemp = ((piOrg[n ]+iOffset)>>iShift) - ((piCur[n ]+iOffset)>>iShift); |
---|
1016 | uiSum += iTemp * iTemp; |
---|
1017 | } |
---|
1018 | piOrg += iStrideOrg; |
---|
1019 | piCur += iStrideCur; |
---|
1020 | } |
---|
1021 | |
---|
1022 | return ( uiSum ); |
---|
1023 | } |
---|
1024 | |
---|
1025 | UInt TComRdCost::xGetSSE4( DistParam* pcDtParam ) |
---|
1026 | { |
---|
1027 | Pel* piOrg = pcDtParam->pOrg; |
---|
1028 | Pel* piCur = pcDtParam->pCur; |
---|
1029 | Int iRows = pcDtParam->iRows; |
---|
1030 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1031 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1032 | |
---|
1033 | UInt uiSum = 0; |
---|
1034 | Int iShift = g_uiBitIncrement; |
---|
1035 | Int iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0; |
---|
1036 | |
---|
1037 | Int iTemp; |
---|
1038 | |
---|
1039 | for( ; iRows != 0; iRows-- ) |
---|
1040 | { |
---|
1041 | |
---|
1042 | iTemp = ((piOrg[0]+iOffset)>>iShift) - ((piCur[0]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1043 | iTemp = ((piOrg[1]+iOffset)>>iShift) - ((piCur[1]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1044 | iTemp = ((piOrg[2]+iOffset)>>iShift) - ((piCur[2]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1045 | iTemp = ((piOrg[3]+iOffset)>>iShift) - ((piCur[3]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1046 | |
---|
1047 | piOrg += iStrideOrg; |
---|
1048 | piCur += iStrideCur; |
---|
1049 | } |
---|
1050 | |
---|
1051 | return ( uiSum ); |
---|
1052 | } |
---|
1053 | |
---|
1054 | UInt TComRdCost::xGetSSE8( DistParam* pcDtParam ) |
---|
1055 | { |
---|
1056 | Pel* piOrg = pcDtParam->pOrg; |
---|
1057 | Pel* piCur = pcDtParam->pCur; |
---|
1058 | Int iRows = pcDtParam->iRows; |
---|
1059 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1060 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1061 | |
---|
1062 | UInt uiSum = 0; |
---|
1063 | Int iShift = g_uiBitIncrement; |
---|
1064 | Int iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0; |
---|
1065 | |
---|
1066 | Int iTemp; |
---|
1067 | |
---|
1068 | for( ; iRows != 0; iRows-- ) |
---|
1069 | { |
---|
1070 | iTemp = ((piOrg[0]+iOffset)>>iShift) - ((piCur[0]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1071 | iTemp = ((piOrg[1]+iOffset)>>iShift) - ((piCur[1]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1072 | iTemp = ((piOrg[2]+iOffset)>>iShift) - ((piCur[2]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1073 | iTemp = ((piOrg[3]+iOffset)>>iShift) - ((piCur[3]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1074 | iTemp = ((piOrg[4]+iOffset)>>iShift) - ((piCur[4]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1075 | iTemp = ((piOrg[5]+iOffset)>>iShift) - ((piCur[5]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1076 | iTemp = ((piOrg[6]+iOffset)>>iShift) - ((piCur[6]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1077 | iTemp = ((piOrg[7]+iOffset)>>iShift) - ((piCur[7]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1078 | |
---|
1079 | piOrg += iStrideOrg; |
---|
1080 | piCur += iStrideCur; |
---|
1081 | } |
---|
1082 | |
---|
1083 | return ( uiSum ); |
---|
1084 | } |
---|
1085 | |
---|
1086 | UInt TComRdCost::xGetSSE16( DistParam* pcDtParam ) |
---|
1087 | { |
---|
1088 | Pel* piOrg = pcDtParam->pOrg; |
---|
1089 | Pel* piCur = pcDtParam->pCur; |
---|
1090 | Int iRows = pcDtParam->iRows; |
---|
1091 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1092 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1093 | |
---|
1094 | UInt uiSum = 0; |
---|
1095 | Int iShift = g_uiBitIncrement; |
---|
1096 | Int iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0; |
---|
1097 | |
---|
1098 | Int iTemp; |
---|
1099 | |
---|
1100 | for( ; iRows != 0; iRows-- ) |
---|
1101 | { |
---|
1102 | |
---|
1103 | iTemp = ((piOrg[ 0]+iOffset)>>iShift) - ((piCur[ 0]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1104 | iTemp = ((piOrg[ 1]+iOffset)>>iShift) - ((piCur[ 1]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1105 | iTemp = ((piOrg[ 2]+iOffset)>>iShift) - ((piCur[ 2]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1106 | iTemp = ((piOrg[ 3]+iOffset)>>iShift) - ((piCur[ 3]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1107 | iTemp = ((piOrg[ 4]+iOffset)>>iShift) - ((piCur[ 4]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1108 | iTemp = ((piOrg[ 5]+iOffset)>>iShift) - ((piCur[ 5]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1109 | iTemp = ((piOrg[ 6]+iOffset)>>iShift) - ((piCur[ 6]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1110 | iTemp = ((piOrg[ 7]+iOffset)>>iShift) - ((piCur[ 7]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1111 | iTemp = ((piOrg[ 8]+iOffset)>>iShift) - ((piCur[ 8]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1112 | iTemp = ((piOrg[ 9]+iOffset)>>iShift) - ((piCur[ 9]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1113 | iTemp = ((piOrg[10]+iOffset)>>iShift) - ((piCur[10]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1114 | iTemp = ((piOrg[11]+iOffset)>>iShift) - ((piCur[11]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1115 | iTemp = ((piOrg[12]+iOffset)>>iShift) - ((piCur[12]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1116 | iTemp = ((piOrg[13]+iOffset)>>iShift) - ((piCur[13]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1117 | iTemp = ((piOrg[14]+iOffset)>>iShift) - ((piCur[14]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1118 | iTemp = ((piOrg[15]+iOffset)>>iShift) - ((piCur[15]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1119 | |
---|
1120 | piOrg += iStrideOrg; |
---|
1121 | piCur += iStrideCur; |
---|
1122 | } |
---|
1123 | |
---|
1124 | return ( uiSum ); |
---|
1125 | } |
---|
1126 | |
---|
1127 | UInt TComRdCost::xGetSSE16N( DistParam* pcDtParam ) |
---|
1128 | { |
---|
1129 | Pel* piOrg = pcDtParam->pOrg; |
---|
1130 | Pel* piCur = pcDtParam->pCur; |
---|
1131 | Int iRows = pcDtParam->iRows; |
---|
1132 | Int iCols = pcDtParam->iCols; |
---|
1133 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1134 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1135 | |
---|
1136 | UInt uiSum = 0; |
---|
1137 | Int iShift = g_uiBitIncrement; |
---|
1138 | Int iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0; |
---|
1139 | Int iTemp; |
---|
1140 | |
---|
1141 | for( ; iRows != 0; iRows-- ) |
---|
1142 | { |
---|
1143 | for (Int n = 0; n < iCols; n+=16 ) |
---|
1144 | { |
---|
1145 | |
---|
1146 | iTemp = ((piOrg[n+ 0]+iOffset)>>iShift) - ((piCur[n+ 0]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1147 | iTemp = ((piOrg[n+ 1]+iOffset)>>iShift) - ((piCur[n+ 1]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1148 | iTemp = ((piOrg[n+ 2]+iOffset)>>iShift) - ((piCur[n+ 2]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1149 | iTemp = ((piOrg[n+ 3]+iOffset)>>iShift) - ((piCur[n+ 3]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1150 | iTemp = ((piOrg[n+ 4]+iOffset)>>iShift) - ((piCur[n+ 4]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1151 | iTemp = ((piOrg[n+ 5]+iOffset)>>iShift) - ((piCur[n+ 5]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1152 | iTemp = ((piOrg[n+ 6]+iOffset)>>iShift) - ((piCur[n+ 6]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1153 | iTemp = ((piOrg[n+ 7]+iOffset)>>iShift) - ((piCur[n+ 7]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1154 | iTemp = ((piOrg[n+ 8]+iOffset)>>iShift) - ((piCur[n+ 8]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1155 | iTemp = ((piOrg[n+ 9]+iOffset)>>iShift) - ((piCur[n+ 9]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1156 | iTemp = ((piOrg[n+10]+iOffset)>>iShift) - ((piCur[n+10]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1157 | iTemp = ((piOrg[n+11]+iOffset)>>iShift) - ((piCur[n+11]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1158 | iTemp = ((piOrg[n+12]+iOffset)>>iShift) - ((piCur[n+12]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1159 | iTemp = ((piOrg[n+13]+iOffset)>>iShift) - ((piCur[n+13]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1160 | iTemp = ((piOrg[n+14]+iOffset)>>iShift) - ((piCur[n+14]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1161 | iTemp = ((piOrg[n+15]+iOffset)>>iShift) - ((piCur[n+15]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1162 | |
---|
1163 | } |
---|
1164 | piOrg += iStrideOrg; |
---|
1165 | piCur += iStrideCur; |
---|
1166 | } |
---|
1167 | |
---|
1168 | return ( uiSum ); |
---|
1169 | } |
---|
1170 | |
---|
1171 | UInt TComRdCost::xGetSSE32( DistParam* pcDtParam ) |
---|
1172 | { |
---|
1173 | Pel* piOrg = pcDtParam->pOrg; |
---|
1174 | Pel* piCur = pcDtParam->pCur; |
---|
1175 | Int iRows = pcDtParam->iRows; |
---|
1176 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1177 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1178 | |
---|
1179 | UInt uiSum = 0; |
---|
1180 | Int iShift = g_uiBitIncrement; |
---|
1181 | Int iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0; |
---|
1182 | Int iTemp; |
---|
1183 | |
---|
1184 | for( ; iRows != 0; iRows-- ) |
---|
1185 | { |
---|
1186 | |
---|
1187 | iTemp = ((piOrg[ 0]+iOffset)>>iShift) - ((piCur[ 0]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1188 | iTemp = ((piOrg[ 1]+iOffset)>>iShift) - ((piCur[ 1]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1189 | iTemp = ((piOrg[ 2]+iOffset)>>iShift) - ((piCur[ 2]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1190 | iTemp = ((piOrg[ 3]+iOffset)>>iShift) - ((piCur[ 3]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1191 | iTemp = ((piOrg[ 4]+iOffset)>>iShift) - ((piCur[ 4]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1192 | iTemp = ((piOrg[ 5]+iOffset)>>iShift) - ((piCur[ 5]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1193 | iTemp = ((piOrg[ 6]+iOffset)>>iShift) - ((piCur[ 6]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1194 | iTemp = ((piOrg[ 7]+iOffset)>>iShift) - ((piCur[ 7]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1195 | iTemp = ((piOrg[ 8]+iOffset)>>iShift) - ((piCur[ 8]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1196 | iTemp = ((piOrg[ 9]+iOffset)>>iShift) - ((piCur[ 9]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1197 | iTemp = ((piOrg[10]+iOffset)>>iShift) - ((piCur[10]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1198 | iTemp = ((piOrg[11]+iOffset)>>iShift) - ((piCur[11]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1199 | iTemp = ((piOrg[12]+iOffset)>>iShift) - ((piCur[12]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1200 | iTemp = ((piOrg[13]+iOffset)>>iShift) - ((piCur[13]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1201 | iTemp = ((piOrg[14]+iOffset)>>iShift) - ((piCur[14]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1202 | iTemp = ((piOrg[15]+iOffset)>>iShift) - ((piCur[15]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1203 | iTemp = ((piOrg[16]+iOffset)>>iShift) - ((piCur[16]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1204 | iTemp = ((piOrg[17]+iOffset)>>iShift) - ((piCur[17]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1205 | iTemp = ((piOrg[18]+iOffset)>>iShift) - ((piCur[18]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1206 | iTemp = ((piOrg[19]+iOffset)>>iShift) - ((piCur[19]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1207 | iTemp = ((piOrg[20]+iOffset)>>iShift) - ((piCur[20]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1208 | iTemp = ((piOrg[21]+iOffset)>>iShift) - ((piCur[21]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1209 | iTemp = ((piOrg[22]+iOffset)>>iShift) - ((piCur[22]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1210 | iTemp = ((piOrg[23]+iOffset)>>iShift) - ((piCur[23]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1211 | iTemp = ((piOrg[24]+iOffset)>>iShift) - ((piCur[24]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1212 | iTemp = ((piOrg[25]+iOffset)>>iShift) - ((piCur[25]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1213 | iTemp = ((piOrg[26]+iOffset)>>iShift) - ((piCur[26]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1214 | iTemp = ((piOrg[27]+iOffset)>>iShift) - ((piCur[27]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1215 | iTemp = ((piOrg[28]+iOffset)>>iShift) - ((piCur[28]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1216 | iTemp = ((piOrg[29]+iOffset)>>iShift) - ((piCur[29]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1217 | iTemp = ((piOrg[30]+iOffset)>>iShift) - ((piCur[30]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1218 | iTemp = ((piOrg[31]+iOffset)>>iShift) - ((piCur[31]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1219 | |
---|
1220 | piOrg += iStrideOrg; |
---|
1221 | piCur += iStrideCur; |
---|
1222 | } |
---|
1223 | |
---|
1224 | return ( uiSum ); |
---|
1225 | } |
---|
1226 | |
---|
1227 | UInt TComRdCost::xGetSSE64( DistParam* pcDtParam ) |
---|
1228 | { |
---|
1229 | Pel* piOrg = pcDtParam->pOrg; |
---|
1230 | Pel* piCur = pcDtParam->pCur; |
---|
1231 | Int iRows = pcDtParam->iRows; |
---|
1232 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1233 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1234 | |
---|
1235 | UInt uiSum = 0; |
---|
1236 | Int iShift = g_uiBitIncrement; |
---|
1237 | Int iOffset = (g_uiBitIncrement>0)? (1<<(g_uiBitIncrement-1)):0; |
---|
1238 | Int iTemp; |
---|
1239 | |
---|
1240 | for( ; iRows != 0; iRows-- ) |
---|
1241 | { |
---|
1242 | iTemp = ((piOrg[ 0]+iOffset)>>iShift) - ((piCur[ 0]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1243 | iTemp = ((piOrg[ 1]+iOffset)>>iShift) - ((piCur[ 1]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1244 | iTemp = ((piOrg[ 2]+iOffset)>>iShift) - ((piCur[ 2]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1245 | iTemp = ((piOrg[ 3]+iOffset)>>iShift) - ((piCur[ 3]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1246 | iTemp = ((piOrg[ 4]+iOffset)>>iShift) - ((piCur[ 4]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1247 | iTemp = ((piOrg[ 5]+iOffset)>>iShift) - ((piCur[ 5]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1248 | iTemp = ((piOrg[ 6]+iOffset)>>iShift) - ((piCur[ 6]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1249 | iTemp = ((piOrg[ 7]+iOffset)>>iShift) - ((piCur[ 7]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1250 | iTemp = ((piOrg[ 8]+iOffset)>>iShift) - ((piCur[ 8]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1251 | iTemp = ((piOrg[ 9]+iOffset)>>iShift) - ((piCur[ 9]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1252 | iTemp = ((piOrg[10]+iOffset)>>iShift) - ((piCur[10]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1253 | iTemp = ((piOrg[11]+iOffset)>>iShift) - ((piCur[11]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1254 | iTemp = ((piOrg[12]+iOffset)>>iShift) - ((piCur[12]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1255 | iTemp = ((piOrg[13]+iOffset)>>iShift) - ((piCur[13]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1256 | iTemp = ((piOrg[14]+iOffset)>>iShift) - ((piCur[14]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1257 | iTemp = ((piOrg[15]+iOffset)>>iShift) - ((piCur[15]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1258 | iTemp = ((piOrg[16]+iOffset)>>iShift) - ((piCur[16]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1259 | iTemp = ((piOrg[17]+iOffset)>>iShift) - ((piCur[17]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1260 | iTemp = ((piOrg[18]+iOffset)>>iShift) - ((piCur[18]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1261 | iTemp = ((piOrg[19]+iOffset)>>iShift) - ((piCur[19]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1262 | iTemp = ((piOrg[20]+iOffset)>>iShift) - ((piCur[20]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1263 | iTemp = ((piOrg[21]+iOffset)>>iShift) - ((piCur[21]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1264 | iTemp = ((piOrg[22]+iOffset)>>iShift) - ((piCur[22]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1265 | iTemp = ((piOrg[23]+iOffset)>>iShift) - ((piCur[23]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1266 | iTemp = ((piOrg[24]+iOffset)>>iShift) - ((piCur[24]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1267 | iTemp = ((piOrg[25]+iOffset)>>iShift) - ((piCur[25]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1268 | iTemp = ((piOrg[26]+iOffset)>>iShift) - ((piCur[26]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1269 | iTemp = ((piOrg[27]+iOffset)>>iShift) - ((piCur[27]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1270 | iTemp = ((piOrg[28]+iOffset)>>iShift) - ((piCur[28]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1271 | iTemp = ((piOrg[29]+iOffset)>>iShift) - ((piCur[29]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1272 | iTemp = ((piOrg[30]+iOffset)>>iShift) - ((piCur[30]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1273 | iTemp = ((piOrg[31]+iOffset)>>iShift) - ((piCur[31]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1274 | iTemp = ((piOrg[32]+iOffset)>>iShift) - ((piCur[32]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1275 | iTemp = ((piOrg[33]+iOffset)>>iShift) - ((piCur[33]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1276 | iTemp = ((piOrg[34]+iOffset)>>iShift) - ((piCur[34]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1277 | iTemp = ((piOrg[35]+iOffset)>>iShift) - ((piCur[35]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1278 | iTemp = ((piOrg[36]+iOffset)>>iShift) - ((piCur[36]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1279 | iTemp = ((piOrg[37]+iOffset)>>iShift) - ((piCur[37]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1280 | iTemp = ((piOrg[38]+iOffset)>>iShift) - ((piCur[38]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1281 | iTemp = ((piOrg[39]+iOffset)>>iShift) - ((piCur[39]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1282 | iTemp = ((piOrg[40]+iOffset)>>iShift) - ((piCur[40]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1283 | iTemp = ((piOrg[41]+iOffset)>>iShift) - ((piCur[41]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1284 | iTemp = ((piOrg[42]+iOffset)>>iShift) - ((piCur[42]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1285 | iTemp = ((piOrg[43]+iOffset)>>iShift) - ((piCur[43]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1286 | iTemp = ((piOrg[44]+iOffset)>>iShift) - ((piCur[44]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1287 | iTemp = ((piOrg[45]+iOffset)>>iShift) - ((piCur[45]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1288 | iTemp = ((piOrg[46]+iOffset)>>iShift) - ((piCur[46]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1289 | iTemp = ((piOrg[47]+iOffset)>>iShift) - ((piCur[47]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1290 | iTemp = ((piOrg[48]+iOffset)>>iShift) - ((piCur[48]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1291 | iTemp = ((piOrg[49]+iOffset)>>iShift) - ((piCur[49]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1292 | iTemp = ((piOrg[50]+iOffset)>>iShift) - ((piCur[50]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1293 | iTemp = ((piOrg[51]+iOffset)>>iShift) - ((piCur[51]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1294 | iTemp = ((piOrg[52]+iOffset)>>iShift) - ((piCur[52]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1295 | iTemp = ((piOrg[53]+iOffset)>>iShift) - ((piCur[53]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1296 | iTemp = ((piOrg[54]+iOffset)>>iShift) - ((piCur[54]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1297 | iTemp = ((piOrg[55]+iOffset)>>iShift) - ((piCur[55]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1298 | iTemp = ((piOrg[56]+iOffset)>>iShift) - ((piCur[56]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1299 | iTemp = ((piOrg[57]+iOffset)>>iShift) - ((piCur[57]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1300 | iTemp = ((piOrg[58]+iOffset)>>iShift) - ((piCur[58]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1301 | iTemp = ((piOrg[59]+iOffset)>>iShift) - ((piCur[59]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1302 | iTemp = ((piOrg[60]+iOffset)>>iShift) - ((piCur[60]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1303 | iTemp = ((piOrg[61]+iOffset)>>iShift) - ((piCur[61]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1304 | iTemp = ((piOrg[62]+iOffset)>>iShift) - ((piCur[62]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1305 | iTemp = ((piOrg[63]+iOffset)>>iShift) - ((piCur[63]+iOffset)>>iShift); uiSum += iTemp * iTemp; |
---|
1306 | |
---|
1307 | piOrg += iStrideOrg; |
---|
1308 | piCur += iStrideCur; |
---|
1309 | } |
---|
1310 | |
---|
1311 | return ( uiSum ); |
---|
1312 | } |
---|
1313 | #else |
---|
1314 | UInt TComRdCost::xGetSSE( DistParam* pcDtParam ) |
---|
1315 | { |
---|
1316 | if ( pcDtParam->bApplyWeight ) |
---|
1317 | { |
---|
1318 | return xGetSSEw( pcDtParam ); |
---|
1319 | } |
---|
1320 | Pel* piOrg = pcDtParam->pOrg; |
---|
1321 | Pel* piCur = pcDtParam->pCur; |
---|
1322 | Int iRows = pcDtParam->iRows; |
---|
1323 | Int iCols = pcDtParam->iCols; |
---|
1324 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1325 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1326 | |
---|
1327 | UInt uiSum = 0; |
---|
1328 | UInt uiShift = g_uiBitIncrement<<1; |
---|
1329 | |
---|
1330 | Int iTemp; |
---|
1331 | |
---|
1332 | for( ; iRows != 0; iRows-- ) |
---|
1333 | { |
---|
1334 | for (Int n = 0; n < iCols; n++ ) |
---|
1335 | { |
---|
1336 | iTemp = piOrg[n ] - piCur[n ]; |
---|
1337 | uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1338 | } |
---|
1339 | piOrg += iStrideOrg; |
---|
1340 | piCur += iStrideCur; |
---|
1341 | } |
---|
1342 | |
---|
1343 | return ( uiSum ); |
---|
1344 | } |
---|
1345 | |
---|
1346 | UInt TComRdCost::xGetSSE4( DistParam* pcDtParam ) |
---|
1347 | { |
---|
1348 | if ( pcDtParam->bApplyWeight ) |
---|
1349 | { |
---|
1350 | assert( pcDtParam->iCols == 4 ); |
---|
1351 | return xGetSSEw( pcDtParam ); |
---|
1352 | } |
---|
1353 | Pel* piOrg = pcDtParam->pOrg; |
---|
1354 | Pel* piCur = pcDtParam->pCur; |
---|
1355 | Int iRows = pcDtParam->iRows; |
---|
1356 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1357 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1358 | |
---|
1359 | UInt uiSum = 0; |
---|
1360 | UInt uiShift = g_uiBitIncrement<<1; |
---|
1361 | |
---|
1362 | Int iTemp; |
---|
1363 | |
---|
1364 | for( ; iRows != 0; iRows-- ) |
---|
1365 | { |
---|
1366 | |
---|
1367 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1368 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1369 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1370 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1371 | |
---|
1372 | piOrg += iStrideOrg; |
---|
1373 | piCur += iStrideCur; |
---|
1374 | } |
---|
1375 | |
---|
1376 | return ( uiSum ); |
---|
1377 | } |
---|
1378 | |
---|
1379 | UInt TComRdCost::xGetSSE8( DistParam* pcDtParam ) |
---|
1380 | { |
---|
1381 | if ( pcDtParam->bApplyWeight ) |
---|
1382 | { |
---|
1383 | assert( pcDtParam->iCols == 8 ); |
---|
1384 | return xGetSSEw( pcDtParam ); |
---|
1385 | } |
---|
1386 | Pel* piOrg = pcDtParam->pOrg; |
---|
1387 | Pel* piCur = pcDtParam->pCur; |
---|
1388 | Int iRows = pcDtParam->iRows; |
---|
1389 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1390 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1391 | |
---|
1392 | UInt uiSum = 0; |
---|
1393 | UInt uiShift = g_uiBitIncrement<<1; |
---|
1394 | |
---|
1395 | Int iTemp; |
---|
1396 | |
---|
1397 | for( ; iRows != 0; iRows-- ) |
---|
1398 | { |
---|
1399 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1400 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1401 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1402 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1403 | iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1404 | iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1405 | iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1406 | iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1407 | |
---|
1408 | piOrg += iStrideOrg; |
---|
1409 | piCur += iStrideCur; |
---|
1410 | } |
---|
1411 | |
---|
1412 | return ( uiSum ); |
---|
1413 | } |
---|
1414 | |
---|
1415 | UInt TComRdCost::xGetSSE16( DistParam* pcDtParam ) |
---|
1416 | { |
---|
1417 | if ( pcDtParam->bApplyWeight ) |
---|
1418 | { |
---|
1419 | assert( pcDtParam->iCols == 16 ); |
---|
1420 | return xGetSSEw( pcDtParam ); |
---|
1421 | } |
---|
1422 | Pel* piOrg = pcDtParam->pOrg; |
---|
1423 | Pel* piCur = pcDtParam->pCur; |
---|
1424 | Int iRows = pcDtParam->iRows; |
---|
1425 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1426 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1427 | |
---|
1428 | UInt uiSum = 0; |
---|
1429 | UInt uiShift = g_uiBitIncrement<<1; |
---|
1430 | |
---|
1431 | Int iTemp; |
---|
1432 | |
---|
1433 | for( ; iRows != 0; iRows-- ) |
---|
1434 | { |
---|
1435 | |
---|
1436 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1437 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1438 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1439 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1440 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1441 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1442 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1443 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1444 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1445 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1446 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1447 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1448 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1449 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1450 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1451 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1452 | |
---|
1453 | piOrg += iStrideOrg; |
---|
1454 | piCur += iStrideCur; |
---|
1455 | } |
---|
1456 | |
---|
1457 | return ( uiSum ); |
---|
1458 | } |
---|
1459 | |
---|
1460 | UInt TComRdCost::xGetSSE16N( DistParam* pcDtParam ) |
---|
1461 | { |
---|
1462 | if ( pcDtParam->bApplyWeight ) |
---|
1463 | { |
---|
1464 | return xGetSSEw( pcDtParam ); |
---|
1465 | } |
---|
1466 | Pel* piOrg = pcDtParam->pOrg; |
---|
1467 | Pel* piCur = pcDtParam->pCur; |
---|
1468 | Int iRows = pcDtParam->iRows; |
---|
1469 | Int iCols = pcDtParam->iCols; |
---|
1470 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1471 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1472 | |
---|
1473 | UInt uiSum = 0; |
---|
1474 | UInt uiShift = g_uiBitIncrement<<1; |
---|
1475 | Int iTemp; |
---|
1476 | |
---|
1477 | for( ; iRows != 0; iRows-- ) |
---|
1478 | { |
---|
1479 | for (Int n = 0; n < iCols; n+=16 ) |
---|
1480 | { |
---|
1481 | |
---|
1482 | iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1483 | iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1484 | iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1485 | iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1486 | iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1487 | iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1488 | iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1489 | iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1490 | iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1491 | iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1492 | iTemp = piOrg[n+10] - piCur[n+10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1493 | iTemp = piOrg[n+11] - piCur[n+11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1494 | iTemp = piOrg[n+12] - piCur[n+12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1495 | iTemp = piOrg[n+13] - piCur[n+13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1496 | iTemp = piOrg[n+14] - piCur[n+14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1497 | iTemp = piOrg[n+15] - piCur[n+15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1498 | |
---|
1499 | } |
---|
1500 | piOrg += iStrideOrg; |
---|
1501 | piCur += iStrideCur; |
---|
1502 | } |
---|
1503 | |
---|
1504 | return ( uiSum ); |
---|
1505 | } |
---|
1506 | |
---|
1507 | UInt TComRdCost::xGetSSE32( DistParam* pcDtParam ) |
---|
1508 | { |
---|
1509 | if ( pcDtParam->bApplyWeight ) |
---|
1510 | { |
---|
1511 | assert( pcDtParam->iCols == 32 ); |
---|
1512 | return xGetSSEw( pcDtParam ); |
---|
1513 | } |
---|
1514 | Pel* piOrg = pcDtParam->pOrg; |
---|
1515 | Pel* piCur = pcDtParam->pCur; |
---|
1516 | Int iRows = pcDtParam->iRows; |
---|
1517 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1518 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1519 | |
---|
1520 | UInt uiSum = 0; |
---|
1521 | UInt uiShift = g_uiBitIncrement<<1; |
---|
1522 | Int iTemp; |
---|
1523 | |
---|
1524 | for( ; iRows != 0; iRows-- ) |
---|
1525 | { |
---|
1526 | |
---|
1527 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1528 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1529 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1530 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1531 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1532 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1533 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1534 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1535 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1536 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1537 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1538 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1539 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1540 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1541 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1542 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1543 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1544 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1545 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1546 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1547 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1548 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1549 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1550 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1551 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1552 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1553 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1554 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1555 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1556 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1557 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1558 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1559 | |
---|
1560 | piOrg += iStrideOrg; |
---|
1561 | piCur += iStrideCur; |
---|
1562 | } |
---|
1563 | |
---|
1564 | return ( uiSum ); |
---|
1565 | } |
---|
1566 | |
---|
1567 | UInt TComRdCost::xGetSSE64( DistParam* pcDtParam ) |
---|
1568 | { |
---|
1569 | if ( pcDtParam->bApplyWeight ) |
---|
1570 | { |
---|
1571 | assert( pcDtParam->iCols == 64 ); |
---|
1572 | return xGetSSEw( pcDtParam ); |
---|
1573 | } |
---|
1574 | Pel* piOrg = pcDtParam->pOrg; |
---|
1575 | Pel* piCur = pcDtParam->pCur; |
---|
1576 | Int iRows = pcDtParam->iRows; |
---|
1577 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1578 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1579 | |
---|
1580 | UInt uiSum = 0; |
---|
1581 | UInt uiShift = g_uiBitIncrement<<1; |
---|
1582 | Int iTemp; |
---|
1583 | |
---|
1584 | for( ; iRows != 0; iRows-- ) |
---|
1585 | { |
---|
1586 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1587 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1588 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1589 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1590 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1591 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1592 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1593 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1594 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1595 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1596 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1597 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1598 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1599 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1600 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1601 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1602 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1603 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1604 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1605 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1606 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1607 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1608 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1609 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1610 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1611 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1612 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1613 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1614 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1615 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1616 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1617 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1618 | iTemp = piOrg[32] - piCur[32]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1619 | iTemp = piOrg[33] - piCur[33]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1620 | iTemp = piOrg[34] - piCur[34]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1621 | iTemp = piOrg[35] - piCur[35]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1622 | iTemp = piOrg[36] - piCur[36]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1623 | iTemp = piOrg[37] - piCur[37]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1624 | iTemp = piOrg[38] - piCur[38]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1625 | iTemp = piOrg[39] - piCur[39]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1626 | iTemp = piOrg[40] - piCur[40]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1627 | iTemp = piOrg[41] - piCur[41]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1628 | iTemp = piOrg[42] - piCur[42]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1629 | iTemp = piOrg[43] - piCur[43]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1630 | iTemp = piOrg[44] - piCur[44]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1631 | iTemp = piOrg[45] - piCur[45]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1632 | iTemp = piOrg[46] - piCur[46]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1633 | iTemp = piOrg[47] - piCur[47]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1634 | iTemp = piOrg[48] - piCur[48]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1635 | iTemp = piOrg[49] - piCur[49]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1636 | iTemp = piOrg[50] - piCur[50]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1637 | iTemp = piOrg[51] - piCur[51]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1638 | iTemp = piOrg[52] - piCur[52]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1639 | iTemp = piOrg[53] - piCur[53]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1640 | iTemp = piOrg[54] - piCur[54]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1641 | iTemp = piOrg[55] - piCur[55]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1642 | iTemp = piOrg[56] - piCur[56]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1643 | iTemp = piOrg[57] - piCur[57]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1644 | iTemp = piOrg[58] - piCur[58]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1645 | iTemp = piOrg[59] - piCur[59]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1646 | iTemp = piOrg[60] - piCur[60]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1647 | iTemp = piOrg[61] - piCur[61]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1648 | iTemp = piOrg[62] - piCur[62]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1649 | iTemp = piOrg[63] - piCur[63]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1650 | |
---|
1651 | piOrg += iStrideOrg; |
---|
1652 | piCur += iStrideCur; |
---|
1653 | } |
---|
1654 | |
---|
1655 | return ( uiSum ); |
---|
1656 | } |
---|
1657 | #endif |
---|
1658 | |
---|
1659 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1660 | // HADAMARD with step (used in fractional search) |
---|
1661 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1662 | |
---|
1663 | UInt TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1664 | { |
---|
1665 | Int satd = 0, diff[4], m[4]; |
---|
1666 | assert( iStep == 1 ); |
---|
1667 | diff[0] = piOrg[0 ] - piCur[0]; |
---|
1668 | diff[1] = piOrg[1 ] - piCur[1]; |
---|
1669 | diff[2] = piOrg[iStrideOrg ] - piCur[0 + iStrideCur]; |
---|
1670 | diff[3] = piOrg[iStrideOrg + 1] - piCur[1 + iStrideCur]; |
---|
1671 | m[0] = diff[0] + diff[2]; |
---|
1672 | m[1] = diff[1] + diff[3]; |
---|
1673 | m[2] = diff[0] - diff[2]; |
---|
1674 | m[3] = diff[1] - diff[3]; |
---|
1675 | |
---|
1676 | satd += abs(m[0] + m[1]); |
---|
1677 | satd += abs(m[0] - m[1]); |
---|
1678 | satd += abs(m[2] + m[3]); |
---|
1679 | satd += abs(m[2] - m[3]); |
---|
1680 | |
---|
1681 | return satd; |
---|
1682 | } |
---|
1683 | |
---|
1684 | UInt TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1685 | { |
---|
1686 | Int k, satd = 0, diff[16], m[16], d[16]; |
---|
1687 | |
---|
1688 | assert( iStep == 1 ); |
---|
1689 | for( k = 0; k < 16; k+=4 ) |
---|
1690 | { |
---|
1691 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1692 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1693 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1694 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1695 | |
---|
1696 | piCur += iStrideCur; |
---|
1697 | piOrg += iStrideOrg; |
---|
1698 | } |
---|
1699 | |
---|
1700 | /*===== hadamard transform =====*/ |
---|
1701 | m[ 0] = diff[ 0] + diff[12]; |
---|
1702 | m[ 1] = diff[ 1] + diff[13]; |
---|
1703 | m[ 2] = diff[ 2] + diff[14]; |
---|
1704 | m[ 3] = diff[ 3] + diff[15]; |
---|
1705 | m[ 4] = diff[ 4] + diff[ 8]; |
---|
1706 | m[ 5] = diff[ 5] + diff[ 9]; |
---|
1707 | m[ 6] = diff[ 6] + diff[10]; |
---|
1708 | m[ 7] = diff[ 7] + diff[11]; |
---|
1709 | m[ 8] = diff[ 4] - diff[ 8]; |
---|
1710 | m[ 9] = diff[ 5] - diff[ 9]; |
---|
1711 | m[10] = diff[ 6] - diff[10]; |
---|
1712 | m[11] = diff[ 7] - diff[11]; |
---|
1713 | m[12] = diff[ 0] - diff[12]; |
---|
1714 | m[13] = diff[ 1] - diff[13]; |
---|
1715 | m[14] = diff[ 2] - diff[14]; |
---|
1716 | m[15] = diff[ 3] - diff[15]; |
---|
1717 | |
---|
1718 | d[ 0] = m[ 0] + m[ 4]; |
---|
1719 | d[ 1] = m[ 1] + m[ 5]; |
---|
1720 | d[ 2] = m[ 2] + m[ 6]; |
---|
1721 | d[ 3] = m[ 3] + m[ 7]; |
---|
1722 | d[ 4] = m[ 8] + m[12]; |
---|
1723 | d[ 5] = m[ 9] + m[13]; |
---|
1724 | d[ 6] = m[10] + m[14]; |
---|
1725 | d[ 7] = m[11] + m[15]; |
---|
1726 | d[ 8] = m[ 0] - m[ 4]; |
---|
1727 | d[ 9] = m[ 1] - m[ 5]; |
---|
1728 | d[10] = m[ 2] - m[ 6]; |
---|
1729 | d[11] = m[ 3] - m[ 7]; |
---|
1730 | d[12] = m[12] - m[ 8]; |
---|
1731 | d[13] = m[13] - m[ 9]; |
---|
1732 | d[14] = m[14] - m[10]; |
---|
1733 | d[15] = m[15] - m[11]; |
---|
1734 | |
---|
1735 | m[ 0] = d[ 0] + d[ 3]; |
---|
1736 | m[ 1] = d[ 1] + d[ 2]; |
---|
1737 | m[ 2] = d[ 1] - d[ 2]; |
---|
1738 | m[ 3] = d[ 0] - d[ 3]; |
---|
1739 | m[ 4] = d[ 4] + d[ 7]; |
---|
1740 | m[ 5] = d[ 5] + d[ 6]; |
---|
1741 | m[ 6] = d[ 5] - d[ 6]; |
---|
1742 | m[ 7] = d[ 4] - d[ 7]; |
---|
1743 | m[ 8] = d[ 8] + d[11]; |
---|
1744 | m[ 9] = d[ 9] + d[10]; |
---|
1745 | m[10] = d[ 9] - d[10]; |
---|
1746 | m[11] = d[ 8] - d[11]; |
---|
1747 | m[12] = d[12] + d[15]; |
---|
1748 | m[13] = d[13] + d[14]; |
---|
1749 | m[14] = d[13] - d[14]; |
---|
1750 | m[15] = d[12] - d[15]; |
---|
1751 | |
---|
1752 | d[ 0] = m[ 0] + m[ 1]; |
---|
1753 | d[ 1] = m[ 0] - m[ 1]; |
---|
1754 | d[ 2] = m[ 2] + m[ 3]; |
---|
1755 | d[ 3] = m[ 3] - m[ 2]; |
---|
1756 | d[ 4] = m[ 4] + m[ 5]; |
---|
1757 | d[ 5] = m[ 4] - m[ 5]; |
---|
1758 | d[ 6] = m[ 6] + m[ 7]; |
---|
1759 | d[ 7] = m[ 7] - m[ 6]; |
---|
1760 | d[ 8] = m[ 8] + m[ 9]; |
---|
1761 | d[ 9] = m[ 8] - m[ 9]; |
---|
1762 | d[10] = m[10] + m[11]; |
---|
1763 | d[11] = m[11] - m[10]; |
---|
1764 | d[12] = m[12] + m[13]; |
---|
1765 | d[13] = m[12] - m[13]; |
---|
1766 | d[14] = m[14] + m[15]; |
---|
1767 | d[15] = m[15] - m[14]; |
---|
1768 | |
---|
1769 | for (k=0; k<16; ++k) |
---|
1770 | { |
---|
1771 | satd += abs(d[k]); |
---|
1772 | } |
---|
1773 | satd = ((satd+1)>>1); |
---|
1774 | |
---|
1775 | return satd; |
---|
1776 | } |
---|
1777 | |
---|
1778 | UInt TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1779 | { |
---|
1780 | Int k, i, j, jj, sad=0; |
---|
1781 | Int diff[64], m1[8][8], m2[8][8], m3[8][8]; |
---|
1782 | assert( iStep == 1 ); |
---|
1783 | for( k = 0; k < 64; k += 8 ) |
---|
1784 | { |
---|
1785 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1786 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1787 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1788 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1789 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
1790 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
1791 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
1792 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
1793 | |
---|
1794 | piCur += iStrideCur; |
---|
1795 | piOrg += iStrideOrg; |
---|
1796 | } |
---|
1797 | |
---|
1798 | //horizontal |
---|
1799 | for (j=0; j < 8; j++) |
---|
1800 | { |
---|
1801 | jj = j << 3; |
---|
1802 | m2[j][0] = diff[jj ] + diff[jj+4]; |
---|
1803 | m2[j][1] = diff[jj+1] + diff[jj+5]; |
---|
1804 | m2[j][2] = diff[jj+2] + diff[jj+6]; |
---|
1805 | m2[j][3] = diff[jj+3] + diff[jj+7]; |
---|
1806 | m2[j][4] = diff[jj ] - diff[jj+4]; |
---|
1807 | m2[j][5] = diff[jj+1] - diff[jj+5]; |
---|
1808 | m2[j][6] = diff[jj+2] - diff[jj+6]; |
---|
1809 | m2[j][7] = diff[jj+3] - diff[jj+7]; |
---|
1810 | |
---|
1811 | m1[j][0] = m2[j][0] + m2[j][2]; |
---|
1812 | m1[j][1] = m2[j][1] + m2[j][3]; |
---|
1813 | m1[j][2] = m2[j][0] - m2[j][2]; |
---|
1814 | m1[j][3] = m2[j][1] - m2[j][3]; |
---|
1815 | m1[j][4] = m2[j][4] + m2[j][6]; |
---|
1816 | m1[j][5] = m2[j][5] + m2[j][7]; |
---|
1817 | m1[j][6] = m2[j][4] - m2[j][6]; |
---|
1818 | m1[j][7] = m2[j][5] - m2[j][7]; |
---|
1819 | |
---|
1820 | m2[j][0] = m1[j][0] + m1[j][1]; |
---|
1821 | m2[j][1] = m1[j][0] - m1[j][1]; |
---|
1822 | m2[j][2] = m1[j][2] + m1[j][3]; |
---|
1823 | m2[j][3] = m1[j][2] - m1[j][3]; |
---|
1824 | m2[j][4] = m1[j][4] + m1[j][5]; |
---|
1825 | m2[j][5] = m1[j][4] - m1[j][5]; |
---|
1826 | m2[j][6] = m1[j][6] + m1[j][7]; |
---|
1827 | m2[j][7] = m1[j][6] - m1[j][7]; |
---|
1828 | } |
---|
1829 | |
---|
1830 | //vertical |
---|
1831 | for (i=0; i < 8; i++) |
---|
1832 | { |
---|
1833 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
1834 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
1835 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
1836 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
1837 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
1838 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
1839 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
1840 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
1841 | |
---|
1842 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
1843 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
1844 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
1845 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
1846 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
1847 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
1848 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
1849 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
1850 | |
---|
1851 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
1852 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
1853 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
1854 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
1855 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
1856 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
1857 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
1858 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
1859 | } |
---|
1860 | |
---|
1861 | for (i = 0; i < 8; i++) |
---|
1862 | { |
---|
1863 | for (j = 0; j < 8; j++) |
---|
1864 | { |
---|
1865 | sad += abs(m2[i][j]); |
---|
1866 | } |
---|
1867 | } |
---|
1868 | |
---|
1869 | sad=((sad+2)>>2); |
---|
1870 | |
---|
1871 | return sad; |
---|
1872 | } |
---|
1873 | |
---|
1874 | #if NS_HAD |
---|
1875 | UInt TComRdCost::xCalcHADs16x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1876 | { |
---|
1877 | Int k, i, j, jj, sad=0; |
---|
1878 | Int diff[64], m1[4][16], m2[4][16]; |
---|
1879 | assert( iStep == 1 ); |
---|
1880 | for( k = 0; k < 64; k += 16 ) |
---|
1881 | { |
---|
1882 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1883 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1884 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1885 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1886 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
1887 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
1888 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
1889 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
1890 | |
---|
1891 | diff[k+8] = piOrg[8] - piCur[8] ; |
---|
1892 | diff[k+9] = piOrg[9] - piCur[9] ; |
---|
1893 | diff[k+10] = piOrg[10] - piCur[10]; |
---|
1894 | diff[k+11] = piOrg[11] - piCur[11]; |
---|
1895 | diff[k+12] = piOrg[12] - piCur[12]; |
---|
1896 | diff[k+13] = piOrg[13] - piCur[13]; |
---|
1897 | diff[k+14] = piOrg[14] - piCur[14]; |
---|
1898 | diff[k+15] = piOrg[15] - piCur[15]; |
---|
1899 | |
---|
1900 | piCur += iStrideCur; |
---|
1901 | piOrg += iStrideOrg; |
---|
1902 | } |
---|
1903 | |
---|
1904 | //horizontal |
---|
1905 | for (j=0; j < 4; j++) |
---|
1906 | { |
---|
1907 | jj = j << 4; |
---|
1908 | |
---|
1909 | m2[j][0] = diff[jj ] + diff[jj+8]; |
---|
1910 | m2[j][1] = diff[jj+1] + diff[jj+9]; |
---|
1911 | m2[j][2] = diff[jj+2] + diff[jj+10]; |
---|
1912 | m2[j][3] = diff[jj+3] + diff[jj+11]; |
---|
1913 | m2[j][4] = diff[jj+4] + diff[jj+12]; |
---|
1914 | m2[j][5] = diff[jj+5] + diff[jj+13]; |
---|
1915 | m2[j][6] = diff[jj+6] + diff[jj+14]; |
---|
1916 | m2[j][7] = diff[jj+7] + diff[jj+15]; |
---|
1917 | m2[j][8] = diff[jj ] - diff[jj+8]; |
---|
1918 | m2[j][9] = diff[jj+1] - diff[jj+9]; |
---|
1919 | m2[j][10] = diff[jj+2] - diff[jj+10]; |
---|
1920 | m2[j][11] = diff[jj+3] - diff[jj+11]; |
---|
1921 | m2[j][12] = diff[jj+4] - diff[jj+12]; |
---|
1922 | m2[j][13] = diff[jj+5] - diff[jj+13]; |
---|
1923 | m2[j][14] = diff[jj+6] - diff[jj+14]; |
---|
1924 | m2[j][15] = diff[jj+7] - diff[jj+15]; |
---|
1925 | |
---|
1926 | m1[j][0] = m2[j][0] + m2[j][4]; |
---|
1927 | m1[j][1] = m2[j][1] + m2[j][5]; |
---|
1928 | m1[j][2] = m2[j][2] + m2[j][6]; |
---|
1929 | m1[j][3] = m2[j][3] + m2[j][7]; |
---|
1930 | m1[j][4] = m2[j][0] - m2[j][4]; |
---|
1931 | m1[j][5] = m2[j][1] - m2[j][5]; |
---|
1932 | m1[j][6] = m2[j][2] - m2[j][6]; |
---|
1933 | m1[j][7] = m2[j][3] - m2[j][7]; |
---|
1934 | m1[j][8] = m2[j][8] + m2[j][12]; |
---|
1935 | m1[j][9] = m2[j][9] + m2[j][13]; |
---|
1936 | m1[j][10] = m2[j][10] + m2[j][14]; |
---|
1937 | m1[j][11] = m2[j][11] + m2[j][15]; |
---|
1938 | m1[j][12] = m2[j][8] - m2[j][12]; |
---|
1939 | m1[j][13] = m2[j][9] - m2[j][13]; |
---|
1940 | m1[j][14] = m2[j][10] - m2[j][14]; |
---|
1941 | m1[j][15] = m2[j][11] - m2[j][15]; |
---|
1942 | |
---|
1943 | m2[j][0] = m1[j][0] + m1[j][2]; |
---|
1944 | m2[j][1] = m1[j][1] + m1[j][3]; |
---|
1945 | m2[j][2] = m1[j][0] - m1[j][2]; |
---|
1946 | m2[j][3] = m1[j][1] - m1[j][3]; |
---|
1947 | m2[j][4] = m1[j][4] + m1[j][6]; |
---|
1948 | m2[j][5] = m1[j][5] + m1[j][7]; |
---|
1949 | m2[j][6] = m1[j][4] - m1[j][6]; |
---|
1950 | m2[j][7] = m1[j][5] - m1[j][7]; |
---|
1951 | m2[j][8] = m1[j][8] + m1[j][10]; |
---|
1952 | m2[j][9] = m1[j][9] + m1[j][11]; |
---|
1953 | m2[j][10] = m1[j][8] - m1[j][10]; |
---|
1954 | m2[j][11] = m1[j][9] - m1[j][11]; |
---|
1955 | m2[j][12] = m1[j][12] + m1[j][14]; |
---|
1956 | m2[j][13] = m1[j][13] + m1[j][15]; |
---|
1957 | m2[j][14] = m1[j][12] - m1[j][14]; |
---|
1958 | m2[j][15] = m1[j][13] - m1[j][15]; |
---|
1959 | |
---|
1960 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
1961 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
1962 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
1963 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
1964 | m1[j][4] = m2[j][4] + m2[j][5]; |
---|
1965 | m1[j][5] = m2[j][4] - m2[j][5]; |
---|
1966 | m1[j][6] = m2[j][6] + m2[j][7]; |
---|
1967 | m1[j][7] = m2[j][6] - m2[j][7]; |
---|
1968 | m1[j][8] = m2[j][8] + m2[j][9]; |
---|
1969 | m1[j][9] = m2[j][8] - m2[j][9]; |
---|
1970 | m1[j][10] = m2[j][10] + m2[j][11]; |
---|
1971 | m1[j][11] = m2[j][10] - m2[j][11]; |
---|
1972 | m1[j][12] = m2[j][12] + m2[j][13]; |
---|
1973 | m1[j][13] = m2[j][12] - m2[j][13]; |
---|
1974 | m1[j][14] = m2[j][14] + m2[j][15]; |
---|
1975 | m1[j][15] = m2[j][14] - m2[j][15]; |
---|
1976 | } |
---|
1977 | |
---|
1978 | //vertical |
---|
1979 | for (i=0; i < 16; i++) |
---|
1980 | { |
---|
1981 | m2[0][i] = m1[0][i] + m1[2][i]; |
---|
1982 | m2[1][i] = m1[1][i] + m1[3][i]; |
---|
1983 | m2[2][i] = m1[0][i] - m1[2][i]; |
---|
1984 | m2[3][i] = m1[1][i] - m1[3][i]; |
---|
1985 | |
---|
1986 | m1[0][i] = m2[0][i] + m2[1][i]; |
---|
1987 | m1[1][i] = m2[0][i] - m2[1][i]; |
---|
1988 | m1[2][i] = m2[2][i] + m2[3][i]; |
---|
1989 | m1[3][i] = m2[2][i] - m2[3][i]; |
---|
1990 | } |
---|
1991 | |
---|
1992 | for (i = 0; i < 4; i++) |
---|
1993 | { |
---|
1994 | for (j = 0; j < 16; j++) |
---|
1995 | { |
---|
1996 | sad += abs(m1[i][j]); |
---|
1997 | } |
---|
1998 | } |
---|
1999 | |
---|
2000 | sad=((sad+2)>>2); |
---|
2001 | |
---|
2002 | return sad; |
---|
2003 | } |
---|
2004 | |
---|
2005 | UInt TComRdCost::xCalcHADs4x16( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
2006 | { |
---|
2007 | Int k, i, j, jj, sad=0; |
---|
2008 | Int diff[64], m1[16][4], m2[16][4], m3[16][4]; |
---|
2009 | assert( iStep == 1 ); |
---|
2010 | for( k = 0; k < 64; k += 4 ) |
---|
2011 | { |
---|
2012 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
2013 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
2014 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
2015 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
2016 | |
---|
2017 | piCur += iStrideCur; |
---|
2018 | piOrg += iStrideOrg; |
---|
2019 | } |
---|
2020 | |
---|
2021 | //horizontal |
---|
2022 | for (j=0; j < 16; j++) |
---|
2023 | { |
---|
2024 | jj = j << 2; |
---|
2025 | m2[j][0] = diff[jj ] + diff[jj+2]; |
---|
2026 | m2[j][1] = diff[jj+1] + diff[jj+3]; |
---|
2027 | m2[j][2] = diff[jj ] - diff[jj+2]; |
---|
2028 | m2[j][3] = diff[jj+1] - diff[jj+3]; |
---|
2029 | |
---|
2030 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
2031 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
2032 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
2033 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
2034 | } |
---|
2035 | |
---|
2036 | //vertical |
---|
2037 | for (i=0; i < 4; i++) |
---|
2038 | { |
---|
2039 | m2[0][i] = m1[0][i] + m1[8][i]; |
---|
2040 | m2[1][i] = m1[1][i] + m1[9][i]; |
---|
2041 | m2[2][i] = m1[2][i] + m1[10][i]; |
---|
2042 | m2[3][i] = m1[3][i] + m1[11][i]; |
---|
2043 | m2[4][i] = m1[4][i] + m1[12][i]; |
---|
2044 | m2[5][i] = m1[5][i] + m1[13][i]; |
---|
2045 | m2[6][i] = m1[6][i] + m1[14][i]; |
---|
2046 | m2[7][i] = m1[7][i] + m1[15][i]; |
---|
2047 | m2[8][i] = m1[0][i] - m1[8][i]; |
---|
2048 | m2[9][i] = m1[1][i] - m1[9][i]; |
---|
2049 | m2[10][i] = m1[2][i] - m1[10][i]; |
---|
2050 | m2[11][i] = m1[3][i] - m1[11][i]; |
---|
2051 | m2[12][i] = m1[4][i] - m1[12][i]; |
---|
2052 | m2[13][i] = m1[5][i] - m1[13][i]; |
---|
2053 | m2[14][i] = m1[6][i] - m1[14][i]; |
---|
2054 | m2[15][i] = m1[7][i] - m1[15][i]; |
---|
2055 | |
---|
2056 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
2057 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
2058 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
2059 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
2060 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
2061 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
2062 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
2063 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
2064 | m3[8][i] = m2[8][i] + m2[12][i]; |
---|
2065 | m3[9][i] = m2[9][i] + m2[13][i]; |
---|
2066 | m3[10][i] = m2[10][i] + m2[14][i]; |
---|
2067 | m3[11][i] = m2[11][i] + m2[15][i]; |
---|
2068 | m3[12][i] = m2[8][i] - m2[12][i]; |
---|
2069 | m3[13][i] = m2[9][i] - m2[13][i]; |
---|
2070 | m3[14][i] = m2[10][i] - m2[14][i]; |
---|
2071 | m3[15][i] = m2[11][i] - m2[15][i]; |
---|
2072 | |
---|
2073 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
2074 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
2075 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
2076 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
2077 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
2078 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
2079 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
2080 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
2081 | m1[8][i] = m3[8][i] + m3[10][i]; |
---|
2082 | m1[9][i] = m3[9][i] + m3[11][i]; |
---|
2083 | m1[10][i] = m3[8][i] - m3[10][i]; |
---|
2084 | m1[11][i] = m3[9][i] - m3[11][i]; |
---|
2085 | m1[12][i] = m3[12][i] + m3[14][i]; |
---|
2086 | m1[13][i] = m3[13][i] + m3[15][i]; |
---|
2087 | m1[14][i] = m3[12][i] - m3[14][i]; |
---|
2088 | m1[15][i] = m3[13][i] - m3[15][i]; |
---|
2089 | |
---|
2090 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
2091 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
2092 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
2093 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
2094 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
2095 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
2096 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
2097 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
2098 | m2[8][i] = m1[8][i] + m1[9][i]; |
---|
2099 | m2[9][i] = m1[8][i] - m1[9][i]; |
---|
2100 | m2[10][i] = m1[10][i] + m1[11][i]; |
---|
2101 | m2[11][i] = m1[10][i] - m1[11][i]; |
---|
2102 | m2[12][i] = m1[12][i] + m1[13][i]; |
---|
2103 | m2[13][i] = m1[12][i] - m1[13][i]; |
---|
2104 | m2[14][i] = m1[14][i] + m1[15][i]; |
---|
2105 | m2[15][i] = m1[14][i] - m1[15][i]; |
---|
2106 | } |
---|
2107 | |
---|
2108 | for (i = 0; i < 16; i++) |
---|
2109 | { |
---|
2110 | for (j = 0; j < 4; j++) |
---|
2111 | { |
---|
2112 | sad += abs(m2[i][j]); |
---|
2113 | } |
---|
2114 | } |
---|
2115 | |
---|
2116 | sad=((sad+2)>>2); |
---|
2117 | |
---|
2118 | return sad; |
---|
2119 | } |
---|
2120 | #endif |
---|
2121 | |
---|
2122 | UInt TComRdCost::xGetHADs4( DistParam* pcDtParam ) |
---|
2123 | { |
---|
2124 | if ( pcDtParam->bApplyWeight ) |
---|
2125 | { |
---|
2126 | return xGetHADs4w( pcDtParam ); |
---|
2127 | } |
---|
2128 | Pel* piOrg = pcDtParam->pOrg; |
---|
2129 | Pel* piCur = pcDtParam->pCur; |
---|
2130 | Int iRows = pcDtParam->iRows; |
---|
2131 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2132 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2133 | Int iStep = pcDtParam->iStep; |
---|
2134 | Int y; |
---|
2135 | Int iOffsetOrg = iStrideOrg<<2; |
---|
2136 | Int iOffsetCur = iStrideCur<<2; |
---|
2137 | |
---|
2138 | UInt uiSum = 0; |
---|
2139 | |
---|
2140 | for ( y=0; y<iRows; y+= 4 ) |
---|
2141 | { |
---|
2142 | uiSum += xCalcHADs4x4( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
2143 | piOrg += iOffsetOrg; |
---|
2144 | piCur += iOffsetCur; |
---|
2145 | } |
---|
2146 | |
---|
2147 | return ( uiSum >> g_uiBitIncrement ); |
---|
2148 | } |
---|
2149 | |
---|
2150 | UInt TComRdCost::xGetHADs8( DistParam* pcDtParam ) |
---|
2151 | { |
---|
2152 | if ( pcDtParam->bApplyWeight ) |
---|
2153 | { |
---|
2154 | return xGetHADs8w( pcDtParam ); |
---|
2155 | } |
---|
2156 | Pel* piOrg = pcDtParam->pOrg; |
---|
2157 | Pel* piCur = pcDtParam->pCur; |
---|
2158 | Int iRows = pcDtParam->iRows; |
---|
2159 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2160 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2161 | Int iStep = pcDtParam->iStep; |
---|
2162 | Int y; |
---|
2163 | |
---|
2164 | UInt uiSum = 0; |
---|
2165 | |
---|
2166 | if ( iRows == 4 ) |
---|
2167 | { |
---|
2168 | uiSum += xCalcHADs4x4( piOrg+0, piCur , iStrideOrg, iStrideCur, iStep ); |
---|
2169 | uiSum += xCalcHADs4x4( piOrg+4, piCur+4*iStep, iStrideOrg, iStrideCur, iStep ); |
---|
2170 | } |
---|
2171 | else |
---|
2172 | { |
---|
2173 | Int iOffsetOrg = iStrideOrg<<3; |
---|
2174 | Int iOffsetCur = iStrideCur<<3; |
---|
2175 | for ( y=0; y<iRows; y+= 8 ) |
---|
2176 | { |
---|
2177 | uiSum += xCalcHADs8x8( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
2178 | piOrg += iOffsetOrg; |
---|
2179 | piCur += iOffsetCur; |
---|
2180 | } |
---|
2181 | } |
---|
2182 | |
---|
2183 | return ( uiSum >> g_uiBitIncrement ); |
---|
2184 | } |
---|
2185 | |
---|
2186 | UInt TComRdCost::xGetHADs( DistParam* pcDtParam ) |
---|
2187 | { |
---|
2188 | if ( pcDtParam->bApplyWeight ) |
---|
2189 | { |
---|
2190 | return xGetHADsw( pcDtParam ); |
---|
2191 | } |
---|
2192 | Pel* piOrg = pcDtParam->pOrg; |
---|
2193 | Pel* piCur = pcDtParam->pCur; |
---|
2194 | Int iRows = pcDtParam->iRows; |
---|
2195 | Int iCols = pcDtParam->iCols; |
---|
2196 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2197 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2198 | Int iStep = pcDtParam->iStep; |
---|
2199 | |
---|
2200 | Int x, y; |
---|
2201 | |
---|
2202 | UInt uiSum = 0; |
---|
2203 | |
---|
2204 | #if NS_HAD |
---|
2205 | if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) ) |
---|
2206 | #else |
---|
2207 | if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) |
---|
2208 | #endif |
---|
2209 | { |
---|
2210 | Int iOffsetOrg = iStrideOrg<<3; |
---|
2211 | Int iOffsetCur = iStrideCur<<3; |
---|
2212 | for ( y=0; y<iRows; y+= 8 ) |
---|
2213 | { |
---|
2214 | for ( x=0; x<iCols; x+= 8 ) |
---|
2215 | { |
---|
2216 | uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
2217 | } |
---|
2218 | piOrg += iOffsetOrg; |
---|
2219 | piCur += iOffsetCur; |
---|
2220 | } |
---|
2221 | } |
---|
2222 | #if NS_HAD |
---|
2223 | else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD ) |
---|
2224 | { |
---|
2225 | Int iOffsetOrg = iStrideOrg<<2; |
---|
2226 | Int iOffsetCur = iStrideCur<<2; |
---|
2227 | for ( y=0; y<iRows; y+= 4 ) |
---|
2228 | { |
---|
2229 | for ( x=0; x<iCols; x+= 16 ) |
---|
2230 | { |
---|
2231 | uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
2232 | } |
---|
2233 | piOrg += iOffsetOrg; |
---|
2234 | piCur += iOffsetCur; |
---|
2235 | } |
---|
2236 | } |
---|
2237 | else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD ) |
---|
2238 | { |
---|
2239 | Int iOffsetOrg = iStrideOrg<<4; |
---|
2240 | Int iOffsetCur = iStrideCur<<4; |
---|
2241 | for ( y=0; y<iRows; y+= 16 ) |
---|
2242 | { |
---|
2243 | for ( x=0; x<iCols; x+= 4 ) |
---|
2244 | { |
---|
2245 | uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
2246 | } |
---|
2247 | piOrg += iOffsetOrg; |
---|
2248 | piCur += iOffsetCur; |
---|
2249 | } |
---|
2250 | } |
---|
2251 | #endif |
---|
2252 | else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) |
---|
2253 | { |
---|
2254 | Int iOffsetOrg = iStrideOrg<<2; |
---|
2255 | Int iOffsetCur = iStrideCur<<2; |
---|
2256 | |
---|
2257 | for ( y=0; y<iRows; y+= 4 ) |
---|
2258 | { |
---|
2259 | for ( x=0; x<iCols; x+= 4 ) |
---|
2260 | { |
---|
2261 | uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
2262 | } |
---|
2263 | piOrg += iOffsetOrg; |
---|
2264 | piCur += iOffsetCur; |
---|
2265 | } |
---|
2266 | } |
---|
2267 | else if( ( iRows % 2 == 0) && (iCols % 2 == 0) ) |
---|
2268 | { |
---|
2269 | Int iOffsetOrg = iStrideOrg<<1; |
---|
2270 | Int iOffsetCur = iStrideCur<<1; |
---|
2271 | for ( y=0; y<iRows; y+=2 ) |
---|
2272 | { |
---|
2273 | for ( x=0; x<iCols; x+=2 ) |
---|
2274 | { |
---|
2275 | uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
2276 | } |
---|
2277 | piOrg += iOffsetOrg; |
---|
2278 | piCur += iOffsetCur; |
---|
2279 | } |
---|
2280 | } |
---|
2281 | else |
---|
2282 | { |
---|
2283 | assert(false); |
---|
2284 | } |
---|
2285 | |
---|
2286 | return ( uiSum >> g_uiBitIncrement ); |
---|
2287 | } |
---|
2288 | |
---|
2289 | //! \} |
---|