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