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 | #if NS_HAD |
---|
333 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME, Bool bUseNSHAD ) |
---|
334 | #else |
---|
335 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME ) |
---|
336 | #endif |
---|
337 | { |
---|
338 | #if O0194_WEIGHTED_PREDICTION_CGS |
---|
339 | // Bug fix: The correct bit depth has not been used for weighted cost calculation |
---|
340 | rcDistParam.bitDepth = g_bitDepthY; |
---|
341 | #endif |
---|
342 | // set Original & Curr Pointer / Stride |
---|
343 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
344 | rcDistParam.pCur = piRefY; |
---|
345 | |
---|
346 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
347 | rcDistParam.iStrideCur = iRefStride * iStep; |
---|
348 | |
---|
349 | // set Step for interpolated buffer |
---|
350 | rcDistParam.iStep = iStep; |
---|
351 | |
---|
352 | // set Block Width / Height |
---|
353 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
354 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
355 | #if NS_HAD |
---|
356 | rcDistParam.bUseNSHAD = bUseNSHAD; |
---|
357 | #endif |
---|
358 | |
---|
359 | // set distortion function |
---|
360 | if ( !bHADME ) |
---|
361 | { |
---|
362 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
363 | #if AMP_SAD |
---|
364 | if (rcDistParam.iCols == 12) |
---|
365 | { |
---|
366 | rcDistParam.DistFunc = m_afpDistortFunc[46 ]; |
---|
367 | } |
---|
368 | else if (rcDistParam.iCols == 24) |
---|
369 | { |
---|
370 | rcDistParam.DistFunc = m_afpDistortFunc[47 ]; |
---|
371 | } |
---|
372 | else if (rcDistParam.iCols == 48) |
---|
373 | { |
---|
374 | rcDistParam.DistFunc = m_afpDistortFunc[48 ]; |
---|
375 | } |
---|
376 | #endif |
---|
377 | } |
---|
378 | else |
---|
379 | { |
---|
380 | rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
381 | } |
---|
382 | |
---|
383 | // initialize |
---|
384 | rcDistParam.iSubShift = 0; |
---|
385 | } |
---|
386 | |
---|
387 | Void |
---|
388 | #if NS_HAD |
---|
389 | TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard, Bool bUseNSHAD ) |
---|
390 | #else |
---|
391 | TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard ) |
---|
392 | #endif |
---|
393 | { |
---|
394 | rcDP.pOrg = p1; |
---|
395 | rcDP.pCur = p2; |
---|
396 | rcDP.iStrideOrg = iStride1; |
---|
397 | rcDP.iStrideCur = iStride2; |
---|
398 | rcDP.iCols = iWidth; |
---|
399 | rcDP.iRows = iHeight; |
---|
400 | rcDP.iStep = 1; |
---|
401 | rcDP.iSubShift = 0; |
---|
402 | rcDP.bitDepth = bitDepth; |
---|
403 | rcDP.DistFunc = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ]; |
---|
404 | #if NS_HAD |
---|
405 | rcDP.bUseNSHAD = bUseNSHAD; |
---|
406 | #endif |
---|
407 | } |
---|
408 | |
---|
409 | UInt TComRdCost::calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight ) |
---|
410 | { |
---|
411 | UInt uiSum = 0; |
---|
412 | Int x, y; |
---|
413 | |
---|
414 | if ( ( (iWidth % 8) == 0 ) && ( (iHeight % 8) == 0 ) ) |
---|
415 | { |
---|
416 | for ( y=0; y<iHeight; y+= 8 ) |
---|
417 | { |
---|
418 | for ( x=0; x<iWidth; x+= 8 ) |
---|
419 | { |
---|
420 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
421 | } |
---|
422 | pi0 += iStride0*8; |
---|
423 | pi1 += iStride1*8; |
---|
424 | } |
---|
425 | } |
---|
426 | else if ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) ) |
---|
427 | { |
---|
428 | for ( y=0; y<iHeight; y+= 4 ) |
---|
429 | { |
---|
430 | for ( x=0; x<iWidth; x+= 4 ) |
---|
431 | { |
---|
432 | uiSum += xCalcHADs4x4( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
433 | } |
---|
434 | pi0 += iStride0*4; |
---|
435 | pi1 += iStride1*4; |
---|
436 | } |
---|
437 | } |
---|
438 | else |
---|
439 | { |
---|
440 | for ( y=0; y<iHeight; y+= 2 ) |
---|
441 | { |
---|
442 | for ( x=0; x<iWidth; x+= 2 ) |
---|
443 | { |
---|
444 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
445 | } |
---|
446 | pi0 += iStride0*2; |
---|
447 | pi1 += iStride1*2; |
---|
448 | } |
---|
449 | } |
---|
450 | |
---|
451 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); |
---|
452 | |
---|
453 | } |
---|
454 | |
---|
455 | #if WEIGHTED_CHROMA_DISTORTION |
---|
456 | UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText, DFunc eDFunc) |
---|
457 | #else |
---|
458 | UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc ) |
---|
459 | #endif |
---|
460 | { |
---|
461 | DistParam cDtParam; |
---|
462 | setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam ); |
---|
463 | cDtParam.pOrg = piOrg; |
---|
464 | cDtParam.pCur = piCur; |
---|
465 | cDtParam.iStrideOrg = iOrgStride; |
---|
466 | cDtParam.iStrideCur = iCurStride; |
---|
467 | cDtParam.iStep = 1; |
---|
468 | |
---|
469 | cDtParam.bApplyWeight = false; |
---|
470 | cDtParam.uiComp = 255; // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed. |
---|
471 | cDtParam.bitDepth = bitDepth; |
---|
472 | |
---|
473 | #if WEIGHTED_CHROMA_DISTORTION |
---|
474 | if (eText == TEXT_CHROMA_U) |
---|
475 | { |
---|
476 | return ((Int) (m_cbDistortionWeight * cDtParam.DistFunc( &cDtParam ))); |
---|
477 | } |
---|
478 | else if (eText == TEXT_CHROMA_V) |
---|
479 | { |
---|
480 | return ((Int) (m_crDistortionWeight * cDtParam.DistFunc( &cDtParam ))); |
---|
481 | } |
---|
482 | else |
---|
483 | { |
---|
484 | return cDtParam.DistFunc( &cDtParam ); |
---|
485 | } |
---|
486 | #else |
---|
487 | return cDtParam.DistFunc( &cDtParam ); |
---|
488 | #endif |
---|
489 | } |
---|
490 | |
---|
491 | #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT |
---|
492 | UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride, Pel* pelOrg, Int orgStride, UInt width, UInt height ) |
---|
493 | { |
---|
494 | UInt SAD = 0; |
---|
495 | Int shift = DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); |
---|
496 | for ( Int i=0; i<height; i++ ) |
---|
497 | { |
---|
498 | for( Int j=0; j<width; j++ ) |
---|
499 | { |
---|
500 | SAD += abs((pelCur[j] - pelOrg[j])) >> shift; |
---|
501 | } |
---|
502 | pelCur = pelCur + curStride; |
---|
503 | pelOrg = pelOrg + orgStride; |
---|
504 | } |
---|
505 | return SAD; |
---|
506 | } |
---|
507 | #endif |
---|
508 | |
---|
509 | // ==================================================================================================================== |
---|
510 | // Distortion functions |
---|
511 | // ==================================================================================================================== |
---|
512 | |
---|
513 | // -------------------------------------------------------------------------------------------------------------------- |
---|
514 | // SAD |
---|
515 | // -------------------------------------------------------------------------------------------------------------------- |
---|
516 | |
---|
517 | UInt TComRdCost::xGetSAD( DistParam* pcDtParam ) |
---|
518 | { |
---|
519 | if ( pcDtParam->bApplyWeight ) |
---|
520 | { |
---|
521 | return xGetSADw( pcDtParam ); |
---|
522 | } |
---|
523 | Pel* piOrg = pcDtParam->pOrg; |
---|
524 | Pel* piCur = pcDtParam->pCur; |
---|
525 | Int iRows = pcDtParam->iRows; |
---|
526 | Int iCols = pcDtParam->iCols; |
---|
527 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
528 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
529 | |
---|
530 | UInt uiSum = 0; |
---|
531 | |
---|
532 | for( ; iRows != 0; iRows-- ) |
---|
533 | { |
---|
534 | for (Int n = 0; n < iCols; n++ ) |
---|
535 | { |
---|
536 | uiSum += abs( piOrg[n] - piCur[n] ); |
---|
537 | } |
---|
538 | piOrg += iStrideOrg; |
---|
539 | piCur += iStrideCur; |
---|
540 | } |
---|
541 | |
---|
542 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
543 | } |
---|
544 | |
---|
545 | UInt TComRdCost::xGetSAD4( DistParam* pcDtParam ) |
---|
546 | { |
---|
547 | if ( pcDtParam->bApplyWeight ) |
---|
548 | { |
---|
549 | return xGetSADw( pcDtParam ); |
---|
550 | } |
---|
551 | Pel* piOrg = pcDtParam->pOrg; |
---|
552 | Pel* piCur = pcDtParam->pCur; |
---|
553 | Int iRows = pcDtParam->iRows; |
---|
554 | Int iSubShift = pcDtParam->iSubShift; |
---|
555 | Int iSubStep = ( 1 << iSubShift ); |
---|
556 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
557 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
558 | |
---|
559 | UInt uiSum = 0; |
---|
560 | |
---|
561 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
562 | { |
---|
563 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
564 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
565 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
566 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
567 | |
---|
568 | piOrg += iStrideOrg; |
---|
569 | piCur += iStrideCur; |
---|
570 | } |
---|
571 | |
---|
572 | uiSum <<= iSubShift; |
---|
573 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
574 | } |
---|
575 | |
---|
576 | UInt TComRdCost::xGetSAD8( DistParam* pcDtParam ) |
---|
577 | { |
---|
578 | if ( pcDtParam->bApplyWeight ) |
---|
579 | { |
---|
580 | return xGetSADw( pcDtParam ); |
---|
581 | } |
---|
582 | Pel* piOrg = pcDtParam->pOrg; |
---|
583 | Pel* piCur = pcDtParam->pCur; |
---|
584 | Int iRows = pcDtParam->iRows; |
---|
585 | Int iSubShift = pcDtParam->iSubShift; |
---|
586 | Int iSubStep = ( 1 << iSubShift ); |
---|
587 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
588 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
589 | |
---|
590 | UInt uiSum = 0; |
---|
591 | |
---|
592 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
593 | { |
---|
594 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
595 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
596 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
597 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
598 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
599 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
600 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
601 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
602 | |
---|
603 | piOrg += iStrideOrg; |
---|
604 | piCur += iStrideCur; |
---|
605 | } |
---|
606 | |
---|
607 | uiSum <<= iSubShift; |
---|
608 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
609 | } |
---|
610 | |
---|
611 | UInt TComRdCost::xGetSAD16( DistParam* pcDtParam ) |
---|
612 | { |
---|
613 | if ( pcDtParam->bApplyWeight ) |
---|
614 | { |
---|
615 | return xGetSADw( pcDtParam ); |
---|
616 | } |
---|
617 | Pel* piOrg = pcDtParam->pOrg; |
---|
618 | Pel* piCur = pcDtParam->pCur; |
---|
619 | Int iRows = pcDtParam->iRows; |
---|
620 | Int iSubShift = pcDtParam->iSubShift; |
---|
621 | Int iSubStep = ( 1 << iSubShift ); |
---|
622 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
623 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
624 | |
---|
625 | UInt uiSum = 0; |
---|
626 | |
---|
627 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
628 | { |
---|
629 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
630 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
631 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
632 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
633 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
634 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
635 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
636 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
637 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
638 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
639 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
640 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
641 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
642 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
643 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
644 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
645 | |
---|
646 | piOrg += iStrideOrg; |
---|
647 | piCur += iStrideCur; |
---|
648 | } |
---|
649 | |
---|
650 | uiSum <<= iSubShift; |
---|
651 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
652 | } |
---|
653 | |
---|
654 | #if AMP_SAD |
---|
655 | UInt TComRdCost::xGetSAD12( DistParam* pcDtParam ) |
---|
656 | { |
---|
657 | if ( pcDtParam->bApplyWeight ) |
---|
658 | { |
---|
659 | return xGetSADw( pcDtParam ); |
---|
660 | } |
---|
661 | Pel* piOrg = pcDtParam->pOrg; |
---|
662 | Pel* piCur = pcDtParam->pCur; |
---|
663 | Int iRows = pcDtParam->iRows; |
---|
664 | Int iSubShift = pcDtParam->iSubShift; |
---|
665 | Int iSubStep = ( 1 << iSubShift ); |
---|
666 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
667 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
668 | |
---|
669 | UInt uiSum = 0; |
---|
670 | |
---|
671 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
672 | { |
---|
673 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
674 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
675 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
676 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
677 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
678 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
679 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
680 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
681 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
682 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
683 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
684 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
685 | |
---|
686 | piOrg += iStrideOrg; |
---|
687 | piCur += iStrideCur; |
---|
688 | } |
---|
689 | |
---|
690 | uiSum <<= iSubShift; |
---|
691 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
692 | } |
---|
693 | #endif |
---|
694 | |
---|
695 | UInt TComRdCost::xGetSAD16N( DistParam* pcDtParam ) |
---|
696 | { |
---|
697 | Pel* piOrg = pcDtParam->pOrg; |
---|
698 | Pel* piCur = pcDtParam->pCur; |
---|
699 | Int iRows = pcDtParam->iRows; |
---|
700 | Int iCols = pcDtParam->iCols; |
---|
701 | Int iSubShift = pcDtParam->iSubShift; |
---|
702 | Int iSubStep = ( 1 << iSubShift ); |
---|
703 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
704 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
705 | |
---|
706 | UInt uiSum = 0; |
---|
707 | |
---|
708 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
709 | { |
---|
710 | for (Int n = 0; n < iCols; n+=16 ) |
---|
711 | { |
---|
712 | uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] ); |
---|
713 | uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] ); |
---|
714 | uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] ); |
---|
715 | uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] ); |
---|
716 | uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] ); |
---|
717 | uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] ); |
---|
718 | uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] ); |
---|
719 | uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] ); |
---|
720 | uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] ); |
---|
721 | uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] ); |
---|
722 | uiSum += abs( piOrg[n+10] - piCur[n+10] ); |
---|
723 | uiSum += abs( piOrg[n+11] - piCur[n+11] ); |
---|
724 | uiSum += abs( piOrg[n+12] - piCur[n+12] ); |
---|
725 | uiSum += abs( piOrg[n+13] - piCur[n+13] ); |
---|
726 | uiSum += abs( piOrg[n+14] - piCur[n+14] ); |
---|
727 | uiSum += abs( piOrg[n+15] - piCur[n+15] ); |
---|
728 | } |
---|
729 | piOrg += iStrideOrg; |
---|
730 | piCur += iStrideCur; |
---|
731 | } |
---|
732 | |
---|
733 | uiSum <<= iSubShift; |
---|
734 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
735 | } |
---|
736 | |
---|
737 | UInt TComRdCost::xGetSAD32( DistParam* pcDtParam ) |
---|
738 | { |
---|
739 | if ( pcDtParam->bApplyWeight ) |
---|
740 | { |
---|
741 | return xGetSADw( pcDtParam ); |
---|
742 | } |
---|
743 | Pel* piOrg = pcDtParam->pOrg; |
---|
744 | Pel* piCur = pcDtParam->pCur; |
---|
745 | Int iRows = pcDtParam->iRows; |
---|
746 | Int iSubShift = pcDtParam->iSubShift; |
---|
747 | Int iSubStep = ( 1 << iSubShift ); |
---|
748 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
749 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
750 | |
---|
751 | UInt uiSum = 0; |
---|
752 | |
---|
753 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
754 | { |
---|
755 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
756 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
757 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
758 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
759 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
760 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
761 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
762 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
763 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
764 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
765 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
766 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
767 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
768 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
769 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
770 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
771 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
772 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
773 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
774 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
775 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
776 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
777 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
778 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
779 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
780 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
781 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
782 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
783 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
784 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
785 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
786 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
787 | |
---|
788 | piOrg += iStrideOrg; |
---|
789 | piCur += iStrideCur; |
---|
790 | } |
---|
791 | |
---|
792 | uiSum <<= iSubShift; |
---|
793 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
794 | } |
---|
795 | |
---|
796 | #if AMP_SAD |
---|
797 | UInt TComRdCost::xGetSAD24( DistParam* pcDtParam ) |
---|
798 | { |
---|
799 | if ( pcDtParam->bApplyWeight ) |
---|
800 | { |
---|
801 | return xGetSADw( pcDtParam ); |
---|
802 | } |
---|
803 | Pel* piOrg = pcDtParam->pOrg; |
---|
804 | Pel* piCur = pcDtParam->pCur; |
---|
805 | Int iRows = pcDtParam->iRows; |
---|
806 | Int iSubShift = pcDtParam->iSubShift; |
---|
807 | Int iSubStep = ( 1 << iSubShift ); |
---|
808 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
809 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
810 | |
---|
811 | UInt uiSum = 0; |
---|
812 | |
---|
813 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
814 | { |
---|
815 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
816 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
817 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
818 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
819 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
820 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
821 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
822 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
823 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
824 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
825 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
826 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
827 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
828 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
829 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
830 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
831 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
832 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
833 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
834 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
835 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
836 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
837 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
838 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
839 | |
---|
840 | piOrg += iStrideOrg; |
---|
841 | piCur += iStrideCur; |
---|
842 | } |
---|
843 | |
---|
844 | uiSum <<= iSubShift; |
---|
845 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
846 | } |
---|
847 | |
---|
848 | #endif |
---|
849 | |
---|
850 | UInt TComRdCost::xGetSAD64( DistParam* pcDtParam ) |
---|
851 | { |
---|
852 | if ( pcDtParam->bApplyWeight ) |
---|
853 | { |
---|
854 | return xGetSADw( pcDtParam ); |
---|
855 | } |
---|
856 | Pel* piOrg = pcDtParam->pOrg; |
---|
857 | Pel* piCur = pcDtParam->pCur; |
---|
858 | Int iRows = pcDtParam->iRows; |
---|
859 | Int iSubShift = pcDtParam->iSubShift; |
---|
860 | Int iSubStep = ( 1 << iSubShift ); |
---|
861 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
862 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
863 | |
---|
864 | UInt uiSum = 0; |
---|
865 | |
---|
866 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
867 | { |
---|
868 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
869 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
870 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
871 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
872 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
873 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
874 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
875 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
876 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
877 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
878 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
879 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
880 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
881 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
882 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
883 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
884 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
885 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
886 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
887 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
888 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
889 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
890 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
891 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
892 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
893 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
894 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
895 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
896 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
897 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
898 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
899 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
900 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
901 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
902 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
903 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
904 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
905 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
906 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
907 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
908 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
909 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
910 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
911 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
912 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
913 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
914 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
915 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
916 | uiSum += abs( piOrg[48] - piCur[48] ); |
---|
917 | uiSum += abs( piOrg[49] - piCur[49] ); |
---|
918 | uiSum += abs( piOrg[50] - piCur[50] ); |
---|
919 | uiSum += abs( piOrg[51] - piCur[51] ); |
---|
920 | uiSum += abs( piOrg[52] - piCur[52] ); |
---|
921 | uiSum += abs( piOrg[53] - piCur[53] ); |
---|
922 | uiSum += abs( piOrg[54] - piCur[54] ); |
---|
923 | uiSum += abs( piOrg[55] - piCur[55] ); |
---|
924 | uiSum += abs( piOrg[56] - piCur[56] ); |
---|
925 | uiSum += abs( piOrg[57] - piCur[57] ); |
---|
926 | uiSum += abs( piOrg[58] - piCur[58] ); |
---|
927 | uiSum += abs( piOrg[59] - piCur[59] ); |
---|
928 | uiSum += abs( piOrg[60] - piCur[60] ); |
---|
929 | uiSum += abs( piOrg[61] - piCur[61] ); |
---|
930 | uiSum += abs( piOrg[62] - piCur[62] ); |
---|
931 | uiSum += abs( piOrg[63] - piCur[63] ); |
---|
932 | |
---|
933 | piOrg += iStrideOrg; |
---|
934 | piCur += iStrideCur; |
---|
935 | } |
---|
936 | |
---|
937 | uiSum <<= iSubShift; |
---|
938 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
939 | } |
---|
940 | |
---|
941 | #if AMP_SAD |
---|
942 | UInt TComRdCost::xGetSAD48( DistParam* pcDtParam ) |
---|
943 | { |
---|
944 | if ( pcDtParam->bApplyWeight ) |
---|
945 | { |
---|
946 | return xGetSADw( pcDtParam ); |
---|
947 | } |
---|
948 | Pel* piOrg = pcDtParam->pOrg; |
---|
949 | Pel* piCur = pcDtParam->pCur; |
---|
950 | Int iRows = pcDtParam->iRows; |
---|
951 | Int iSubShift = pcDtParam->iSubShift; |
---|
952 | Int iSubStep = ( 1 << iSubShift ); |
---|
953 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
954 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
955 | |
---|
956 | UInt uiSum = 0; |
---|
957 | |
---|
958 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
959 | { |
---|
960 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
961 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
962 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
963 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
964 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
965 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
966 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
967 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
968 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
969 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
970 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
971 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
972 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
973 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
974 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
975 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
976 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
977 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
978 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
979 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
980 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
981 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
982 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
983 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
984 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
985 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
986 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
987 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
988 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
989 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
990 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
991 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
992 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
993 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
994 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
995 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
996 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
997 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
998 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
999 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
1000 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
1001 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
1002 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
1003 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
1004 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
1005 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
1006 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
1007 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
1008 | |
---|
1009 | piOrg += iStrideOrg; |
---|
1010 | piCur += iStrideCur; |
---|
1011 | } |
---|
1012 | |
---|
1013 | uiSum <<= iSubShift; |
---|
1014 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
1015 | } |
---|
1016 | #endif |
---|
1017 | |
---|
1018 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1019 | // SSE |
---|
1020 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1021 | |
---|
1022 | UInt TComRdCost::xGetSSE( DistParam* pcDtParam ) |
---|
1023 | { |
---|
1024 | if ( pcDtParam->bApplyWeight ) |
---|
1025 | { |
---|
1026 | return xGetSSEw( pcDtParam ); |
---|
1027 | } |
---|
1028 | Pel* piOrg = pcDtParam->pOrg; |
---|
1029 | Pel* piCur = pcDtParam->pCur; |
---|
1030 | Int iRows = pcDtParam->iRows; |
---|
1031 | Int iCols = pcDtParam->iCols; |
---|
1032 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1033 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1034 | |
---|
1035 | UInt uiSum = 0; |
---|
1036 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1037 | |
---|
1038 | Int iTemp; |
---|
1039 | |
---|
1040 | for( ; iRows != 0; iRows-- ) |
---|
1041 | { |
---|
1042 | for (Int n = 0; n < iCols; n++ ) |
---|
1043 | { |
---|
1044 | iTemp = piOrg[n ] - piCur[n ]; |
---|
1045 | uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1046 | } |
---|
1047 | piOrg += iStrideOrg; |
---|
1048 | piCur += iStrideCur; |
---|
1049 | } |
---|
1050 | |
---|
1051 | return ( uiSum ); |
---|
1052 | } |
---|
1053 | |
---|
1054 | UInt TComRdCost::xGetSSE4( DistParam* pcDtParam ) |
---|
1055 | { |
---|
1056 | if ( pcDtParam->bApplyWeight ) |
---|
1057 | { |
---|
1058 | assert( pcDtParam->iCols == 4 ); |
---|
1059 | return xGetSSEw( pcDtParam ); |
---|
1060 | } |
---|
1061 | Pel* piOrg = pcDtParam->pOrg; |
---|
1062 | Pel* piCur = pcDtParam->pCur; |
---|
1063 | Int iRows = pcDtParam->iRows; |
---|
1064 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1065 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1066 | |
---|
1067 | UInt uiSum = 0; |
---|
1068 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1069 | |
---|
1070 | Int iTemp; |
---|
1071 | |
---|
1072 | for( ; iRows != 0; iRows-- ) |
---|
1073 | { |
---|
1074 | |
---|
1075 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1076 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1077 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1078 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1079 | |
---|
1080 | piOrg += iStrideOrg; |
---|
1081 | piCur += iStrideCur; |
---|
1082 | } |
---|
1083 | |
---|
1084 | return ( uiSum ); |
---|
1085 | } |
---|
1086 | |
---|
1087 | UInt TComRdCost::xGetSSE8( DistParam* pcDtParam ) |
---|
1088 | { |
---|
1089 | if ( pcDtParam->bApplyWeight ) |
---|
1090 | { |
---|
1091 | assert( pcDtParam->iCols == 8 ); |
---|
1092 | return xGetSSEw( pcDtParam ); |
---|
1093 | } |
---|
1094 | Pel* piOrg = pcDtParam->pOrg; |
---|
1095 | Pel* piCur = pcDtParam->pCur; |
---|
1096 | Int iRows = pcDtParam->iRows; |
---|
1097 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1098 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1099 | |
---|
1100 | UInt uiSum = 0; |
---|
1101 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1102 | |
---|
1103 | Int iTemp; |
---|
1104 | |
---|
1105 | for( ; iRows != 0; iRows-- ) |
---|
1106 | { |
---|
1107 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1108 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1109 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1110 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1111 | iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1112 | iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1113 | iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1114 | iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1115 | |
---|
1116 | piOrg += iStrideOrg; |
---|
1117 | piCur += iStrideCur; |
---|
1118 | } |
---|
1119 | |
---|
1120 | return ( uiSum ); |
---|
1121 | } |
---|
1122 | |
---|
1123 | UInt TComRdCost::xGetSSE16( DistParam* pcDtParam ) |
---|
1124 | { |
---|
1125 | if ( pcDtParam->bApplyWeight ) |
---|
1126 | { |
---|
1127 | assert( pcDtParam->iCols == 16 ); |
---|
1128 | return xGetSSEw( pcDtParam ); |
---|
1129 | } |
---|
1130 | Pel* piOrg = pcDtParam->pOrg; |
---|
1131 | Pel* piCur = pcDtParam->pCur; |
---|
1132 | Int iRows = pcDtParam->iRows; |
---|
1133 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1134 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1135 | |
---|
1136 | UInt uiSum = 0; |
---|
1137 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1138 | |
---|
1139 | Int iTemp; |
---|
1140 | |
---|
1141 | for( ; iRows != 0; iRows-- ) |
---|
1142 | { |
---|
1143 | |
---|
1144 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1145 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1146 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1147 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1148 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1149 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1150 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1151 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1152 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1153 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1154 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1155 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1156 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1157 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1158 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1159 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1160 | |
---|
1161 | piOrg += iStrideOrg; |
---|
1162 | piCur += iStrideCur; |
---|
1163 | } |
---|
1164 | |
---|
1165 | return ( uiSum ); |
---|
1166 | } |
---|
1167 | |
---|
1168 | UInt TComRdCost::xGetSSE16N( DistParam* pcDtParam ) |
---|
1169 | { |
---|
1170 | if ( pcDtParam->bApplyWeight ) |
---|
1171 | { |
---|
1172 | return xGetSSEw( pcDtParam ); |
---|
1173 | } |
---|
1174 | Pel* piOrg = pcDtParam->pOrg; |
---|
1175 | Pel* piCur = pcDtParam->pCur; |
---|
1176 | Int iRows = pcDtParam->iRows; |
---|
1177 | Int iCols = pcDtParam->iCols; |
---|
1178 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1179 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1180 | |
---|
1181 | UInt uiSum = 0; |
---|
1182 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1183 | Int iTemp; |
---|
1184 | |
---|
1185 | for( ; iRows != 0; iRows-- ) |
---|
1186 | { |
---|
1187 | for (Int n = 0; n < iCols; n+=16 ) |
---|
1188 | { |
---|
1189 | |
---|
1190 | iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1191 | iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1192 | iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1193 | iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1194 | iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1195 | iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1196 | iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1197 | iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1198 | iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1199 | iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1200 | iTemp = piOrg[n+10] - piCur[n+10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1201 | iTemp = piOrg[n+11] - piCur[n+11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1202 | iTemp = piOrg[n+12] - piCur[n+12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1203 | iTemp = piOrg[n+13] - piCur[n+13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1204 | iTemp = piOrg[n+14] - piCur[n+14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1205 | iTemp = piOrg[n+15] - piCur[n+15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1206 | |
---|
1207 | } |
---|
1208 | piOrg += iStrideOrg; |
---|
1209 | piCur += iStrideCur; |
---|
1210 | } |
---|
1211 | |
---|
1212 | return ( uiSum ); |
---|
1213 | } |
---|
1214 | |
---|
1215 | UInt TComRdCost::xGetSSE32( DistParam* pcDtParam ) |
---|
1216 | { |
---|
1217 | if ( pcDtParam->bApplyWeight ) |
---|
1218 | { |
---|
1219 | assert( pcDtParam->iCols == 32 ); |
---|
1220 | return xGetSSEw( pcDtParam ); |
---|
1221 | } |
---|
1222 | Pel* piOrg = pcDtParam->pOrg; |
---|
1223 | Pel* piCur = pcDtParam->pCur; |
---|
1224 | Int iRows = pcDtParam->iRows; |
---|
1225 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1226 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1227 | |
---|
1228 | UInt uiSum = 0; |
---|
1229 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1230 | Int iTemp; |
---|
1231 | |
---|
1232 | for( ; iRows != 0; iRows-- ) |
---|
1233 | { |
---|
1234 | |
---|
1235 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1236 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1237 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1238 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1239 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1240 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1241 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1242 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1243 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1244 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1245 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1246 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1247 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1248 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1249 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1250 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1251 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1252 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1253 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1254 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1255 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1256 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1257 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1258 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1259 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1260 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1261 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1262 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1263 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1264 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1265 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1266 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1267 | |
---|
1268 | piOrg += iStrideOrg; |
---|
1269 | piCur += iStrideCur; |
---|
1270 | } |
---|
1271 | |
---|
1272 | return ( uiSum ); |
---|
1273 | } |
---|
1274 | |
---|
1275 | UInt TComRdCost::xGetSSE64( DistParam* pcDtParam ) |
---|
1276 | { |
---|
1277 | if ( pcDtParam->bApplyWeight ) |
---|
1278 | { |
---|
1279 | assert( pcDtParam->iCols == 64 ); |
---|
1280 | return xGetSSEw( pcDtParam ); |
---|
1281 | } |
---|
1282 | Pel* piOrg = pcDtParam->pOrg; |
---|
1283 | Pel* piCur = pcDtParam->pCur; |
---|
1284 | Int iRows = pcDtParam->iRows; |
---|
1285 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1286 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1287 | |
---|
1288 | UInt uiSum = 0; |
---|
1289 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1290 | Int iTemp; |
---|
1291 | |
---|
1292 | for( ; iRows != 0; iRows-- ) |
---|
1293 | { |
---|
1294 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1295 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1296 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1297 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1298 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1299 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1300 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1301 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1302 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1303 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1304 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1305 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1306 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1307 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1308 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1309 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1310 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1311 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1312 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1313 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1314 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1315 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1316 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1317 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1318 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1319 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1320 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1321 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1322 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1323 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1324 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1325 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1326 | iTemp = piOrg[32] - piCur[32]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1327 | iTemp = piOrg[33] - piCur[33]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1328 | iTemp = piOrg[34] - piCur[34]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1329 | iTemp = piOrg[35] - piCur[35]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1330 | iTemp = piOrg[36] - piCur[36]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1331 | iTemp = piOrg[37] - piCur[37]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1332 | iTemp = piOrg[38] - piCur[38]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1333 | iTemp = piOrg[39] - piCur[39]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1334 | iTemp = piOrg[40] - piCur[40]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1335 | iTemp = piOrg[41] - piCur[41]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1336 | iTemp = piOrg[42] - piCur[42]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1337 | iTemp = piOrg[43] - piCur[43]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1338 | iTemp = piOrg[44] - piCur[44]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1339 | iTemp = piOrg[45] - piCur[45]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1340 | iTemp = piOrg[46] - piCur[46]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1341 | iTemp = piOrg[47] - piCur[47]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1342 | iTemp = piOrg[48] - piCur[48]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1343 | iTemp = piOrg[49] - piCur[49]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1344 | iTemp = piOrg[50] - piCur[50]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1345 | iTemp = piOrg[51] - piCur[51]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1346 | iTemp = piOrg[52] - piCur[52]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1347 | iTemp = piOrg[53] - piCur[53]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1348 | iTemp = piOrg[54] - piCur[54]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1349 | iTemp = piOrg[55] - piCur[55]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1350 | iTemp = piOrg[56] - piCur[56]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1351 | iTemp = piOrg[57] - piCur[57]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1352 | iTemp = piOrg[58] - piCur[58]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1353 | iTemp = piOrg[59] - piCur[59]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1354 | iTemp = piOrg[60] - piCur[60]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1355 | iTemp = piOrg[61] - piCur[61]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1356 | iTemp = piOrg[62] - piCur[62]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1357 | iTemp = piOrg[63] - piCur[63]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1358 | |
---|
1359 | piOrg += iStrideOrg; |
---|
1360 | piCur += iStrideCur; |
---|
1361 | } |
---|
1362 | |
---|
1363 | return ( uiSum ); |
---|
1364 | } |
---|
1365 | |
---|
1366 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1367 | // HADAMARD with step (used in fractional search) |
---|
1368 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1369 | |
---|
1370 | UInt TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1371 | { |
---|
1372 | Int satd = 0, diff[4], m[4]; |
---|
1373 | assert( iStep == 1 ); |
---|
1374 | diff[0] = piOrg[0 ] - piCur[0]; |
---|
1375 | diff[1] = piOrg[1 ] - piCur[1]; |
---|
1376 | diff[2] = piOrg[iStrideOrg ] - piCur[0 + iStrideCur]; |
---|
1377 | diff[3] = piOrg[iStrideOrg + 1] - piCur[1 + iStrideCur]; |
---|
1378 | m[0] = diff[0] + diff[2]; |
---|
1379 | m[1] = diff[1] + diff[3]; |
---|
1380 | m[2] = diff[0] - diff[2]; |
---|
1381 | m[3] = diff[1] - diff[3]; |
---|
1382 | |
---|
1383 | satd += abs(m[0] + m[1]); |
---|
1384 | satd += abs(m[0] - m[1]); |
---|
1385 | satd += abs(m[2] + m[3]); |
---|
1386 | satd += abs(m[2] - m[3]); |
---|
1387 | |
---|
1388 | return satd; |
---|
1389 | } |
---|
1390 | |
---|
1391 | UInt TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1392 | { |
---|
1393 | Int k, satd = 0, diff[16], m[16], d[16]; |
---|
1394 | |
---|
1395 | assert( iStep == 1 ); |
---|
1396 | for( k = 0; k < 16; k+=4 ) |
---|
1397 | { |
---|
1398 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1399 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1400 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1401 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1402 | |
---|
1403 | piCur += iStrideCur; |
---|
1404 | piOrg += iStrideOrg; |
---|
1405 | } |
---|
1406 | |
---|
1407 | /*===== hadamard transform =====*/ |
---|
1408 | m[ 0] = diff[ 0] + diff[12]; |
---|
1409 | m[ 1] = diff[ 1] + diff[13]; |
---|
1410 | m[ 2] = diff[ 2] + diff[14]; |
---|
1411 | m[ 3] = diff[ 3] + diff[15]; |
---|
1412 | m[ 4] = diff[ 4] + diff[ 8]; |
---|
1413 | m[ 5] = diff[ 5] + diff[ 9]; |
---|
1414 | m[ 6] = diff[ 6] + diff[10]; |
---|
1415 | m[ 7] = diff[ 7] + diff[11]; |
---|
1416 | m[ 8] = diff[ 4] - diff[ 8]; |
---|
1417 | m[ 9] = diff[ 5] - diff[ 9]; |
---|
1418 | m[10] = diff[ 6] - diff[10]; |
---|
1419 | m[11] = diff[ 7] - diff[11]; |
---|
1420 | m[12] = diff[ 0] - diff[12]; |
---|
1421 | m[13] = diff[ 1] - diff[13]; |
---|
1422 | m[14] = diff[ 2] - diff[14]; |
---|
1423 | m[15] = diff[ 3] - diff[15]; |
---|
1424 | |
---|
1425 | d[ 0] = m[ 0] + m[ 4]; |
---|
1426 | d[ 1] = m[ 1] + m[ 5]; |
---|
1427 | d[ 2] = m[ 2] + m[ 6]; |
---|
1428 | d[ 3] = m[ 3] + m[ 7]; |
---|
1429 | d[ 4] = m[ 8] + m[12]; |
---|
1430 | d[ 5] = m[ 9] + m[13]; |
---|
1431 | d[ 6] = m[10] + m[14]; |
---|
1432 | d[ 7] = m[11] + m[15]; |
---|
1433 | d[ 8] = m[ 0] - m[ 4]; |
---|
1434 | d[ 9] = m[ 1] - m[ 5]; |
---|
1435 | d[10] = m[ 2] - m[ 6]; |
---|
1436 | d[11] = m[ 3] - m[ 7]; |
---|
1437 | d[12] = m[12] - m[ 8]; |
---|
1438 | d[13] = m[13] - m[ 9]; |
---|
1439 | d[14] = m[14] - m[10]; |
---|
1440 | d[15] = m[15] - m[11]; |
---|
1441 | |
---|
1442 | m[ 0] = d[ 0] + d[ 3]; |
---|
1443 | m[ 1] = d[ 1] + d[ 2]; |
---|
1444 | m[ 2] = d[ 1] - d[ 2]; |
---|
1445 | m[ 3] = d[ 0] - d[ 3]; |
---|
1446 | m[ 4] = d[ 4] + d[ 7]; |
---|
1447 | m[ 5] = d[ 5] + d[ 6]; |
---|
1448 | m[ 6] = d[ 5] - d[ 6]; |
---|
1449 | m[ 7] = d[ 4] - d[ 7]; |
---|
1450 | m[ 8] = d[ 8] + d[11]; |
---|
1451 | m[ 9] = d[ 9] + d[10]; |
---|
1452 | m[10] = d[ 9] - d[10]; |
---|
1453 | m[11] = d[ 8] - d[11]; |
---|
1454 | m[12] = d[12] + d[15]; |
---|
1455 | m[13] = d[13] + d[14]; |
---|
1456 | m[14] = d[13] - d[14]; |
---|
1457 | m[15] = d[12] - d[15]; |
---|
1458 | |
---|
1459 | d[ 0] = m[ 0] + m[ 1]; |
---|
1460 | d[ 1] = m[ 0] - m[ 1]; |
---|
1461 | d[ 2] = m[ 2] + m[ 3]; |
---|
1462 | d[ 3] = m[ 3] - m[ 2]; |
---|
1463 | d[ 4] = m[ 4] + m[ 5]; |
---|
1464 | d[ 5] = m[ 4] - m[ 5]; |
---|
1465 | d[ 6] = m[ 6] + m[ 7]; |
---|
1466 | d[ 7] = m[ 7] - m[ 6]; |
---|
1467 | d[ 8] = m[ 8] + m[ 9]; |
---|
1468 | d[ 9] = m[ 8] - m[ 9]; |
---|
1469 | d[10] = m[10] + m[11]; |
---|
1470 | d[11] = m[11] - m[10]; |
---|
1471 | d[12] = m[12] + m[13]; |
---|
1472 | d[13] = m[12] - m[13]; |
---|
1473 | d[14] = m[14] + m[15]; |
---|
1474 | d[15] = m[15] - m[14]; |
---|
1475 | |
---|
1476 | for (k=0; k<16; ++k) |
---|
1477 | { |
---|
1478 | satd += abs(d[k]); |
---|
1479 | } |
---|
1480 | satd = ((satd+1)>>1); |
---|
1481 | |
---|
1482 | return satd; |
---|
1483 | } |
---|
1484 | |
---|
1485 | UInt TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1486 | { |
---|
1487 | Int k, i, j, jj, sad=0; |
---|
1488 | Int diff[64], m1[8][8], m2[8][8], m3[8][8]; |
---|
1489 | assert( iStep == 1 ); |
---|
1490 | for( k = 0; k < 64; k += 8 ) |
---|
1491 | { |
---|
1492 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1493 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1494 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1495 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1496 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
1497 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
1498 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
1499 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
1500 | |
---|
1501 | piCur += iStrideCur; |
---|
1502 | piOrg += iStrideOrg; |
---|
1503 | } |
---|
1504 | |
---|
1505 | //horizontal |
---|
1506 | for (j=0; j < 8; j++) |
---|
1507 | { |
---|
1508 | jj = j << 3; |
---|
1509 | m2[j][0] = diff[jj ] + diff[jj+4]; |
---|
1510 | m2[j][1] = diff[jj+1] + diff[jj+5]; |
---|
1511 | m2[j][2] = diff[jj+2] + diff[jj+6]; |
---|
1512 | m2[j][3] = diff[jj+3] + diff[jj+7]; |
---|
1513 | m2[j][4] = diff[jj ] - diff[jj+4]; |
---|
1514 | m2[j][5] = diff[jj+1] - diff[jj+5]; |
---|
1515 | m2[j][6] = diff[jj+2] - diff[jj+6]; |
---|
1516 | m2[j][7] = diff[jj+3] - diff[jj+7]; |
---|
1517 | |
---|
1518 | m1[j][0] = m2[j][0] + m2[j][2]; |
---|
1519 | m1[j][1] = m2[j][1] + m2[j][3]; |
---|
1520 | m1[j][2] = m2[j][0] - m2[j][2]; |
---|
1521 | m1[j][3] = m2[j][1] - m2[j][3]; |
---|
1522 | m1[j][4] = m2[j][4] + m2[j][6]; |
---|
1523 | m1[j][5] = m2[j][5] + m2[j][7]; |
---|
1524 | m1[j][6] = m2[j][4] - m2[j][6]; |
---|
1525 | m1[j][7] = m2[j][5] - m2[j][7]; |
---|
1526 | |
---|
1527 | m2[j][0] = m1[j][0] + m1[j][1]; |
---|
1528 | m2[j][1] = m1[j][0] - m1[j][1]; |
---|
1529 | m2[j][2] = m1[j][2] + m1[j][3]; |
---|
1530 | m2[j][3] = m1[j][2] - m1[j][3]; |
---|
1531 | m2[j][4] = m1[j][4] + m1[j][5]; |
---|
1532 | m2[j][5] = m1[j][4] - m1[j][5]; |
---|
1533 | m2[j][6] = m1[j][6] + m1[j][7]; |
---|
1534 | m2[j][7] = m1[j][6] - m1[j][7]; |
---|
1535 | } |
---|
1536 | |
---|
1537 | //vertical |
---|
1538 | for (i=0; i < 8; i++) |
---|
1539 | { |
---|
1540 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
1541 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
1542 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
1543 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
1544 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
1545 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
1546 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
1547 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
1548 | |
---|
1549 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
1550 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
1551 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
1552 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
1553 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
1554 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
1555 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
1556 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
1557 | |
---|
1558 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
1559 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
1560 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
1561 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
1562 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
1563 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
1564 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
1565 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
1566 | } |
---|
1567 | |
---|
1568 | for (i = 0; i < 8; i++) |
---|
1569 | { |
---|
1570 | for (j = 0; j < 8; j++) |
---|
1571 | { |
---|
1572 | sad += abs(m2[i][j]); |
---|
1573 | } |
---|
1574 | } |
---|
1575 | |
---|
1576 | sad=((sad+2)>>2); |
---|
1577 | |
---|
1578 | return sad; |
---|
1579 | } |
---|
1580 | |
---|
1581 | #if NS_HAD |
---|
1582 | UInt TComRdCost::xCalcHADs16x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1583 | { |
---|
1584 | Int k, i, j, jj, sad=0; |
---|
1585 | Int diff[64], m1[4][16], m2[4][16]; |
---|
1586 | assert( iStep == 1 ); |
---|
1587 | for( k = 0; k < 64; k += 16 ) |
---|
1588 | { |
---|
1589 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1590 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1591 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1592 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1593 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
1594 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
1595 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
1596 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
1597 | |
---|
1598 | diff[k+8] = piOrg[8] - piCur[8] ; |
---|
1599 | diff[k+9] = piOrg[9] - piCur[9] ; |
---|
1600 | diff[k+10] = piOrg[10] - piCur[10]; |
---|
1601 | diff[k+11] = piOrg[11] - piCur[11]; |
---|
1602 | diff[k+12] = piOrg[12] - piCur[12]; |
---|
1603 | diff[k+13] = piOrg[13] - piCur[13]; |
---|
1604 | diff[k+14] = piOrg[14] - piCur[14]; |
---|
1605 | diff[k+15] = piOrg[15] - piCur[15]; |
---|
1606 | |
---|
1607 | piCur += iStrideCur; |
---|
1608 | piOrg += iStrideOrg; |
---|
1609 | } |
---|
1610 | |
---|
1611 | //horizontal |
---|
1612 | for (j=0; j < 4; j++) |
---|
1613 | { |
---|
1614 | jj = j << 4; |
---|
1615 | |
---|
1616 | m2[j][0] = diff[jj ] + diff[jj+8]; |
---|
1617 | m2[j][1] = diff[jj+1] + diff[jj+9]; |
---|
1618 | m2[j][2] = diff[jj+2] + diff[jj+10]; |
---|
1619 | m2[j][3] = diff[jj+3] + diff[jj+11]; |
---|
1620 | m2[j][4] = diff[jj+4] + diff[jj+12]; |
---|
1621 | m2[j][5] = diff[jj+5] + diff[jj+13]; |
---|
1622 | m2[j][6] = diff[jj+6] + diff[jj+14]; |
---|
1623 | m2[j][7] = diff[jj+7] + diff[jj+15]; |
---|
1624 | m2[j][8] = diff[jj ] - diff[jj+8]; |
---|
1625 | m2[j][9] = diff[jj+1] - diff[jj+9]; |
---|
1626 | m2[j][10] = diff[jj+2] - diff[jj+10]; |
---|
1627 | m2[j][11] = diff[jj+3] - diff[jj+11]; |
---|
1628 | m2[j][12] = diff[jj+4] - diff[jj+12]; |
---|
1629 | m2[j][13] = diff[jj+5] - diff[jj+13]; |
---|
1630 | m2[j][14] = diff[jj+6] - diff[jj+14]; |
---|
1631 | m2[j][15] = diff[jj+7] - diff[jj+15]; |
---|
1632 | |
---|
1633 | m1[j][0] = m2[j][0] + m2[j][4]; |
---|
1634 | m1[j][1] = m2[j][1] + m2[j][5]; |
---|
1635 | m1[j][2] = m2[j][2] + m2[j][6]; |
---|
1636 | m1[j][3] = m2[j][3] + m2[j][7]; |
---|
1637 | m1[j][4] = m2[j][0] - m2[j][4]; |
---|
1638 | m1[j][5] = m2[j][1] - m2[j][5]; |
---|
1639 | m1[j][6] = m2[j][2] - m2[j][6]; |
---|
1640 | m1[j][7] = m2[j][3] - m2[j][7]; |
---|
1641 | m1[j][8] = m2[j][8] + m2[j][12]; |
---|
1642 | m1[j][9] = m2[j][9] + m2[j][13]; |
---|
1643 | m1[j][10] = m2[j][10] + m2[j][14]; |
---|
1644 | m1[j][11] = m2[j][11] + m2[j][15]; |
---|
1645 | m1[j][12] = m2[j][8] - m2[j][12]; |
---|
1646 | m1[j][13] = m2[j][9] - m2[j][13]; |
---|
1647 | m1[j][14] = m2[j][10] - m2[j][14]; |
---|
1648 | m1[j][15] = m2[j][11] - m2[j][15]; |
---|
1649 | |
---|
1650 | m2[j][0] = m1[j][0] + m1[j][2]; |
---|
1651 | m2[j][1] = m1[j][1] + m1[j][3]; |
---|
1652 | m2[j][2] = m1[j][0] - m1[j][2]; |
---|
1653 | m2[j][3] = m1[j][1] - m1[j][3]; |
---|
1654 | m2[j][4] = m1[j][4] + m1[j][6]; |
---|
1655 | m2[j][5] = m1[j][5] + m1[j][7]; |
---|
1656 | m2[j][6] = m1[j][4] - m1[j][6]; |
---|
1657 | m2[j][7] = m1[j][5] - m1[j][7]; |
---|
1658 | m2[j][8] = m1[j][8] + m1[j][10]; |
---|
1659 | m2[j][9] = m1[j][9] + m1[j][11]; |
---|
1660 | m2[j][10] = m1[j][8] - m1[j][10]; |
---|
1661 | m2[j][11] = m1[j][9] - m1[j][11]; |
---|
1662 | m2[j][12] = m1[j][12] + m1[j][14]; |
---|
1663 | m2[j][13] = m1[j][13] + m1[j][15]; |
---|
1664 | m2[j][14] = m1[j][12] - m1[j][14]; |
---|
1665 | m2[j][15] = m1[j][13] - m1[j][15]; |
---|
1666 | |
---|
1667 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
1668 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
1669 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
1670 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
1671 | m1[j][4] = m2[j][4] + m2[j][5]; |
---|
1672 | m1[j][5] = m2[j][4] - m2[j][5]; |
---|
1673 | m1[j][6] = m2[j][6] + m2[j][7]; |
---|
1674 | m1[j][7] = m2[j][6] - m2[j][7]; |
---|
1675 | m1[j][8] = m2[j][8] + m2[j][9]; |
---|
1676 | m1[j][9] = m2[j][8] - m2[j][9]; |
---|
1677 | m1[j][10] = m2[j][10] + m2[j][11]; |
---|
1678 | m1[j][11] = m2[j][10] - m2[j][11]; |
---|
1679 | m1[j][12] = m2[j][12] + m2[j][13]; |
---|
1680 | m1[j][13] = m2[j][12] - m2[j][13]; |
---|
1681 | m1[j][14] = m2[j][14] + m2[j][15]; |
---|
1682 | m1[j][15] = m2[j][14] - m2[j][15]; |
---|
1683 | } |
---|
1684 | |
---|
1685 | //vertical |
---|
1686 | for (i=0; i < 16; i++) |
---|
1687 | { |
---|
1688 | m2[0][i] = m1[0][i] + m1[2][i]; |
---|
1689 | m2[1][i] = m1[1][i] + m1[3][i]; |
---|
1690 | m2[2][i] = m1[0][i] - m1[2][i]; |
---|
1691 | m2[3][i] = m1[1][i] - m1[3][i]; |
---|
1692 | |
---|
1693 | m1[0][i] = m2[0][i] + m2[1][i]; |
---|
1694 | m1[1][i] = m2[0][i] - m2[1][i]; |
---|
1695 | m1[2][i] = m2[2][i] + m2[3][i]; |
---|
1696 | m1[3][i] = m2[2][i] - m2[3][i]; |
---|
1697 | } |
---|
1698 | |
---|
1699 | for (i = 0; i < 4; i++) |
---|
1700 | { |
---|
1701 | for (j = 0; j < 16; j++) |
---|
1702 | { |
---|
1703 | sad += abs(m1[i][j]); |
---|
1704 | } |
---|
1705 | } |
---|
1706 | |
---|
1707 | sad=((sad+2)>>2); |
---|
1708 | |
---|
1709 | return sad; |
---|
1710 | } |
---|
1711 | |
---|
1712 | UInt TComRdCost::xCalcHADs4x16( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1713 | { |
---|
1714 | Int k, i, j, jj, sad=0; |
---|
1715 | Int diff[64], m1[16][4], m2[16][4], m3[16][4]; |
---|
1716 | assert( iStep == 1 ); |
---|
1717 | for( k = 0; k < 64; k += 4 ) |
---|
1718 | { |
---|
1719 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1720 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1721 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1722 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1723 | |
---|
1724 | piCur += iStrideCur; |
---|
1725 | piOrg += iStrideOrg; |
---|
1726 | } |
---|
1727 | |
---|
1728 | //horizontal |
---|
1729 | for (j=0; j < 16; j++) |
---|
1730 | { |
---|
1731 | jj = j << 2; |
---|
1732 | m2[j][0] = diff[jj ] + diff[jj+2]; |
---|
1733 | m2[j][1] = diff[jj+1] + diff[jj+3]; |
---|
1734 | m2[j][2] = diff[jj ] - diff[jj+2]; |
---|
1735 | m2[j][3] = diff[jj+1] - diff[jj+3]; |
---|
1736 | |
---|
1737 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
1738 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
1739 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
1740 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
1741 | } |
---|
1742 | |
---|
1743 | //vertical |
---|
1744 | for (i=0; i < 4; i++) |
---|
1745 | { |
---|
1746 | m2[0][i] = m1[0][i] + m1[8][i]; |
---|
1747 | m2[1][i] = m1[1][i] + m1[9][i]; |
---|
1748 | m2[2][i] = m1[2][i] + m1[10][i]; |
---|
1749 | m2[3][i] = m1[3][i] + m1[11][i]; |
---|
1750 | m2[4][i] = m1[4][i] + m1[12][i]; |
---|
1751 | m2[5][i] = m1[5][i] + m1[13][i]; |
---|
1752 | m2[6][i] = m1[6][i] + m1[14][i]; |
---|
1753 | m2[7][i] = m1[7][i] + m1[15][i]; |
---|
1754 | m2[8][i] = m1[0][i] - m1[8][i]; |
---|
1755 | m2[9][i] = m1[1][i] - m1[9][i]; |
---|
1756 | m2[10][i] = m1[2][i] - m1[10][i]; |
---|
1757 | m2[11][i] = m1[3][i] - m1[11][i]; |
---|
1758 | m2[12][i] = m1[4][i] - m1[12][i]; |
---|
1759 | m2[13][i] = m1[5][i] - m1[13][i]; |
---|
1760 | m2[14][i] = m1[6][i] - m1[14][i]; |
---|
1761 | m2[15][i] = m1[7][i] - m1[15][i]; |
---|
1762 | |
---|
1763 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
1764 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
1765 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
1766 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
1767 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
1768 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
1769 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
1770 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
1771 | m3[8][i] = m2[8][i] + m2[12][i]; |
---|
1772 | m3[9][i] = m2[9][i] + m2[13][i]; |
---|
1773 | m3[10][i] = m2[10][i] + m2[14][i]; |
---|
1774 | m3[11][i] = m2[11][i] + m2[15][i]; |
---|
1775 | m3[12][i] = m2[8][i] - m2[12][i]; |
---|
1776 | m3[13][i] = m2[9][i] - m2[13][i]; |
---|
1777 | m3[14][i] = m2[10][i] - m2[14][i]; |
---|
1778 | m3[15][i] = m2[11][i] - m2[15][i]; |
---|
1779 | |
---|
1780 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
1781 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
1782 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
1783 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
1784 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
1785 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
1786 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
1787 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
1788 | m1[8][i] = m3[8][i] + m3[10][i]; |
---|
1789 | m1[9][i] = m3[9][i] + m3[11][i]; |
---|
1790 | m1[10][i] = m3[8][i] - m3[10][i]; |
---|
1791 | m1[11][i] = m3[9][i] - m3[11][i]; |
---|
1792 | m1[12][i] = m3[12][i] + m3[14][i]; |
---|
1793 | m1[13][i] = m3[13][i] + m3[15][i]; |
---|
1794 | m1[14][i] = m3[12][i] - m3[14][i]; |
---|
1795 | m1[15][i] = m3[13][i] - m3[15][i]; |
---|
1796 | |
---|
1797 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
1798 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
1799 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
1800 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
1801 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
1802 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
1803 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
1804 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
1805 | m2[8][i] = m1[8][i] + m1[9][i]; |
---|
1806 | m2[9][i] = m1[8][i] - m1[9][i]; |
---|
1807 | m2[10][i] = m1[10][i] + m1[11][i]; |
---|
1808 | m2[11][i] = m1[10][i] - m1[11][i]; |
---|
1809 | m2[12][i] = m1[12][i] + m1[13][i]; |
---|
1810 | m2[13][i] = m1[12][i] - m1[13][i]; |
---|
1811 | m2[14][i] = m1[14][i] + m1[15][i]; |
---|
1812 | m2[15][i] = m1[14][i] - m1[15][i]; |
---|
1813 | } |
---|
1814 | |
---|
1815 | for (i = 0; i < 16; i++) |
---|
1816 | { |
---|
1817 | for (j = 0; j < 4; j++) |
---|
1818 | { |
---|
1819 | sad += abs(m2[i][j]); |
---|
1820 | } |
---|
1821 | } |
---|
1822 | |
---|
1823 | sad=((sad+2)>>2); |
---|
1824 | |
---|
1825 | return sad; |
---|
1826 | } |
---|
1827 | #endif |
---|
1828 | |
---|
1829 | UInt TComRdCost::xGetHADs4( DistParam* pcDtParam ) |
---|
1830 | { |
---|
1831 | if ( pcDtParam->bApplyWeight ) |
---|
1832 | { |
---|
1833 | return xGetHADs4w( pcDtParam ); |
---|
1834 | } |
---|
1835 | Pel* piOrg = pcDtParam->pOrg; |
---|
1836 | Pel* piCur = pcDtParam->pCur; |
---|
1837 | Int iRows = pcDtParam->iRows; |
---|
1838 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1839 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1840 | Int iStep = pcDtParam->iStep; |
---|
1841 | Int y; |
---|
1842 | Int iOffsetOrg = iStrideOrg<<2; |
---|
1843 | Int iOffsetCur = iStrideCur<<2; |
---|
1844 | |
---|
1845 | UInt uiSum = 0; |
---|
1846 | |
---|
1847 | for ( y=0; y<iRows; y+= 4 ) |
---|
1848 | { |
---|
1849 | uiSum += xCalcHADs4x4( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
1850 | piOrg += iOffsetOrg; |
---|
1851 | piCur += iOffsetCur; |
---|
1852 | } |
---|
1853 | |
---|
1854 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
1855 | } |
---|
1856 | |
---|
1857 | UInt TComRdCost::xGetHADs8( DistParam* pcDtParam ) |
---|
1858 | { |
---|
1859 | if ( pcDtParam->bApplyWeight ) |
---|
1860 | { |
---|
1861 | return xGetHADs8w( pcDtParam ); |
---|
1862 | } |
---|
1863 | Pel* piOrg = pcDtParam->pOrg; |
---|
1864 | Pel* piCur = pcDtParam->pCur; |
---|
1865 | Int iRows = pcDtParam->iRows; |
---|
1866 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1867 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1868 | Int iStep = pcDtParam->iStep; |
---|
1869 | Int y; |
---|
1870 | |
---|
1871 | UInt uiSum = 0; |
---|
1872 | |
---|
1873 | if ( iRows == 4 ) |
---|
1874 | { |
---|
1875 | uiSum += xCalcHADs4x4( piOrg+0, piCur , iStrideOrg, iStrideCur, iStep ); |
---|
1876 | uiSum += xCalcHADs4x4( piOrg+4, piCur+4*iStep, iStrideOrg, iStrideCur, iStep ); |
---|
1877 | } |
---|
1878 | else |
---|
1879 | { |
---|
1880 | Int iOffsetOrg = iStrideOrg<<3; |
---|
1881 | Int iOffsetCur = iStrideCur<<3; |
---|
1882 | for ( y=0; y<iRows; y+= 8 ) |
---|
1883 | { |
---|
1884 | uiSum += xCalcHADs8x8( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
1885 | piOrg += iOffsetOrg; |
---|
1886 | piCur += iOffsetCur; |
---|
1887 | } |
---|
1888 | } |
---|
1889 | |
---|
1890 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
1891 | } |
---|
1892 | |
---|
1893 | UInt TComRdCost::xGetHADs( DistParam* pcDtParam ) |
---|
1894 | { |
---|
1895 | if ( pcDtParam->bApplyWeight ) |
---|
1896 | { |
---|
1897 | return xGetHADsw( pcDtParam ); |
---|
1898 | } |
---|
1899 | Pel* piOrg = pcDtParam->pOrg; |
---|
1900 | Pel* piCur = pcDtParam->pCur; |
---|
1901 | Int iRows = pcDtParam->iRows; |
---|
1902 | Int iCols = pcDtParam->iCols; |
---|
1903 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1904 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1905 | Int iStep = pcDtParam->iStep; |
---|
1906 | |
---|
1907 | Int x, y; |
---|
1908 | |
---|
1909 | UInt uiSum = 0; |
---|
1910 | |
---|
1911 | #if NS_HAD |
---|
1912 | if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) ) |
---|
1913 | #else |
---|
1914 | if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) |
---|
1915 | #endif |
---|
1916 | { |
---|
1917 | Int iOffsetOrg = iStrideOrg<<3; |
---|
1918 | Int iOffsetCur = iStrideCur<<3; |
---|
1919 | for ( y=0; y<iRows; y+= 8 ) |
---|
1920 | { |
---|
1921 | for ( x=0; x<iCols; x+= 8 ) |
---|
1922 | { |
---|
1923 | uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
1924 | } |
---|
1925 | piOrg += iOffsetOrg; |
---|
1926 | piCur += iOffsetCur; |
---|
1927 | } |
---|
1928 | } |
---|
1929 | #if NS_HAD |
---|
1930 | else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD ) |
---|
1931 | { |
---|
1932 | Int iOffsetOrg = iStrideOrg<<2; |
---|
1933 | Int iOffsetCur = iStrideCur<<2; |
---|
1934 | for ( y=0; y<iRows; y+= 4 ) |
---|
1935 | { |
---|
1936 | for ( x=0; x<iCols; x+= 16 ) |
---|
1937 | { |
---|
1938 | uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
1939 | } |
---|
1940 | piOrg += iOffsetOrg; |
---|
1941 | piCur += iOffsetCur; |
---|
1942 | } |
---|
1943 | } |
---|
1944 | else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD ) |
---|
1945 | { |
---|
1946 | Int iOffsetOrg = iStrideOrg<<4; |
---|
1947 | Int iOffsetCur = iStrideCur<<4; |
---|
1948 | for ( y=0; y<iRows; y+= 16 ) |
---|
1949 | { |
---|
1950 | for ( x=0; x<iCols; x+= 4 ) |
---|
1951 | { |
---|
1952 | uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
1953 | } |
---|
1954 | piOrg += iOffsetOrg; |
---|
1955 | piCur += iOffsetCur; |
---|
1956 | } |
---|
1957 | } |
---|
1958 | #endif |
---|
1959 | else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) |
---|
1960 | { |
---|
1961 | Int iOffsetOrg = iStrideOrg<<2; |
---|
1962 | Int iOffsetCur = iStrideCur<<2; |
---|
1963 | |
---|
1964 | for ( y=0; y<iRows; y+= 4 ) |
---|
1965 | { |
---|
1966 | for ( x=0; x<iCols; x+= 4 ) |
---|
1967 | { |
---|
1968 | uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
1969 | } |
---|
1970 | piOrg += iOffsetOrg; |
---|
1971 | piCur += iOffsetCur; |
---|
1972 | } |
---|
1973 | } |
---|
1974 | else if( ( iRows % 2 == 0) && (iCols % 2 == 0) ) |
---|
1975 | { |
---|
1976 | Int iOffsetOrg = iStrideOrg<<1; |
---|
1977 | Int iOffsetCur = iStrideCur<<1; |
---|
1978 | for ( y=0; y<iRows; y+=2 ) |
---|
1979 | { |
---|
1980 | for ( x=0; x<iCols; x+=2 ) |
---|
1981 | { |
---|
1982 | uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
1983 | } |
---|
1984 | piOrg += iOffsetOrg; |
---|
1985 | piCur += iOffsetCur; |
---|
1986 | } |
---|
1987 | } |
---|
1988 | else |
---|
1989 | { |
---|
1990 | assert(false); |
---|
1991 | } |
---|
1992 | |
---|
1993 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
1994 | } |
---|
1995 | |
---|
1996 | //! \} |
---|