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