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 | #if H_3D |
---|
43 | #include "TComDataCU.h" |
---|
44 | #endif |
---|
45 | |
---|
46 | //! \ingroup TLibCommon |
---|
47 | //! \{ |
---|
48 | |
---|
49 | #if H_3D_VSO |
---|
50 | // SAIT_VSO_EST_A0033 |
---|
51 | Double TComRdCost::m_dDisparityCoeff = 1.0; |
---|
52 | #endif |
---|
53 | |
---|
54 | TComRdCost::TComRdCost() |
---|
55 | { |
---|
56 | init(); |
---|
57 | } |
---|
58 | |
---|
59 | TComRdCost::~TComRdCost() |
---|
60 | { |
---|
61 | #if !FIX203 |
---|
62 | xUninit(); |
---|
63 | #endif |
---|
64 | } |
---|
65 | |
---|
66 | // Calculate RD functions |
---|
67 | #if H_3D_VSO |
---|
68 | Double TComRdCost::calcRdCost( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
69 | #else |
---|
70 | Double TComRdCost::calcRdCost( UInt uiBits, UInt uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
71 | #endif |
---|
72 | { |
---|
73 | Double dRdCost = 0.0; |
---|
74 | Double dLambda = 0.0; |
---|
75 | |
---|
76 | switch ( eDFunc ) |
---|
77 | { |
---|
78 | case DF_SSE: |
---|
79 | assert(0); |
---|
80 | break; |
---|
81 | case DF_SAD: |
---|
82 | dLambda = (Double)m_uiLambdaMotionSAD; |
---|
83 | break; |
---|
84 | case DF_DEFAULT: |
---|
85 | dLambda = m_dLambda; |
---|
86 | break; |
---|
87 | case DF_SSE_FRAME: |
---|
88 | dLambda = m_dFrameLambda; |
---|
89 | break; |
---|
90 | default: |
---|
91 | assert (0); |
---|
92 | break; |
---|
93 | } |
---|
94 | |
---|
95 | if (bFlag) |
---|
96 | { |
---|
97 | // Intra8x8, Intra4x4 Block only... |
---|
98 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
99 | dRdCost = (Double)(uiBits); |
---|
100 | #else |
---|
101 | dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda)); |
---|
102 | #endif |
---|
103 | } |
---|
104 | else |
---|
105 | { |
---|
106 | if (eDFunc == DF_SAD) |
---|
107 | { |
---|
108 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16)); |
---|
109 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
110 | } |
---|
111 | else |
---|
112 | { |
---|
113 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
114 | dRdCost = (Double)(uiBits); |
---|
115 | #else |
---|
116 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5))); |
---|
117 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
118 | #endif |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | return dRdCost; |
---|
123 | } |
---|
124 | |
---|
125 | #if H_3D_VSO |
---|
126 | Double TComRdCost::calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
127 | #else |
---|
128 | Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
129 | #endif |
---|
130 | { |
---|
131 | Double dRdCost = 0.0; |
---|
132 | Double dLambda = 0.0; |
---|
133 | |
---|
134 | switch ( eDFunc ) |
---|
135 | { |
---|
136 | case DF_SSE: |
---|
137 | assert(0); |
---|
138 | break; |
---|
139 | case DF_SAD: |
---|
140 | dLambda = (Double)m_uiLambdaMotionSAD; |
---|
141 | break; |
---|
142 | case DF_DEFAULT: |
---|
143 | dLambda = m_dLambda; |
---|
144 | break; |
---|
145 | case DF_SSE_FRAME: |
---|
146 | dLambda = m_dFrameLambda; |
---|
147 | break; |
---|
148 | default: |
---|
149 | assert (0); |
---|
150 | break; |
---|
151 | } |
---|
152 | |
---|
153 | if (bFlag) |
---|
154 | { |
---|
155 | // Intra8x8, Intra4x4 Block only... |
---|
156 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
157 | dRdCost = (Double)(uiBits); |
---|
158 | #else |
---|
159 | dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda)); |
---|
160 | #endif |
---|
161 | } |
---|
162 | else |
---|
163 | { |
---|
164 | if (eDFunc == DF_SAD) |
---|
165 | { |
---|
166 | dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5)>>16)); |
---|
167 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
168 | } |
---|
169 | else |
---|
170 | { |
---|
171 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
172 | dRdCost = (Double)(uiBits); |
---|
173 | #else |
---|
174 | dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5))); |
---|
175 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
176 | #endif |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | return dRdCost; |
---|
181 | } |
---|
182 | |
---|
183 | Void TComRdCost::setLambda( Double dLambda ) |
---|
184 | { |
---|
185 | m_dLambda = dLambda; |
---|
186 | m_sqrtLambda = sqrt(m_dLambda); |
---|
187 | m_uiLambdaMotionSAD = (UInt)floor(65536.0 * m_sqrtLambda); |
---|
188 | m_uiLambdaMotionSSE = (UInt)floor(65536.0 * m_dLambda ); |
---|
189 | } |
---|
190 | |
---|
191 | |
---|
192 | // Initalize Function Pointer by [eDFunc] |
---|
193 | Void TComRdCost::init() |
---|
194 | { |
---|
195 | m_afpDistortFunc[0] = NULL; // for DF_DEFAULT |
---|
196 | |
---|
197 | m_afpDistortFunc[1] = TComRdCost::xGetSSE; |
---|
198 | m_afpDistortFunc[2] = TComRdCost::xGetSSE4; |
---|
199 | m_afpDistortFunc[3] = TComRdCost::xGetSSE8; |
---|
200 | m_afpDistortFunc[4] = TComRdCost::xGetSSE16; |
---|
201 | m_afpDistortFunc[5] = TComRdCost::xGetSSE32; |
---|
202 | m_afpDistortFunc[6] = TComRdCost::xGetSSE64; |
---|
203 | m_afpDistortFunc[7] = TComRdCost::xGetSSE16N; |
---|
204 | |
---|
205 | m_afpDistortFunc[8] = TComRdCost::xGetSAD; |
---|
206 | m_afpDistortFunc[9] = TComRdCost::xGetSAD4; |
---|
207 | m_afpDistortFunc[10] = TComRdCost::xGetSAD8; |
---|
208 | m_afpDistortFunc[11] = TComRdCost::xGetSAD16; |
---|
209 | m_afpDistortFunc[12] = TComRdCost::xGetSAD32; |
---|
210 | m_afpDistortFunc[13] = TComRdCost::xGetSAD64; |
---|
211 | m_afpDistortFunc[14] = TComRdCost::xGetSAD16N; |
---|
212 | |
---|
213 | m_afpDistortFunc[15] = TComRdCost::xGetSAD; |
---|
214 | m_afpDistortFunc[16] = TComRdCost::xGetSAD4; |
---|
215 | m_afpDistortFunc[17] = TComRdCost::xGetSAD8; |
---|
216 | m_afpDistortFunc[18] = TComRdCost::xGetSAD16; |
---|
217 | m_afpDistortFunc[19] = TComRdCost::xGetSAD32; |
---|
218 | m_afpDistortFunc[20] = TComRdCost::xGetSAD64; |
---|
219 | m_afpDistortFunc[21] = TComRdCost::xGetSAD16N; |
---|
220 | |
---|
221 | #if AMP_SAD |
---|
222 | m_afpDistortFunc[43] = TComRdCost::xGetSAD12; |
---|
223 | m_afpDistortFunc[44] = TComRdCost::xGetSAD24; |
---|
224 | m_afpDistortFunc[45] = TComRdCost::xGetSAD48; |
---|
225 | |
---|
226 | m_afpDistortFunc[46] = TComRdCost::xGetSAD12; |
---|
227 | m_afpDistortFunc[47] = TComRdCost::xGetSAD24; |
---|
228 | m_afpDistortFunc[48] = TComRdCost::xGetSAD48; |
---|
229 | #endif |
---|
230 | m_afpDistortFunc[22] = TComRdCost::xGetHADs; |
---|
231 | m_afpDistortFunc[23] = TComRdCost::xGetHADs; |
---|
232 | m_afpDistortFunc[24] = TComRdCost::xGetHADs; |
---|
233 | m_afpDistortFunc[25] = TComRdCost::xGetHADs; |
---|
234 | m_afpDistortFunc[26] = TComRdCost::xGetHADs; |
---|
235 | m_afpDistortFunc[27] = TComRdCost::xGetHADs; |
---|
236 | m_afpDistortFunc[28] = TComRdCost::xGetHADs; |
---|
237 | |
---|
238 | #if H_3D_VSO |
---|
239 | // SAIT_VSO_EST_A0033 |
---|
240 | m_afpDistortFunc[29] = TComRdCost::xGetVSD; |
---|
241 | m_afpDistortFunc[30] = TComRdCost::xGetVSD4; |
---|
242 | m_afpDistortFunc[31] = TComRdCost::xGetVSD8; |
---|
243 | m_afpDistortFunc[32] = TComRdCost::xGetVSD16; |
---|
244 | m_afpDistortFunc[33] = TComRdCost::xGetVSD32; |
---|
245 | m_afpDistortFunc[34] = TComRdCost::xGetVSD64; |
---|
246 | m_afpDistortFunc[35] = TComRdCost::xGetVSD16N; |
---|
247 | #endif |
---|
248 | #if !FIX203 |
---|
249 | m_puiComponentCostOriginP = NULL; |
---|
250 | m_puiComponentCost = NULL; |
---|
251 | m_puiVerCost = NULL; |
---|
252 | m_puiHorCost = NULL; |
---|
253 | #endif |
---|
254 | m_uiCost = 0; |
---|
255 | m_iCostScale = 0; |
---|
256 | #if !FIX203 |
---|
257 | m_iSearchLimit = 0xdeaddead; |
---|
258 | #endif |
---|
259 | #if H_3D_VSO |
---|
260 | m_bUseVSO = false; |
---|
261 | m_uiVSOMode = 0; |
---|
262 | m_fpDistortFuncVSO = NULL; |
---|
263 | m_pcRenModel = NULL; |
---|
264 | |
---|
265 | // SAIT_VSO_EST_A0033 |
---|
266 | m_bUseEstimatedVSD = false; |
---|
267 | #endif |
---|
268 | } |
---|
269 | |
---|
270 | #if !FIX203 |
---|
271 | Void TComRdCost::initRateDistortionModel( Int iSubPelSearchLimit ) |
---|
272 | { |
---|
273 | // make it larger |
---|
274 | iSubPelSearchLimit += 4; |
---|
275 | iSubPelSearchLimit *= 8; |
---|
276 | |
---|
277 | if( m_iSearchLimit != iSubPelSearchLimit ) |
---|
278 | { |
---|
279 | xUninit(); |
---|
280 | |
---|
281 | m_iSearchLimit = iSubPelSearchLimit; |
---|
282 | |
---|
283 | m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ]; |
---|
284 | iSubPelSearchLimit *= 2; |
---|
285 | |
---|
286 | m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit; |
---|
287 | |
---|
288 | for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++) |
---|
289 | { |
---|
290 | m_puiComponentCost[n] = xGetComponentBits( n ); |
---|
291 | } |
---|
292 | } |
---|
293 | } |
---|
294 | |
---|
295 | Void TComRdCost::xUninit() |
---|
296 | { |
---|
297 | if( NULL != m_puiComponentCostOriginP ) |
---|
298 | { |
---|
299 | delete [] m_puiComponentCostOriginP; |
---|
300 | m_puiComponentCostOriginP = NULL; |
---|
301 | } |
---|
302 | } |
---|
303 | #endif |
---|
304 | |
---|
305 | UInt TComRdCost::xGetComponentBits( Int iVal ) |
---|
306 | { |
---|
307 | UInt uiLength = 1; |
---|
308 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
309 | |
---|
310 | assert ( uiTemp ); |
---|
311 | |
---|
312 | while ( 1 != uiTemp ) |
---|
313 | { |
---|
314 | uiTemp >>= 1; |
---|
315 | uiLength += 2; |
---|
316 | } |
---|
317 | |
---|
318 | return uiLength; |
---|
319 | } |
---|
320 | |
---|
321 | Void TComRdCost::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam ) |
---|
322 | { |
---|
323 | // set Block Width / Height |
---|
324 | rcDistParam.iCols = uiBlkWidth; |
---|
325 | rcDistParam.iRows = uiBlkHeight; |
---|
326 | rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
327 | |
---|
328 | // initialize |
---|
329 | rcDistParam.iSubShift = 0; |
---|
330 | } |
---|
331 | |
---|
332 | // Setting the Distortion Parameter for Inter (ME) |
---|
333 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam ) |
---|
334 | { |
---|
335 | // set Original & Curr Pointer / Stride |
---|
336 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
337 | rcDistParam.pCur = piRefY; |
---|
338 | |
---|
339 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
340 | rcDistParam.iStrideCur = iRefStride; |
---|
341 | |
---|
342 | // set Block Width / Height |
---|
343 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
344 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
345 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
346 | |
---|
347 | #if AMP_SAD |
---|
348 | if (rcDistParam.iCols == 12) |
---|
349 | { |
---|
350 | rcDistParam.DistFunc = m_afpDistortFunc[43 ]; |
---|
351 | } |
---|
352 | else if (rcDistParam.iCols == 24) |
---|
353 | { |
---|
354 | rcDistParam.DistFunc = m_afpDistortFunc[44 ]; |
---|
355 | } |
---|
356 | else if (rcDistParam.iCols == 48) |
---|
357 | { |
---|
358 | rcDistParam.DistFunc = m_afpDistortFunc[45 ]; |
---|
359 | } |
---|
360 | #endif |
---|
361 | |
---|
362 | // initialize |
---|
363 | rcDistParam.iSubShift = 0; |
---|
364 | } |
---|
365 | |
---|
366 | // Setting the Distortion Parameter for Inter (subpel ME with step) |
---|
367 | #if NS_HAD |
---|
368 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME, Bool bUseNSHAD ) |
---|
369 | #else |
---|
370 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME ) |
---|
371 | #endif |
---|
372 | { |
---|
373 | // set Original & Curr Pointer / Stride |
---|
374 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
375 | rcDistParam.pCur = piRefY; |
---|
376 | |
---|
377 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
378 | rcDistParam.iStrideCur = iRefStride * iStep; |
---|
379 | |
---|
380 | // set Step for interpolated buffer |
---|
381 | rcDistParam.iStep = iStep; |
---|
382 | |
---|
383 | // set Block Width / Height |
---|
384 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
385 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
386 | #if NS_HAD |
---|
387 | rcDistParam.bUseNSHAD = bUseNSHAD; |
---|
388 | #endif |
---|
389 | |
---|
390 | // set distortion function |
---|
391 | if ( !bHADME ) |
---|
392 | { |
---|
393 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
394 | #if AMP_SAD |
---|
395 | if (rcDistParam.iCols == 12) |
---|
396 | { |
---|
397 | rcDistParam.DistFunc = m_afpDistortFunc[46 ]; |
---|
398 | } |
---|
399 | else if (rcDistParam.iCols == 24) |
---|
400 | { |
---|
401 | rcDistParam.DistFunc = m_afpDistortFunc[47 ]; |
---|
402 | } |
---|
403 | else if (rcDistParam.iCols == 48) |
---|
404 | { |
---|
405 | rcDistParam.DistFunc = m_afpDistortFunc[48 ]; |
---|
406 | } |
---|
407 | #endif |
---|
408 | } |
---|
409 | else |
---|
410 | { |
---|
411 | rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
412 | } |
---|
413 | |
---|
414 | // initialize |
---|
415 | rcDistParam.iSubShift = 0; |
---|
416 | } |
---|
417 | |
---|
418 | Void |
---|
419 | #if NS_HAD |
---|
420 | TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard, Bool bUseNSHAD ) |
---|
421 | #else |
---|
422 | TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard ) |
---|
423 | #endif |
---|
424 | { |
---|
425 | rcDP.pOrg = p1; |
---|
426 | rcDP.pCur = p2; |
---|
427 | rcDP.iStrideOrg = iStride1; |
---|
428 | rcDP.iStrideCur = iStride2; |
---|
429 | rcDP.iCols = iWidth; |
---|
430 | rcDP.iRows = iHeight; |
---|
431 | rcDP.iStep = 1; |
---|
432 | rcDP.iSubShift = 0; |
---|
433 | rcDP.bitDepth = bitDepth; |
---|
434 | rcDP.DistFunc = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ]; |
---|
435 | #if NS_HAD |
---|
436 | rcDP.bUseNSHAD = bUseNSHAD; |
---|
437 | #endif |
---|
438 | } |
---|
439 | |
---|
440 | UInt TComRdCost::calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight ) |
---|
441 | { |
---|
442 | UInt uiSum = 0; |
---|
443 | Int x, y; |
---|
444 | |
---|
445 | if ( ( (iWidth % 8) == 0 ) && ( (iHeight % 8) == 0 ) ) |
---|
446 | { |
---|
447 | for ( y=0; y<iHeight; y+= 8 ) |
---|
448 | { |
---|
449 | for ( x=0; x<iWidth; x+= 8 ) |
---|
450 | { |
---|
451 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
452 | } |
---|
453 | pi0 += iStride0*8; |
---|
454 | pi1 += iStride1*8; |
---|
455 | } |
---|
456 | } |
---|
457 | else if ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) ) |
---|
458 | { |
---|
459 | for ( y=0; y<iHeight; y+= 4 ) |
---|
460 | { |
---|
461 | for ( x=0; x<iWidth; x+= 4 ) |
---|
462 | { |
---|
463 | uiSum += xCalcHADs4x4( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
464 | } |
---|
465 | pi0 += iStride0*4; |
---|
466 | pi1 += iStride1*4; |
---|
467 | } |
---|
468 | } |
---|
469 | else |
---|
470 | { |
---|
471 | for ( y=0; y<iHeight; y+= 2 ) |
---|
472 | { |
---|
473 | for ( x=0; x<iWidth; x+= 2 ) |
---|
474 | { |
---|
475 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
476 | } |
---|
477 | pi0 += iStride0*2; |
---|
478 | pi1 += iStride1*2; |
---|
479 | } |
---|
480 | } |
---|
481 | |
---|
482 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); |
---|
483 | |
---|
484 | } |
---|
485 | |
---|
486 | #if SCU_HS_FAST_DEPTH_INTRA_E0238 |
---|
487 | |
---|
488 | UInt TComRdCost::calcVAR (Pel* pi0, Int stride, Int width, Int height, Int cuDepth) |
---|
489 | { |
---|
490 | Int temp = 0; |
---|
491 | |
---|
492 | for (Int y = 0; y < height; y++) |
---|
493 | { |
---|
494 | for (Int x = 0; x < width; x++) |
---|
495 | { |
---|
496 | temp += pi0[ y * stride + x ]; |
---|
497 | } |
---|
498 | } |
---|
499 | |
---|
500 | Int cuMaxLog2Size = g_aucConvertToBit[g_uiMaxCUWidth]+2; |
---|
501 | |
---|
502 | if ( width == 4 ) |
---|
503 | { |
---|
504 | cuDepth = cuMaxLog2Size - 2; |
---|
505 | } |
---|
506 | |
---|
507 | temp = temp >> (cuMaxLog2Size-cuDepth) * 2; |
---|
508 | |
---|
509 | UInt sum = 0; |
---|
510 | for (Int y = 0; y < height; y++) |
---|
511 | { |
---|
512 | for (Int x = 0; x < width; x++) |
---|
513 | { |
---|
514 | sum += (pi0[ y * stride + x ] - temp ) * (pi0[ y * stride + x ] - temp ); |
---|
515 | } |
---|
516 | } |
---|
517 | return (sum >> (cuMaxLog2Size-cuDepth)*2); |
---|
518 | |
---|
519 | } |
---|
520 | #endif |
---|
521 | |
---|
522 | |
---|
523 | #if WEIGHTED_CHROMA_DISTORTION |
---|
524 | UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText, DFunc eDFunc) |
---|
525 | #else |
---|
526 | UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc ) |
---|
527 | #endif |
---|
528 | { |
---|
529 | DistParam cDtParam; |
---|
530 | setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam ); |
---|
531 | cDtParam.pOrg = piOrg; |
---|
532 | cDtParam.pCur = piCur; |
---|
533 | cDtParam.iStrideOrg = iOrgStride; |
---|
534 | cDtParam.iStrideCur = iCurStride; |
---|
535 | cDtParam.iStep = 1; |
---|
536 | |
---|
537 | cDtParam.bApplyWeight = false; |
---|
538 | cDtParam.uiComp = 255; // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed. |
---|
539 | cDtParam.bitDepth = bitDepth; |
---|
540 | |
---|
541 | #if H_3D_IC |
---|
542 | cDtParam.bUseIC = false; |
---|
543 | #endif |
---|
544 | #if WEIGHTED_CHROMA_DISTORTION |
---|
545 | if (eText == TEXT_CHROMA_U) |
---|
546 | { |
---|
547 | return ((Int) (m_cbDistortionWeight * cDtParam.DistFunc( &cDtParam ))); |
---|
548 | } |
---|
549 | else if (eText == TEXT_CHROMA_V) |
---|
550 | { |
---|
551 | return ((Int) (m_crDistortionWeight * cDtParam.DistFunc( &cDtParam ))); |
---|
552 | } |
---|
553 | else |
---|
554 | { |
---|
555 | return cDtParam.DistFunc( &cDtParam ); |
---|
556 | } |
---|
557 | #else |
---|
558 | return cDtParam.DistFunc( &cDtParam ); |
---|
559 | #endif |
---|
560 | } |
---|
561 | #if H_3D_VSO |
---|
562 | // SAIT_VSO_EST_A0033 |
---|
563 | UInt TComRdCost::getDistPartVSD( TComDataCU* pcCU, UInt uiPartOffset, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHAD, DFunc eDFunc ) |
---|
564 | { |
---|
565 | AOT( ( m_dDisparityCoeff <= 0 ) || ( m_dDisparityCoeff > 10 ) ); |
---|
566 | |
---|
567 | Pel* piVirRec = m_pcVideoRecPicYuv->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset); |
---|
568 | Pel* piVirOrg = m_pcDepthPicYuv ->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset); |
---|
569 | Int iVirStride = m_pcVideoRecPicYuv->getStride(); |
---|
570 | |
---|
571 | DistParam cDtParam; |
---|
572 | setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam ); |
---|
573 | cDtParam.pOrg = piOrg; |
---|
574 | cDtParam.pCur = piCur; |
---|
575 | cDtParam.pVirRec = piVirRec; |
---|
576 | cDtParam.pVirOrg = piVirOrg; |
---|
577 | cDtParam.iStrideVir = iVirStride; |
---|
578 | cDtParam.iStrideOrg = iOrgStride; |
---|
579 | cDtParam.iStrideCur = iCurStride; |
---|
580 | cDtParam.iStep = 1; |
---|
581 | |
---|
582 | cDtParam.bApplyWeight = false; |
---|
583 | cDtParam.uiComp = 255; // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed. |
---|
584 | |
---|
585 | Dist dist = cDtParam.DistFunc( &cDtParam ); |
---|
586 | |
---|
587 | if ( m_bUseWVSO ) |
---|
588 | { |
---|
589 | Int iDWeight = m_iDWeight * m_iDWeight; |
---|
590 | Int iVSOWeight = m_iVSDWeight * m_iVSDWeight; |
---|
591 | Dist distDepth; |
---|
592 | |
---|
593 | if ( !bHAD ) |
---|
594 | { |
---|
595 | distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
596 | } |
---|
597 | else |
---|
598 | { |
---|
599 | distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
600 | } |
---|
601 | |
---|
602 | dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight); |
---|
603 | } |
---|
604 | return dist; |
---|
605 | |
---|
606 | } |
---|
607 | #endif |
---|
608 | |
---|
609 | #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT |
---|
610 | UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride, Pel* pelOrg, Int orgStride, UInt width, UInt height ) |
---|
611 | { |
---|
612 | UInt SAD = 0; |
---|
613 | Int shift = DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); |
---|
614 | for ( Int i=0; i<height; i++ ) |
---|
615 | { |
---|
616 | for( Int j=0; j<width; j++ ) |
---|
617 | { |
---|
618 | SAD += abs((pelCur[j] - pelOrg[j])) >> shift; |
---|
619 | } |
---|
620 | pelCur = pelCur + curStride; |
---|
621 | pelOrg = pelOrg + orgStride; |
---|
622 | } |
---|
623 | return SAD; |
---|
624 | } |
---|
625 | #endif |
---|
626 | |
---|
627 | // ==================================================================================================================== |
---|
628 | // Distortion functions |
---|
629 | // ==================================================================================================================== |
---|
630 | |
---|
631 | // -------------------------------------------------------------------------------------------------------------------- |
---|
632 | // SAD |
---|
633 | // -------------------------------------------------------------------------------------------------------------------- |
---|
634 | |
---|
635 | UInt TComRdCost::xGetSAD( DistParam* pcDtParam ) |
---|
636 | { |
---|
637 | if ( pcDtParam->bApplyWeight ) |
---|
638 | { |
---|
639 | return xGetSADw( pcDtParam ); |
---|
640 | } |
---|
641 | #if H_3D_IC |
---|
642 | if( pcDtParam->bUseIC ) |
---|
643 | { |
---|
644 | return xGetSADic( pcDtParam ); |
---|
645 | } |
---|
646 | #endif |
---|
647 | Pel* piOrg = pcDtParam->pOrg; |
---|
648 | Pel* piCur = pcDtParam->pCur; |
---|
649 | Int iRows = pcDtParam->iRows; |
---|
650 | Int iCols = pcDtParam->iCols; |
---|
651 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
652 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
653 | |
---|
654 | UInt uiSum = 0; |
---|
655 | |
---|
656 | for( ; iRows != 0; iRows-- ) |
---|
657 | { |
---|
658 | for (Int n = 0; n < iCols; n++ ) |
---|
659 | { |
---|
660 | uiSum += abs( piOrg[n] - piCur[n] ); |
---|
661 | } |
---|
662 | piOrg += iStrideOrg; |
---|
663 | piCur += iStrideCur; |
---|
664 | } |
---|
665 | |
---|
666 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
667 | } |
---|
668 | |
---|
669 | UInt TComRdCost::xGetSAD4( DistParam* pcDtParam ) |
---|
670 | { |
---|
671 | if ( pcDtParam->bApplyWeight ) |
---|
672 | { |
---|
673 | return xGetSADw( pcDtParam ); |
---|
674 | } |
---|
675 | #if H_3D_IC |
---|
676 | if( pcDtParam->bUseIC ) |
---|
677 | { |
---|
678 | return xGetSAD4ic( pcDtParam ); |
---|
679 | } |
---|
680 | #endif |
---|
681 | Pel* piOrg = pcDtParam->pOrg; |
---|
682 | Pel* piCur = pcDtParam->pCur; |
---|
683 | Int iRows = pcDtParam->iRows; |
---|
684 | Int iSubShift = pcDtParam->iSubShift; |
---|
685 | Int iSubStep = ( 1 << iSubShift ); |
---|
686 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
687 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
688 | |
---|
689 | UInt uiSum = 0; |
---|
690 | |
---|
691 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
692 | { |
---|
693 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
694 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
695 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
696 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
697 | |
---|
698 | piOrg += iStrideOrg; |
---|
699 | piCur += iStrideCur; |
---|
700 | } |
---|
701 | |
---|
702 | uiSum <<= iSubShift; |
---|
703 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
704 | } |
---|
705 | |
---|
706 | UInt TComRdCost::xGetSAD8( DistParam* pcDtParam ) |
---|
707 | { |
---|
708 | if ( pcDtParam->bApplyWeight ) |
---|
709 | { |
---|
710 | return xGetSADw( pcDtParam ); |
---|
711 | } |
---|
712 | #if H_3D_IC |
---|
713 | if( pcDtParam->bUseIC ) |
---|
714 | { |
---|
715 | return xGetSAD8ic( pcDtParam ); |
---|
716 | } |
---|
717 | #endif |
---|
718 | Pel* piOrg = pcDtParam->pOrg; |
---|
719 | Pel* piCur = pcDtParam->pCur; |
---|
720 | Int iRows = pcDtParam->iRows; |
---|
721 | Int iSubShift = pcDtParam->iSubShift; |
---|
722 | Int iSubStep = ( 1 << iSubShift ); |
---|
723 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
724 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
725 | |
---|
726 | UInt uiSum = 0; |
---|
727 | |
---|
728 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
729 | { |
---|
730 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
731 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
732 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
733 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
734 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
735 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
736 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
737 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
738 | |
---|
739 | piOrg += iStrideOrg; |
---|
740 | piCur += iStrideCur; |
---|
741 | } |
---|
742 | |
---|
743 | uiSum <<= iSubShift; |
---|
744 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
745 | } |
---|
746 | |
---|
747 | UInt TComRdCost::xGetSAD16( DistParam* pcDtParam ) |
---|
748 | { |
---|
749 | if ( pcDtParam->bApplyWeight ) |
---|
750 | { |
---|
751 | return xGetSADw( pcDtParam ); |
---|
752 | } |
---|
753 | #if H_3D_IC |
---|
754 | if( pcDtParam->bUseIC ) |
---|
755 | { |
---|
756 | return xGetSAD16ic( pcDtParam ); |
---|
757 | } |
---|
758 | #endif |
---|
759 | Pel* piOrg = pcDtParam->pOrg; |
---|
760 | Pel* piCur = pcDtParam->pCur; |
---|
761 | Int iRows = pcDtParam->iRows; |
---|
762 | Int iSubShift = pcDtParam->iSubShift; |
---|
763 | Int iSubStep = ( 1 << iSubShift ); |
---|
764 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
765 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
766 | |
---|
767 | UInt uiSum = 0; |
---|
768 | |
---|
769 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
770 | { |
---|
771 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
772 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
773 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
774 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
775 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
776 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
777 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
778 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
779 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
780 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
781 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
782 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
783 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
784 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
785 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
786 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
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::xGetSAD12( DistParam* pcDtParam ) |
---|
798 | { |
---|
799 | if ( pcDtParam->bApplyWeight ) |
---|
800 | { |
---|
801 | return xGetSADw( pcDtParam ); |
---|
802 | } |
---|
803 | #if H_3D_IC |
---|
804 | if( pcDtParam->bUseIC ) |
---|
805 | { |
---|
806 | return xGetSAD12ic( pcDtParam ); |
---|
807 | } |
---|
808 | #endif |
---|
809 | Pel* piOrg = pcDtParam->pOrg; |
---|
810 | Pel* piCur = pcDtParam->pCur; |
---|
811 | Int iRows = pcDtParam->iRows; |
---|
812 | Int iSubShift = pcDtParam->iSubShift; |
---|
813 | Int iSubStep = ( 1 << iSubShift ); |
---|
814 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
815 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
816 | |
---|
817 | UInt uiSum = 0; |
---|
818 | |
---|
819 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
820 | { |
---|
821 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
822 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
823 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
824 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
825 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
826 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
827 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
828 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
829 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
830 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
831 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
832 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
833 | |
---|
834 | piOrg += iStrideOrg; |
---|
835 | piCur += iStrideCur; |
---|
836 | } |
---|
837 | |
---|
838 | uiSum <<= iSubShift; |
---|
839 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
840 | } |
---|
841 | #endif |
---|
842 | |
---|
843 | UInt TComRdCost::xGetSAD16N( DistParam* pcDtParam ) |
---|
844 | { |
---|
845 | #if H_3D_IC |
---|
846 | if( pcDtParam->bUseIC ) |
---|
847 | { |
---|
848 | return xGetSAD16Nic( pcDtParam ); |
---|
849 | } |
---|
850 | #endif |
---|
851 | Pel* piOrg = pcDtParam->pOrg; |
---|
852 | Pel* piCur = pcDtParam->pCur; |
---|
853 | Int iRows = pcDtParam->iRows; |
---|
854 | Int iCols = pcDtParam->iCols; |
---|
855 | Int iSubShift = pcDtParam->iSubShift; |
---|
856 | Int iSubStep = ( 1 << iSubShift ); |
---|
857 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
858 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
859 | |
---|
860 | UInt uiSum = 0; |
---|
861 | |
---|
862 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
863 | { |
---|
864 | for (Int n = 0; n < iCols; n+=16 ) |
---|
865 | { |
---|
866 | uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] ); |
---|
867 | uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] ); |
---|
868 | uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] ); |
---|
869 | uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] ); |
---|
870 | uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] ); |
---|
871 | uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] ); |
---|
872 | uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] ); |
---|
873 | uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] ); |
---|
874 | uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] ); |
---|
875 | uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] ); |
---|
876 | uiSum += abs( piOrg[n+10] - piCur[n+10] ); |
---|
877 | uiSum += abs( piOrg[n+11] - piCur[n+11] ); |
---|
878 | uiSum += abs( piOrg[n+12] - piCur[n+12] ); |
---|
879 | uiSum += abs( piOrg[n+13] - piCur[n+13] ); |
---|
880 | uiSum += abs( piOrg[n+14] - piCur[n+14] ); |
---|
881 | uiSum += abs( piOrg[n+15] - piCur[n+15] ); |
---|
882 | } |
---|
883 | piOrg += iStrideOrg; |
---|
884 | piCur += iStrideCur; |
---|
885 | } |
---|
886 | |
---|
887 | uiSum <<= iSubShift; |
---|
888 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
889 | } |
---|
890 | |
---|
891 | UInt TComRdCost::xGetSAD32( DistParam* pcDtParam ) |
---|
892 | { |
---|
893 | if ( pcDtParam->bApplyWeight ) |
---|
894 | { |
---|
895 | return xGetSADw( pcDtParam ); |
---|
896 | } |
---|
897 | #if H_3D_IC |
---|
898 | if( pcDtParam->bUseIC ) |
---|
899 | { |
---|
900 | return xGetSAD32ic( pcDtParam ); |
---|
901 | } |
---|
902 | #endif |
---|
903 | Pel* piOrg = pcDtParam->pOrg; |
---|
904 | Pel* piCur = pcDtParam->pCur; |
---|
905 | Int iRows = pcDtParam->iRows; |
---|
906 | Int iSubShift = pcDtParam->iSubShift; |
---|
907 | Int iSubStep = ( 1 << iSubShift ); |
---|
908 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
909 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
910 | |
---|
911 | UInt uiSum = 0; |
---|
912 | |
---|
913 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
914 | { |
---|
915 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
916 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
917 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
918 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
919 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
920 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
921 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
922 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
923 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
924 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
925 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
926 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
927 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
928 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
929 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
930 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
931 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
932 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
933 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
934 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
935 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
936 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
937 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
938 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
939 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
940 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
941 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
942 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
943 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
944 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
945 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
946 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
947 | |
---|
948 | piOrg += iStrideOrg; |
---|
949 | piCur += iStrideCur; |
---|
950 | } |
---|
951 | |
---|
952 | uiSum <<= iSubShift; |
---|
953 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
954 | } |
---|
955 | |
---|
956 | #if AMP_SAD |
---|
957 | UInt TComRdCost::xGetSAD24( DistParam* pcDtParam ) |
---|
958 | { |
---|
959 | if ( pcDtParam->bApplyWeight ) |
---|
960 | { |
---|
961 | return xGetSADw( pcDtParam ); |
---|
962 | } |
---|
963 | #if H_3D_IC |
---|
964 | if( pcDtParam->bUseIC ) |
---|
965 | { |
---|
966 | return xGetSAD24ic( pcDtParam ); |
---|
967 | } |
---|
968 | #endif |
---|
969 | Pel* piOrg = pcDtParam->pOrg; |
---|
970 | Pel* piCur = pcDtParam->pCur; |
---|
971 | Int iRows = pcDtParam->iRows; |
---|
972 | Int iSubShift = pcDtParam->iSubShift; |
---|
973 | Int iSubStep = ( 1 << iSubShift ); |
---|
974 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
975 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
976 | |
---|
977 | UInt uiSum = 0; |
---|
978 | |
---|
979 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
980 | { |
---|
981 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
982 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
983 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
984 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
985 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
986 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
987 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
988 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
989 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
990 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
991 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
992 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
993 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
994 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
995 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
996 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
997 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
998 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
999 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
1000 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
1001 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
1002 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
1003 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
1004 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
1005 | |
---|
1006 | piOrg += iStrideOrg; |
---|
1007 | piCur += iStrideCur; |
---|
1008 | } |
---|
1009 | |
---|
1010 | uiSum <<= iSubShift; |
---|
1011 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
1012 | } |
---|
1013 | |
---|
1014 | #endif |
---|
1015 | |
---|
1016 | UInt TComRdCost::xGetSAD64( DistParam* pcDtParam ) |
---|
1017 | { |
---|
1018 | if ( pcDtParam->bApplyWeight ) |
---|
1019 | { |
---|
1020 | return xGetSADw( pcDtParam ); |
---|
1021 | } |
---|
1022 | #if H_3D_IC |
---|
1023 | if( pcDtParam->bUseIC ) |
---|
1024 | { |
---|
1025 | return xGetSAD64ic( pcDtParam ); |
---|
1026 | } |
---|
1027 | #endif |
---|
1028 | Pel* piOrg = pcDtParam->pOrg; |
---|
1029 | Pel* piCur = pcDtParam->pCur; |
---|
1030 | Int iRows = pcDtParam->iRows; |
---|
1031 | Int iSubShift = pcDtParam->iSubShift; |
---|
1032 | Int iSubStep = ( 1 << iSubShift ); |
---|
1033 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
1034 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
1035 | |
---|
1036 | UInt uiSum = 0; |
---|
1037 | |
---|
1038 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1039 | { |
---|
1040 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
1041 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
1042 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
1043 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
1044 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
1045 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
1046 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
1047 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
1048 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
1049 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
1050 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
1051 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
1052 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
1053 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
1054 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
1055 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
1056 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
1057 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
1058 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
1059 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
1060 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
1061 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
1062 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
1063 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
1064 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
1065 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
1066 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
1067 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
1068 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
1069 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
1070 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
1071 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
1072 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
1073 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
1074 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
1075 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
1076 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
1077 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
1078 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
1079 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
1080 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
1081 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
1082 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
1083 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
1084 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
1085 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
1086 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
1087 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
1088 | uiSum += abs( piOrg[48] - piCur[48] ); |
---|
1089 | uiSum += abs( piOrg[49] - piCur[49] ); |
---|
1090 | uiSum += abs( piOrg[50] - piCur[50] ); |
---|
1091 | uiSum += abs( piOrg[51] - piCur[51] ); |
---|
1092 | uiSum += abs( piOrg[52] - piCur[52] ); |
---|
1093 | uiSum += abs( piOrg[53] - piCur[53] ); |
---|
1094 | uiSum += abs( piOrg[54] - piCur[54] ); |
---|
1095 | uiSum += abs( piOrg[55] - piCur[55] ); |
---|
1096 | uiSum += abs( piOrg[56] - piCur[56] ); |
---|
1097 | uiSum += abs( piOrg[57] - piCur[57] ); |
---|
1098 | uiSum += abs( piOrg[58] - piCur[58] ); |
---|
1099 | uiSum += abs( piOrg[59] - piCur[59] ); |
---|
1100 | uiSum += abs( piOrg[60] - piCur[60] ); |
---|
1101 | uiSum += abs( piOrg[61] - piCur[61] ); |
---|
1102 | uiSum += abs( piOrg[62] - piCur[62] ); |
---|
1103 | uiSum += abs( piOrg[63] - piCur[63] ); |
---|
1104 | |
---|
1105 | piOrg += iStrideOrg; |
---|
1106 | piCur += iStrideCur; |
---|
1107 | } |
---|
1108 | |
---|
1109 | uiSum <<= iSubShift; |
---|
1110 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
1111 | } |
---|
1112 | |
---|
1113 | #if AMP_SAD |
---|
1114 | UInt TComRdCost::xGetSAD48( DistParam* pcDtParam ) |
---|
1115 | { |
---|
1116 | if ( pcDtParam->bApplyWeight ) |
---|
1117 | { |
---|
1118 | return xGetSADw( pcDtParam ); |
---|
1119 | } |
---|
1120 | #if H_3D_IC |
---|
1121 | if( pcDtParam->bUseIC ) |
---|
1122 | { |
---|
1123 | return xGetSAD48ic( pcDtParam ); |
---|
1124 | } |
---|
1125 | #endif |
---|
1126 | Pel* piOrg = pcDtParam->pOrg; |
---|
1127 | Pel* piCur = pcDtParam->pCur; |
---|
1128 | Int iRows = pcDtParam->iRows; |
---|
1129 | Int iSubShift = pcDtParam->iSubShift; |
---|
1130 | Int iSubStep = ( 1 << iSubShift ); |
---|
1131 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
1132 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
1133 | |
---|
1134 | UInt uiSum = 0; |
---|
1135 | |
---|
1136 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1137 | { |
---|
1138 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
1139 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
1140 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
1141 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
1142 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
1143 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
1144 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
1145 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
1146 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
1147 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
1148 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
1149 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
1150 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
1151 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
1152 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
1153 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
1154 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
1155 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
1156 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
1157 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
1158 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
1159 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
1160 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
1161 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
1162 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
1163 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
1164 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
1165 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
1166 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
1167 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
1168 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
1169 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
1170 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
1171 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
1172 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
1173 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
1174 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
1175 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
1176 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
1177 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
1178 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
1179 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
1180 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
1181 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
1182 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
1183 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
1184 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
1185 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
1186 | |
---|
1187 | piOrg += iStrideOrg; |
---|
1188 | piCur += iStrideCur; |
---|
1189 | } |
---|
1190 | |
---|
1191 | uiSum <<= iSubShift; |
---|
1192 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
1193 | } |
---|
1194 | #endif |
---|
1195 | |
---|
1196 | #if H_3D_IC |
---|
1197 | UInt TComRdCost::xGetSADic( DistParam* pcDtParam ) |
---|
1198 | { |
---|
1199 | if ( pcDtParam->bApplyWeight ) |
---|
1200 | { |
---|
1201 | return xGetSADw( pcDtParam ); |
---|
1202 | } |
---|
1203 | Pel* piOrg = pcDtParam->pOrg; |
---|
1204 | Pel* piCur = pcDtParam->pCur; |
---|
1205 | Int iRows = pcDtParam->iRows; |
---|
1206 | Int iCols = pcDtParam->iCols; |
---|
1207 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1208 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1209 | |
---|
1210 | UInt uiSum = 0; |
---|
1211 | |
---|
1212 | Int iOrigAvg = 0, iCurAvg = 0; |
---|
1213 | Int iDeltaC; |
---|
1214 | |
---|
1215 | for( ; iRows != 0; iRows-- ) |
---|
1216 | { |
---|
1217 | for (Int n = 0; n < iCols; n++ ) |
---|
1218 | { |
---|
1219 | iOrigAvg += piOrg[n]; |
---|
1220 | iCurAvg += piCur[n]; |
---|
1221 | } |
---|
1222 | piOrg += iStrideOrg; |
---|
1223 | piCur += iStrideCur; |
---|
1224 | } |
---|
1225 | |
---|
1226 | piOrg = pcDtParam->pOrg; |
---|
1227 | piCur = pcDtParam->pCur; |
---|
1228 | iRows = pcDtParam->iRows; |
---|
1229 | |
---|
1230 | iDeltaC = (iOrigAvg - iCurAvg)/iCols/iRows; |
---|
1231 | |
---|
1232 | for( ; iRows != 0; iRows-- ) |
---|
1233 | { |
---|
1234 | for (Int n = 0; n < iCols; n++ ) |
---|
1235 | { |
---|
1236 | uiSum += abs( piOrg[n] - piCur[n] - iDeltaC ); |
---|
1237 | } |
---|
1238 | piOrg += iStrideOrg; |
---|
1239 | piCur += iStrideCur; |
---|
1240 | } |
---|
1241 | |
---|
1242 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
1243 | } |
---|
1244 | |
---|
1245 | UInt TComRdCost::xGetSAD4ic( DistParam* pcDtParam ) |
---|
1246 | { |
---|
1247 | if ( pcDtParam->bApplyWeight ) |
---|
1248 | { |
---|
1249 | return xGetSADw( pcDtParam ); |
---|
1250 | } |
---|
1251 | Pel* piOrg = pcDtParam->pOrg; |
---|
1252 | Pel* piCur = pcDtParam->pCur; |
---|
1253 | Int iRows = pcDtParam->iRows; |
---|
1254 | Int iSubShift = pcDtParam->iSubShift; |
---|
1255 | Int iSubStep = ( 1 << iSubShift ); |
---|
1256 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
1257 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
1258 | |
---|
1259 | UInt uiSum = 0; |
---|
1260 | |
---|
1261 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
1262 | Int iDeltaC; |
---|
1263 | |
---|
1264 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1265 | { |
---|
1266 | iOrigAvg += piOrg[0]; |
---|
1267 | iOrigAvg += piOrg[1]; |
---|
1268 | iOrigAvg += piOrg[2]; |
---|
1269 | iOrigAvg += piOrg[3]; |
---|
1270 | |
---|
1271 | iCurAvg += piCur[0]; |
---|
1272 | iCurAvg += piCur[1]; |
---|
1273 | iCurAvg += piCur[2]; |
---|
1274 | iCurAvg += piCur[3]; |
---|
1275 | |
---|
1276 | piOrg += iStrideOrg; |
---|
1277 | piCur += iStrideCur; |
---|
1278 | uiRowCnt++; |
---|
1279 | } |
---|
1280 | |
---|
1281 | piOrg = pcDtParam->pOrg; |
---|
1282 | piCur = pcDtParam->pCur; |
---|
1283 | iRows = pcDtParam->iRows; |
---|
1284 | |
---|
1285 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/4) : 0; |
---|
1286 | |
---|
1287 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1288 | { |
---|
1289 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
1290 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
1291 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
1292 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
1293 | |
---|
1294 | piOrg += iStrideOrg; |
---|
1295 | piCur += iStrideCur; |
---|
1296 | } |
---|
1297 | |
---|
1298 | uiSum <<= iSubShift; |
---|
1299 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
1300 | } |
---|
1301 | |
---|
1302 | UInt TComRdCost::xGetSAD8ic( DistParam* pcDtParam ) |
---|
1303 | { |
---|
1304 | if ( pcDtParam->bApplyWeight ) |
---|
1305 | { |
---|
1306 | return xGetSADw( pcDtParam ); |
---|
1307 | } |
---|
1308 | Pel* piOrg = pcDtParam->pOrg; |
---|
1309 | Pel* piCur = pcDtParam->pCur; |
---|
1310 | Int iRows = pcDtParam->iRows; |
---|
1311 | Int iSubShift = pcDtParam->iSubShift; |
---|
1312 | Int iSubStep = ( 1 << iSubShift ); |
---|
1313 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
1314 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
1315 | |
---|
1316 | UInt uiSum = 0; |
---|
1317 | |
---|
1318 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
1319 | Int iDeltaC; |
---|
1320 | |
---|
1321 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1322 | { |
---|
1323 | iOrigAvg += piOrg[0]; |
---|
1324 | iOrigAvg += piOrg[1]; |
---|
1325 | iOrigAvg += piOrg[2]; |
---|
1326 | iOrigAvg += piOrg[3]; |
---|
1327 | iOrigAvg += piOrg[4]; |
---|
1328 | iOrigAvg += piOrg[5]; |
---|
1329 | iOrigAvg += piOrg[6]; |
---|
1330 | iOrigAvg += piOrg[7]; |
---|
1331 | |
---|
1332 | iCurAvg += piCur[0]; |
---|
1333 | iCurAvg += piCur[1]; |
---|
1334 | iCurAvg += piCur[2]; |
---|
1335 | iCurAvg += piCur[3]; |
---|
1336 | iCurAvg += piCur[4]; |
---|
1337 | iCurAvg += piCur[5]; |
---|
1338 | iCurAvg += piCur[6]; |
---|
1339 | iCurAvg += piCur[7]; |
---|
1340 | |
---|
1341 | piOrg += iStrideOrg; |
---|
1342 | piCur += iStrideCur; |
---|
1343 | uiRowCnt++; |
---|
1344 | } |
---|
1345 | |
---|
1346 | piOrg = pcDtParam->pOrg; |
---|
1347 | piCur = pcDtParam->pCur; |
---|
1348 | iRows = pcDtParam->iRows; |
---|
1349 | |
---|
1350 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/8) : 0; |
---|
1351 | |
---|
1352 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1353 | { |
---|
1354 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
1355 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
1356 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
1357 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
1358 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
1359 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
1360 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
1361 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
1362 | |
---|
1363 | piOrg += iStrideOrg; |
---|
1364 | piCur += iStrideCur; |
---|
1365 | } |
---|
1366 | |
---|
1367 | uiSum <<= iSubShift; |
---|
1368 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
1369 | } |
---|
1370 | |
---|
1371 | UInt TComRdCost::xGetSAD16ic( DistParam* pcDtParam ) |
---|
1372 | { |
---|
1373 | if ( pcDtParam->bApplyWeight ) |
---|
1374 | { |
---|
1375 | return xGetSADw( pcDtParam ); |
---|
1376 | } |
---|
1377 | Pel* piOrg = pcDtParam->pOrg; |
---|
1378 | Pel* piCur = pcDtParam->pCur; |
---|
1379 | Int iRows = pcDtParam->iRows; |
---|
1380 | Int iSubShift = pcDtParam->iSubShift; |
---|
1381 | Int iSubStep = ( 1 << iSubShift ); |
---|
1382 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
1383 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
1384 | |
---|
1385 | UInt uiSum = 0; |
---|
1386 | |
---|
1387 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
1388 | Int iDeltaC; |
---|
1389 | |
---|
1390 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1391 | { |
---|
1392 | iOrigAvg += piOrg[0]; |
---|
1393 | iOrigAvg += piOrg[1]; |
---|
1394 | iOrigAvg += piOrg[2]; |
---|
1395 | iOrigAvg += piOrg[3]; |
---|
1396 | iOrigAvg += piOrg[4]; |
---|
1397 | iOrigAvg += piOrg[5]; |
---|
1398 | iOrigAvg += piOrg[6]; |
---|
1399 | iOrigAvg += piOrg[7]; |
---|
1400 | iOrigAvg += piOrg[8]; |
---|
1401 | iOrigAvg += piOrg[9]; |
---|
1402 | iOrigAvg += piOrg[10]; |
---|
1403 | iOrigAvg += piOrg[11]; |
---|
1404 | iOrigAvg += piOrg[12]; |
---|
1405 | iOrigAvg += piOrg[13]; |
---|
1406 | iOrigAvg += piOrg[14]; |
---|
1407 | iOrigAvg += piOrg[15]; |
---|
1408 | |
---|
1409 | iCurAvg += piCur[0]; |
---|
1410 | iCurAvg += piCur[1]; |
---|
1411 | iCurAvg += piCur[2]; |
---|
1412 | iCurAvg += piCur[3]; |
---|
1413 | iCurAvg += piCur[4]; |
---|
1414 | iCurAvg += piCur[5]; |
---|
1415 | iCurAvg += piCur[6]; |
---|
1416 | iCurAvg += piCur[7]; |
---|
1417 | iCurAvg += piCur[8]; |
---|
1418 | iCurAvg += piCur[9]; |
---|
1419 | iCurAvg += piCur[10]; |
---|
1420 | iCurAvg += piCur[11]; |
---|
1421 | iCurAvg += piCur[12]; |
---|
1422 | iCurAvg += piCur[13]; |
---|
1423 | iCurAvg += piCur[14]; |
---|
1424 | iCurAvg += piCur[15]; |
---|
1425 | |
---|
1426 | piOrg += iStrideOrg; |
---|
1427 | piCur += iStrideCur; |
---|
1428 | uiRowCnt++; |
---|
1429 | } |
---|
1430 | |
---|
1431 | piOrg = pcDtParam->pOrg; |
---|
1432 | piCur = pcDtParam->pCur; |
---|
1433 | iRows = pcDtParam->iRows; |
---|
1434 | |
---|
1435 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/16) : 0; |
---|
1436 | |
---|
1437 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1438 | { |
---|
1439 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
1440 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
1441 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
1442 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
1443 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
1444 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
1445 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
1446 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
1447 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
1448 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
1449 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
1450 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
1451 | uiSum += abs( piOrg[12] - piCur[12] - iDeltaC ); |
---|
1452 | uiSum += abs( piOrg[13] - piCur[13] - iDeltaC ); |
---|
1453 | uiSum += abs( piOrg[14] - piCur[14] - iDeltaC ); |
---|
1454 | uiSum += abs( piOrg[15] - piCur[15] - iDeltaC ); |
---|
1455 | |
---|
1456 | piOrg += iStrideOrg; |
---|
1457 | piCur += iStrideCur; |
---|
1458 | } |
---|
1459 | |
---|
1460 | uiSum <<= iSubShift; |
---|
1461 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
1462 | } |
---|
1463 | |
---|
1464 | #if AMP_SAD |
---|
1465 | UInt TComRdCost::xGetSAD12ic( DistParam* pcDtParam ) |
---|
1466 | { |
---|
1467 | if ( pcDtParam->bApplyWeight ) |
---|
1468 | { |
---|
1469 | return xGetSADw( pcDtParam ); |
---|
1470 | } |
---|
1471 | Pel* piOrg = pcDtParam->pOrg; |
---|
1472 | Pel* piCur = pcDtParam->pCur; |
---|
1473 | Int iRows = pcDtParam->iRows; |
---|
1474 | Int iSubShift = pcDtParam->iSubShift; |
---|
1475 | Int iSubStep = ( 1 << iSubShift ); |
---|
1476 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
1477 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
1478 | |
---|
1479 | UInt uiSum = 0; |
---|
1480 | |
---|
1481 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
1482 | Int iDeltaC; |
---|
1483 | |
---|
1484 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1485 | { |
---|
1486 | iOrigAvg += piOrg[0]; |
---|
1487 | iOrigAvg += piOrg[1]; |
---|
1488 | iOrigAvg += piOrg[2]; |
---|
1489 | iOrigAvg += piOrg[3]; |
---|
1490 | iOrigAvg += piOrg[4]; |
---|
1491 | iOrigAvg += piOrg[5]; |
---|
1492 | iOrigAvg += piOrg[6]; |
---|
1493 | iOrigAvg += piOrg[7]; |
---|
1494 | iOrigAvg += piOrg[8]; |
---|
1495 | iOrigAvg += piOrg[9]; |
---|
1496 | iOrigAvg += piOrg[10]; |
---|
1497 | iOrigAvg += piOrg[11]; |
---|
1498 | |
---|
1499 | iCurAvg += piCur[0]; |
---|
1500 | iCurAvg += piCur[1]; |
---|
1501 | iCurAvg += piCur[2]; |
---|
1502 | iCurAvg += piCur[3]; |
---|
1503 | iCurAvg += piCur[4]; |
---|
1504 | iCurAvg += piCur[5]; |
---|
1505 | iCurAvg += piCur[6]; |
---|
1506 | iCurAvg += piCur[7]; |
---|
1507 | iCurAvg += piCur[8]; |
---|
1508 | iCurAvg += piCur[9]; |
---|
1509 | iCurAvg += piCur[10]; |
---|
1510 | iCurAvg += piCur[11]; |
---|
1511 | |
---|
1512 | piOrg += iStrideOrg; |
---|
1513 | piCur += iStrideCur; |
---|
1514 | uiRowCnt++; |
---|
1515 | } |
---|
1516 | |
---|
1517 | piOrg = pcDtParam->pOrg; |
---|
1518 | piCur = pcDtParam->pCur; |
---|
1519 | iRows = pcDtParam->iRows; |
---|
1520 | |
---|
1521 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/12) : 0; |
---|
1522 | |
---|
1523 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1524 | { |
---|
1525 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
1526 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
1527 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
1528 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
1529 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
1530 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
1531 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
1532 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
1533 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
1534 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
1535 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
1536 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
1537 | |
---|
1538 | piOrg += iStrideOrg; |
---|
1539 | piCur += iStrideCur; |
---|
1540 | } |
---|
1541 | |
---|
1542 | uiSum <<= iSubShift; |
---|
1543 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
1544 | } |
---|
1545 | #endif |
---|
1546 | |
---|
1547 | UInt TComRdCost::xGetSAD16Nic( DistParam* pcDtParam ) |
---|
1548 | { |
---|
1549 | Pel* piOrg = pcDtParam->pOrg; |
---|
1550 | Pel* piCur = pcDtParam->pCur; |
---|
1551 | Int iRows = pcDtParam->iRows; |
---|
1552 | Int iCols = pcDtParam->iCols; |
---|
1553 | Int iSubShift = pcDtParam->iSubShift; |
---|
1554 | Int iSubStep = ( 1 << iSubShift ); |
---|
1555 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
1556 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
1557 | |
---|
1558 | UInt uiSum = 0; |
---|
1559 | |
---|
1560 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0, uiColCnt = (iCols-1)/16 + 1; |
---|
1561 | Int iDeltaC; |
---|
1562 | |
---|
1563 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1564 | { |
---|
1565 | for (Int n = 0; n < iCols; n+=16 ) |
---|
1566 | { |
---|
1567 | iOrigAvg += piOrg[n + 0]; |
---|
1568 | iOrigAvg += piOrg[n + 1]; |
---|
1569 | iOrigAvg += piOrg[n + 2]; |
---|
1570 | iOrigAvg += piOrg[n + 3]; |
---|
1571 | iOrigAvg += piOrg[n + 4]; |
---|
1572 | iOrigAvg += piOrg[n + 5]; |
---|
1573 | iOrigAvg += piOrg[n + 6]; |
---|
1574 | iOrigAvg += piOrg[n + 7]; |
---|
1575 | iOrigAvg += piOrg[n + 8]; |
---|
1576 | iOrigAvg += piOrg[n + 9]; |
---|
1577 | iOrigAvg += piOrg[n + 10]; |
---|
1578 | iOrigAvg += piOrg[n + 11]; |
---|
1579 | iOrigAvg += piOrg[n + 12]; |
---|
1580 | iOrigAvg += piOrg[n + 13]; |
---|
1581 | iOrigAvg += piOrg[n + 14]; |
---|
1582 | iOrigAvg += piOrg[n + 15]; |
---|
1583 | |
---|
1584 | iCurAvg += piCur[n + 0]; |
---|
1585 | iCurAvg += piCur[n + 1]; |
---|
1586 | iCurAvg += piCur[n + 2]; |
---|
1587 | iCurAvg += piCur[n + 3]; |
---|
1588 | iCurAvg += piCur[n + 4]; |
---|
1589 | iCurAvg += piCur[n + 5]; |
---|
1590 | iCurAvg += piCur[n + 6]; |
---|
1591 | iCurAvg += piCur[n + 7]; |
---|
1592 | iCurAvg += piCur[n + 8]; |
---|
1593 | iCurAvg += piCur[n + 9]; |
---|
1594 | iCurAvg += piCur[n + 10]; |
---|
1595 | iCurAvg += piCur[n + 11]; |
---|
1596 | iCurAvg += piCur[n + 12]; |
---|
1597 | iCurAvg += piCur[n + 13]; |
---|
1598 | iCurAvg += piCur[n + 14]; |
---|
1599 | iCurAvg += piCur[n + 15]; |
---|
1600 | } |
---|
1601 | piOrg += iStrideOrg; |
---|
1602 | piCur += iStrideCur; |
---|
1603 | uiRowCnt++; |
---|
1604 | } |
---|
1605 | piOrg = pcDtParam->pOrg; |
---|
1606 | piCur = pcDtParam->pCur; |
---|
1607 | iRows = pcDtParam->iRows; |
---|
1608 | |
---|
1609 | iDeltaC = (uiRowCnt && uiColCnt) ? ((iOrigAvg - iCurAvg)/uiRowCnt/uiColCnt/16) : 0; |
---|
1610 | |
---|
1611 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1612 | { |
---|
1613 | for (Int n = 0; n < iCols; n+=16 ) |
---|
1614 | { |
---|
1615 | uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] - iDeltaC ); |
---|
1616 | uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] - iDeltaC ); |
---|
1617 | uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] - iDeltaC ); |
---|
1618 | uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] - iDeltaC ); |
---|
1619 | uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] - iDeltaC ); |
---|
1620 | uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] - iDeltaC ); |
---|
1621 | uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] - iDeltaC ); |
---|
1622 | uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] - iDeltaC ); |
---|
1623 | uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] - iDeltaC ); |
---|
1624 | uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] - iDeltaC ); |
---|
1625 | uiSum += abs( piOrg[n+10] - piCur[n+10] - iDeltaC ); |
---|
1626 | uiSum += abs( piOrg[n+11] - piCur[n+11] - iDeltaC ); |
---|
1627 | uiSum += abs( piOrg[n+12] - piCur[n+12] - iDeltaC ); |
---|
1628 | uiSum += abs( piOrg[n+13] - piCur[n+13] - iDeltaC ); |
---|
1629 | uiSum += abs( piOrg[n+14] - piCur[n+14] - iDeltaC ); |
---|
1630 | uiSum += abs( piOrg[n+15] - piCur[n+15] - iDeltaC ); |
---|
1631 | } |
---|
1632 | piOrg += iStrideOrg; |
---|
1633 | piCur += iStrideCur; |
---|
1634 | } |
---|
1635 | |
---|
1636 | uiSum <<= iSubShift; |
---|
1637 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
1638 | } |
---|
1639 | |
---|
1640 | UInt TComRdCost::xGetSAD32ic( DistParam* pcDtParam ) |
---|
1641 | { |
---|
1642 | if ( pcDtParam->bApplyWeight ) |
---|
1643 | { |
---|
1644 | return xGetSADw( pcDtParam ); |
---|
1645 | } |
---|
1646 | Pel* piOrg = pcDtParam->pOrg; |
---|
1647 | Pel* piCur = pcDtParam->pCur; |
---|
1648 | Int iRows = pcDtParam->iRows; |
---|
1649 | Int iSubShift = pcDtParam->iSubShift; |
---|
1650 | Int iSubStep = ( 1 << iSubShift ); |
---|
1651 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
1652 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
1653 | |
---|
1654 | UInt uiSum = 0; |
---|
1655 | |
---|
1656 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
1657 | Int iDeltaC; |
---|
1658 | |
---|
1659 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1660 | { |
---|
1661 | iOrigAvg += piOrg[0]; |
---|
1662 | iOrigAvg += piOrg[1]; |
---|
1663 | iOrigAvg += piOrg[2]; |
---|
1664 | iOrigAvg += piOrg[3]; |
---|
1665 | iOrigAvg += piOrg[4]; |
---|
1666 | iOrigAvg += piOrg[5]; |
---|
1667 | iOrigAvg += piOrg[6]; |
---|
1668 | iOrigAvg += piOrg[7]; |
---|
1669 | iOrigAvg += piOrg[8]; |
---|
1670 | iOrigAvg += piOrg[9]; |
---|
1671 | iOrigAvg += piOrg[10]; |
---|
1672 | iOrigAvg += piOrg[11]; |
---|
1673 | iOrigAvg += piOrg[12]; |
---|
1674 | iOrigAvg += piOrg[13]; |
---|
1675 | iOrigAvg += piOrg[14]; |
---|
1676 | iOrigAvg += piOrg[15]; |
---|
1677 | iOrigAvg += piOrg[16]; |
---|
1678 | iOrigAvg += piOrg[17]; |
---|
1679 | iOrigAvg += piOrg[18]; |
---|
1680 | iOrigAvg += piOrg[19]; |
---|
1681 | iOrigAvg += piOrg[20]; |
---|
1682 | iOrigAvg += piOrg[21]; |
---|
1683 | iOrigAvg += piOrg[22]; |
---|
1684 | iOrigAvg += piOrg[23]; |
---|
1685 | iOrigAvg += piOrg[24]; |
---|
1686 | iOrigAvg += piOrg[25]; |
---|
1687 | iOrigAvg += piOrg[26]; |
---|
1688 | iOrigAvg += piOrg[27]; |
---|
1689 | iOrigAvg += piOrg[28]; |
---|
1690 | iOrigAvg += piOrg[29]; |
---|
1691 | iOrigAvg += piOrg[30]; |
---|
1692 | iOrigAvg += piOrg[31]; |
---|
1693 | |
---|
1694 | iCurAvg += piCur[0]; |
---|
1695 | iCurAvg += piCur[1]; |
---|
1696 | iCurAvg += piCur[2]; |
---|
1697 | iCurAvg += piCur[3]; |
---|
1698 | iCurAvg += piCur[4]; |
---|
1699 | iCurAvg += piCur[5]; |
---|
1700 | iCurAvg += piCur[6]; |
---|
1701 | iCurAvg += piCur[7]; |
---|
1702 | iCurAvg += piCur[8]; |
---|
1703 | iCurAvg += piCur[9]; |
---|
1704 | iCurAvg += piCur[10]; |
---|
1705 | iCurAvg += piCur[11]; |
---|
1706 | iCurAvg += piCur[12]; |
---|
1707 | iCurAvg += piCur[13]; |
---|
1708 | iCurAvg += piCur[14]; |
---|
1709 | iCurAvg += piCur[15]; |
---|
1710 | iCurAvg += piCur[16]; |
---|
1711 | iCurAvg += piCur[17]; |
---|
1712 | iCurAvg += piCur[18]; |
---|
1713 | iCurAvg += piCur[19]; |
---|
1714 | iCurAvg += piCur[20]; |
---|
1715 | iCurAvg += piCur[21]; |
---|
1716 | iCurAvg += piCur[22]; |
---|
1717 | iCurAvg += piCur[23]; |
---|
1718 | iCurAvg += piCur[24]; |
---|
1719 | iCurAvg += piCur[25]; |
---|
1720 | iCurAvg += piCur[26]; |
---|
1721 | iCurAvg += piCur[27]; |
---|
1722 | iCurAvg += piCur[28]; |
---|
1723 | iCurAvg += piCur[29]; |
---|
1724 | iCurAvg += piCur[30]; |
---|
1725 | iCurAvg += piCur[31]; |
---|
1726 | |
---|
1727 | piOrg += iStrideOrg; |
---|
1728 | piCur += iStrideCur; |
---|
1729 | uiRowCnt++; |
---|
1730 | } |
---|
1731 | |
---|
1732 | piOrg = pcDtParam->pOrg; |
---|
1733 | piCur = pcDtParam->pCur; |
---|
1734 | iRows = pcDtParam->iRows; |
---|
1735 | |
---|
1736 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/32) : 0; |
---|
1737 | |
---|
1738 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1739 | { |
---|
1740 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
1741 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
1742 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
1743 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
1744 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
1745 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
1746 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
1747 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
1748 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
1749 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
1750 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
1751 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
1752 | uiSum += abs( piOrg[12] - piCur[12] - iDeltaC ); |
---|
1753 | uiSum += abs( piOrg[13] - piCur[13] - iDeltaC ); |
---|
1754 | uiSum += abs( piOrg[14] - piCur[14] - iDeltaC ); |
---|
1755 | uiSum += abs( piOrg[15] - piCur[15] - iDeltaC ); |
---|
1756 | uiSum += abs( piOrg[16] - piCur[16] - iDeltaC ); |
---|
1757 | uiSum += abs( piOrg[17] - piCur[17] - iDeltaC ); |
---|
1758 | uiSum += abs( piOrg[18] - piCur[18] - iDeltaC ); |
---|
1759 | uiSum += abs( piOrg[19] - piCur[19] - iDeltaC ); |
---|
1760 | uiSum += abs( piOrg[20] - piCur[20] - iDeltaC ); |
---|
1761 | uiSum += abs( piOrg[21] - piCur[21] - iDeltaC ); |
---|
1762 | uiSum += abs( piOrg[22] - piCur[22] - iDeltaC ); |
---|
1763 | uiSum += abs( piOrg[23] - piCur[23] - iDeltaC ); |
---|
1764 | uiSum += abs( piOrg[24] - piCur[24] - iDeltaC ); |
---|
1765 | uiSum += abs( piOrg[25] - piCur[25] - iDeltaC ); |
---|
1766 | uiSum += abs( piOrg[26] - piCur[26] - iDeltaC ); |
---|
1767 | uiSum += abs( piOrg[27] - piCur[27] - iDeltaC ); |
---|
1768 | uiSum += abs( piOrg[28] - piCur[28] - iDeltaC ); |
---|
1769 | uiSum += abs( piOrg[29] - piCur[29] - iDeltaC ); |
---|
1770 | uiSum += abs( piOrg[30] - piCur[30] - iDeltaC ); |
---|
1771 | uiSum += abs( piOrg[31] - piCur[31] - iDeltaC ); |
---|
1772 | |
---|
1773 | piOrg += iStrideOrg; |
---|
1774 | piCur += iStrideCur; |
---|
1775 | } |
---|
1776 | |
---|
1777 | uiSum <<= iSubShift; |
---|
1778 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
1779 | } |
---|
1780 | |
---|
1781 | #if AMP_SAD |
---|
1782 | UInt TComRdCost::xGetSAD24ic( DistParam* pcDtParam ) |
---|
1783 | { |
---|
1784 | if ( pcDtParam->bApplyWeight ) |
---|
1785 | { |
---|
1786 | return xGetSADw( pcDtParam ); |
---|
1787 | } |
---|
1788 | Pel* piOrg = pcDtParam->pOrg; |
---|
1789 | Pel* piCur = pcDtParam->pCur; |
---|
1790 | Int iRows = pcDtParam->iRows; |
---|
1791 | Int iSubShift = pcDtParam->iSubShift; |
---|
1792 | Int iSubStep = ( 1 << iSubShift ); |
---|
1793 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
1794 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
1795 | |
---|
1796 | UInt uiSum = 0; |
---|
1797 | |
---|
1798 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
1799 | Int iDeltaC; |
---|
1800 | |
---|
1801 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1802 | { |
---|
1803 | iOrigAvg += piOrg[0]; |
---|
1804 | iOrigAvg += piOrg[1]; |
---|
1805 | iOrigAvg += piOrg[2]; |
---|
1806 | iOrigAvg += piOrg[3]; |
---|
1807 | iOrigAvg += piOrg[4]; |
---|
1808 | iOrigAvg += piOrg[5]; |
---|
1809 | iOrigAvg += piOrg[6]; |
---|
1810 | iOrigAvg += piOrg[7]; |
---|
1811 | iOrigAvg += piOrg[8]; |
---|
1812 | iOrigAvg += piOrg[9]; |
---|
1813 | iOrigAvg += piOrg[10]; |
---|
1814 | iOrigAvg += piOrg[11]; |
---|
1815 | iOrigAvg += piOrg[12]; |
---|
1816 | iOrigAvg += piOrg[13]; |
---|
1817 | iOrigAvg += piOrg[14]; |
---|
1818 | iOrigAvg += piOrg[15]; |
---|
1819 | iOrigAvg += piOrg[16]; |
---|
1820 | iOrigAvg += piOrg[17]; |
---|
1821 | iOrigAvg += piOrg[18]; |
---|
1822 | iOrigAvg += piOrg[19]; |
---|
1823 | iOrigAvg += piOrg[20]; |
---|
1824 | iOrigAvg += piOrg[21]; |
---|
1825 | iOrigAvg += piOrg[22]; |
---|
1826 | iOrigAvg += piOrg[23]; |
---|
1827 | |
---|
1828 | iCurAvg += piCur[0]; |
---|
1829 | iCurAvg += piCur[1]; |
---|
1830 | iCurAvg += piCur[2]; |
---|
1831 | iCurAvg += piCur[3]; |
---|
1832 | iCurAvg += piCur[4]; |
---|
1833 | iCurAvg += piCur[5]; |
---|
1834 | iCurAvg += piCur[6]; |
---|
1835 | iCurAvg += piCur[7]; |
---|
1836 | iCurAvg += piCur[8]; |
---|
1837 | iCurAvg += piCur[9]; |
---|
1838 | iCurAvg += piCur[10]; |
---|
1839 | iCurAvg += piCur[11]; |
---|
1840 | iCurAvg += piCur[12]; |
---|
1841 | iCurAvg += piCur[13]; |
---|
1842 | iCurAvg += piCur[14]; |
---|
1843 | iCurAvg += piCur[15]; |
---|
1844 | iCurAvg += piCur[16]; |
---|
1845 | iCurAvg += piCur[17]; |
---|
1846 | iCurAvg += piCur[18]; |
---|
1847 | iCurAvg += piCur[19]; |
---|
1848 | iCurAvg += piCur[20]; |
---|
1849 | iCurAvg += piCur[21]; |
---|
1850 | iCurAvg += piCur[22]; |
---|
1851 | iCurAvg += piCur[23]; |
---|
1852 | |
---|
1853 | piOrg += iStrideOrg; |
---|
1854 | piCur += iStrideCur; |
---|
1855 | uiRowCnt++; |
---|
1856 | } |
---|
1857 | |
---|
1858 | piOrg = pcDtParam->pOrg; |
---|
1859 | piCur = pcDtParam->pCur; |
---|
1860 | iRows = pcDtParam->iRows; |
---|
1861 | |
---|
1862 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/24) : 0; |
---|
1863 | |
---|
1864 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1865 | { |
---|
1866 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
1867 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
1868 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
1869 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
1870 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
1871 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
1872 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
1873 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
1874 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
1875 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
1876 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
1877 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
1878 | uiSum += abs( piOrg[12] - piCur[12] - iDeltaC ); |
---|
1879 | uiSum += abs( piOrg[13] - piCur[13] - iDeltaC ); |
---|
1880 | uiSum += abs( piOrg[14] - piCur[14] - iDeltaC ); |
---|
1881 | uiSum += abs( piOrg[15] - piCur[15] - iDeltaC ); |
---|
1882 | uiSum += abs( piOrg[16] - piCur[16] - iDeltaC ); |
---|
1883 | uiSum += abs( piOrg[17] - piCur[17] - iDeltaC ); |
---|
1884 | uiSum += abs( piOrg[18] - piCur[18] - iDeltaC ); |
---|
1885 | uiSum += abs( piOrg[19] - piCur[19] - iDeltaC ); |
---|
1886 | uiSum += abs( piOrg[20] - piCur[20] - iDeltaC ); |
---|
1887 | uiSum += abs( piOrg[21] - piCur[21] - iDeltaC ); |
---|
1888 | uiSum += abs( piOrg[22] - piCur[22] - iDeltaC ); |
---|
1889 | uiSum += abs( piOrg[23] - piCur[23] - iDeltaC ); |
---|
1890 | |
---|
1891 | piOrg += iStrideOrg; |
---|
1892 | piCur += iStrideCur; |
---|
1893 | } |
---|
1894 | |
---|
1895 | uiSum <<= iSubShift; |
---|
1896 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
1897 | } |
---|
1898 | #endif |
---|
1899 | |
---|
1900 | UInt TComRdCost::xGetSAD64ic( DistParam* pcDtParam ) |
---|
1901 | { |
---|
1902 | if ( pcDtParam->bApplyWeight ) |
---|
1903 | { |
---|
1904 | return xGetSADw( pcDtParam ); |
---|
1905 | } |
---|
1906 | Pel* piOrg = pcDtParam->pOrg; |
---|
1907 | Pel* piCur = pcDtParam->pCur; |
---|
1908 | Int iRows = pcDtParam->iRows; |
---|
1909 | Int iSubShift = pcDtParam->iSubShift; |
---|
1910 | Int iSubStep = ( 1 << iSubShift ); |
---|
1911 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
1912 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
1913 | |
---|
1914 | UInt uiSum = 0; |
---|
1915 | |
---|
1916 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
1917 | Int iDeltaC; |
---|
1918 | |
---|
1919 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1920 | { |
---|
1921 | iOrigAvg += piOrg[0] ; |
---|
1922 | iOrigAvg += piOrg[1] ; |
---|
1923 | iOrigAvg += piOrg[2] ; |
---|
1924 | iOrigAvg += piOrg[3] ; |
---|
1925 | iOrigAvg += piOrg[4] ; |
---|
1926 | iOrigAvg += piOrg[5] ; |
---|
1927 | iOrigAvg += piOrg[6] ; |
---|
1928 | iOrigAvg += piOrg[7] ; |
---|
1929 | iOrigAvg += piOrg[8] ; |
---|
1930 | iOrigAvg += piOrg[9] ; |
---|
1931 | iOrigAvg += piOrg[10] ; |
---|
1932 | iOrigAvg += piOrg[11] ; |
---|
1933 | iOrigAvg += piOrg[12] ; |
---|
1934 | iOrigAvg += piOrg[13] ; |
---|
1935 | iOrigAvg += piOrg[14] ; |
---|
1936 | iOrigAvg += piOrg[15] ; |
---|
1937 | iOrigAvg += piOrg[16] ; |
---|
1938 | iOrigAvg += piOrg[17] ; |
---|
1939 | iOrigAvg += piOrg[18] ; |
---|
1940 | iOrigAvg += piOrg[19] ; |
---|
1941 | iOrigAvg += piOrg[20] ; |
---|
1942 | iOrigAvg += piOrg[21] ; |
---|
1943 | iOrigAvg += piOrg[22] ; |
---|
1944 | iOrigAvg += piOrg[23] ; |
---|
1945 | iOrigAvg += piOrg[24] ; |
---|
1946 | iOrigAvg += piOrg[25] ; |
---|
1947 | iOrigAvg += piOrg[26] ; |
---|
1948 | iOrigAvg += piOrg[27] ; |
---|
1949 | iOrigAvg += piOrg[28] ; |
---|
1950 | iOrigAvg += piOrg[29] ; |
---|
1951 | iOrigAvg += piOrg[30] ; |
---|
1952 | iOrigAvg += piOrg[31] ; |
---|
1953 | iOrigAvg += piOrg[32] ; |
---|
1954 | iOrigAvg += piOrg[33] ; |
---|
1955 | iOrigAvg += piOrg[34] ; |
---|
1956 | iOrigAvg += piOrg[35] ; |
---|
1957 | iOrigAvg += piOrg[36] ; |
---|
1958 | iOrigAvg += piOrg[37] ; |
---|
1959 | iOrigAvg += piOrg[38] ; |
---|
1960 | iOrigAvg += piOrg[39] ; |
---|
1961 | iOrigAvg += piOrg[40] ; |
---|
1962 | iOrigAvg += piOrg[41] ; |
---|
1963 | iOrigAvg += piOrg[42] ; |
---|
1964 | iOrigAvg += piOrg[43] ; |
---|
1965 | iOrigAvg += piOrg[44] ; |
---|
1966 | iOrigAvg += piOrg[45] ; |
---|
1967 | iOrigAvg += piOrg[46] ; |
---|
1968 | iOrigAvg += piOrg[47] ; |
---|
1969 | iOrigAvg += piOrg[48] ; |
---|
1970 | iOrigAvg += piOrg[49] ; |
---|
1971 | iOrigAvg += piOrg[50] ; |
---|
1972 | iOrigAvg += piOrg[51] ; |
---|
1973 | iOrigAvg += piOrg[52] ; |
---|
1974 | iOrigAvg += piOrg[53] ; |
---|
1975 | iOrigAvg += piOrg[54] ; |
---|
1976 | iOrigAvg += piOrg[55] ; |
---|
1977 | iOrigAvg += piOrg[56] ; |
---|
1978 | iOrigAvg += piOrg[57] ; |
---|
1979 | iOrigAvg += piOrg[58] ; |
---|
1980 | iOrigAvg += piOrg[59] ; |
---|
1981 | iOrigAvg += piOrg[60] ; |
---|
1982 | iOrigAvg += piOrg[61] ; |
---|
1983 | iOrigAvg += piOrg[62] ; |
---|
1984 | iOrigAvg += piOrg[63] ; |
---|
1985 | |
---|
1986 | iCurAvg += piCur[0] ; |
---|
1987 | iCurAvg += piCur[1] ; |
---|
1988 | iCurAvg += piCur[2] ; |
---|
1989 | iCurAvg += piCur[3] ; |
---|
1990 | iCurAvg += piCur[4] ; |
---|
1991 | iCurAvg += piCur[5] ; |
---|
1992 | iCurAvg += piCur[6] ; |
---|
1993 | iCurAvg += piCur[7] ; |
---|
1994 | iCurAvg += piCur[8] ; |
---|
1995 | iCurAvg += piCur[9] ; |
---|
1996 | iCurAvg += piCur[10] ; |
---|
1997 | iCurAvg += piCur[11] ; |
---|
1998 | iCurAvg += piCur[12] ; |
---|
1999 | iCurAvg += piCur[13] ; |
---|
2000 | iCurAvg += piCur[14] ; |
---|
2001 | iCurAvg += piCur[15] ; |
---|
2002 | iCurAvg += piCur[16] ; |
---|
2003 | iCurAvg += piCur[17] ; |
---|
2004 | iCurAvg += piCur[18] ; |
---|
2005 | iCurAvg += piCur[19] ; |
---|
2006 | iCurAvg += piCur[20] ; |
---|
2007 | iCurAvg += piCur[21] ; |
---|
2008 | iCurAvg += piCur[22] ; |
---|
2009 | iCurAvg += piCur[23] ; |
---|
2010 | iCurAvg += piCur[24] ; |
---|
2011 | iCurAvg += piCur[25] ; |
---|
2012 | iCurAvg += piCur[26] ; |
---|
2013 | iCurAvg += piCur[27] ; |
---|
2014 | iCurAvg += piCur[28] ; |
---|
2015 | iCurAvg += piCur[29] ; |
---|
2016 | iCurAvg += piCur[30] ; |
---|
2017 | iCurAvg += piCur[31] ; |
---|
2018 | iCurAvg += piCur[32] ; |
---|
2019 | iCurAvg += piCur[33] ; |
---|
2020 | iCurAvg += piCur[34] ; |
---|
2021 | iCurAvg += piCur[35] ; |
---|
2022 | iCurAvg += piCur[36] ; |
---|
2023 | iCurAvg += piCur[37] ; |
---|
2024 | iCurAvg += piCur[38] ; |
---|
2025 | iCurAvg += piCur[39] ; |
---|
2026 | iCurAvg += piCur[40] ; |
---|
2027 | iCurAvg += piCur[41] ; |
---|
2028 | iCurAvg += piCur[42] ; |
---|
2029 | iCurAvg += piCur[43] ; |
---|
2030 | iCurAvg += piCur[44] ; |
---|
2031 | iCurAvg += piCur[45] ; |
---|
2032 | iCurAvg += piCur[46] ; |
---|
2033 | iCurAvg += piCur[47] ; |
---|
2034 | iCurAvg += piCur[48] ; |
---|
2035 | iCurAvg += piCur[49] ; |
---|
2036 | iCurAvg += piCur[50] ; |
---|
2037 | iCurAvg += piCur[51] ; |
---|
2038 | iCurAvg += piCur[52] ; |
---|
2039 | iCurAvg += piCur[53] ; |
---|
2040 | iCurAvg += piCur[54] ; |
---|
2041 | iCurAvg += piCur[55] ; |
---|
2042 | iCurAvg += piCur[56] ; |
---|
2043 | iCurAvg += piCur[57] ; |
---|
2044 | iCurAvg += piCur[58] ; |
---|
2045 | iCurAvg += piCur[59] ; |
---|
2046 | iCurAvg += piCur[60] ; |
---|
2047 | iCurAvg += piCur[61] ; |
---|
2048 | iCurAvg += piCur[62] ; |
---|
2049 | iCurAvg += piCur[63] ; |
---|
2050 | |
---|
2051 | piOrg += iStrideOrg; |
---|
2052 | piCur += iStrideCur; |
---|
2053 | uiRowCnt++; |
---|
2054 | } |
---|
2055 | |
---|
2056 | piOrg = pcDtParam->pOrg; |
---|
2057 | piCur = pcDtParam->pCur; |
---|
2058 | iRows = pcDtParam->iRows; |
---|
2059 | |
---|
2060 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/64) : 0; |
---|
2061 | |
---|
2062 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
2063 | { |
---|
2064 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
2065 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
2066 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
2067 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
2068 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
2069 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
2070 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
2071 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
2072 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
2073 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
2074 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
2075 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
2076 | uiSum += abs( piOrg[12] - piCur[12] - iDeltaC ); |
---|
2077 | uiSum += abs( piOrg[13] - piCur[13] - iDeltaC ); |
---|
2078 | uiSum += abs( piOrg[14] - piCur[14] - iDeltaC ); |
---|
2079 | uiSum += abs( piOrg[15] - piCur[15] - iDeltaC ); |
---|
2080 | uiSum += abs( piOrg[16] - piCur[16] - iDeltaC ); |
---|
2081 | uiSum += abs( piOrg[17] - piCur[17] - iDeltaC ); |
---|
2082 | uiSum += abs( piOrg[18] - piCur[18] - iDeltaC ); |
---|
2083 | uiSum += abs( piOrg[19] - piCur[19] - iDeltaC ); |
---|
2084 | uiSum += abs( piOrg[20] - piCur[20] - iDeltaC ); |
---|
2085 | uiSum += abs( piOrg[21] - piCur[21] - iDeltaC ); |
---|
2086 | uiSum += abs( piOrg[22] - piCur[22] - iDeltaC ); |
---|
2087 | uiSum += abs( piOrg[23] - piCur[23] - iDeltaC ); |
---|
2088 | uiSum += abs( piOrg[24] - piCur[24] - iDeltaC ); |
---|
2089 | uiSum += abs( piOrg[25] - piCur[25] - iDeltaC ); |
---|
2090 | uiSum += abs( piOrg[26] - piCur[26] - iDeltaC ); |
---|
2091 | uiSum += abs( piOrg[27] - piCur[27] - iDeltaC ); |
---|
2092 | uiSum += abs( piOrg[28] - piCur[28] - iDeltaC ); |
---|
2093 | uiSum += abs( piOrg[29] - piCur[29] - iDeltaC ); |
---|
2094 | uiSum += abs( piOrg[30] - piCur[30] - iDeltaC ); |
---|
2095 | uiSum += abs( piOrg[31] - piCur[31] - iDeltaC ); |
---|
2096 | uiSum += abs( piOrg[32] - piCur[32] - iDeltaC ); |
---|
2097 | uiSum += abs( piOrg[33] - piCur[33] - iDeltaC ); |
---|
2098 | uiSum += abs( piOrg[34] - piCur[34] - iDeltaC ); |
---|
2099 | uiSum += abs( piOrg[35] - piCur[35] - iDeltaC ); |
---|
2100 | uiSum += abs( piOrg[36] - piCur[36] - iDeltaC ); |
---|
2101 | uiSum += abs( piOrg[37] - piCur[37] - iDeltaC ); |
---|
2102 | uiSum += abs( piOrg[38] - piCur[38] - iDeltaC ); |
---|
2103 | uiSum += abs( piOrg[39] - piCur[39] - iDeltaC ); |
---|
2104 | uiSum += abs( piOrg[40] - piCur[40] - iDeltaC ); |
---|
2105 | uiSum += abs( piOrg[41] - piCur[41] - iDeltaC ); |
---|
2106 | uiSum += abs( piOrg[42] - piCur[42] - iDeltaC ); |
---|
2107 | uiSum += abs( piOrg[43] - piCur[43] - iDeltaC ); |
---|
2108 | uiSum += abs( piOrg[44] - piCur[44] - iDeltaC ); |
---|
2109 | uiSum += abs( piOrg[45] - piCur[45] - iDeltaC ); |
---|
2110 | uiSum += abs( piOrg[46] - piCur[46] - iDeltaC ); |
---|
2111 | uiSum += abs( piOrg[47] - piCur[47] - iDeltaC ); |
---|
2112 | uiSum += abs( piOrg[48] - piCur[48] - iDeltaC ); |
---|
2113 | uiSum += abs( piOrg[49] - piCur[49] - iDeltaC ); |
---|
2114 | uiSum += abs( piOrg[50] - piCur[50] - iDeltaC ); |
---|
2115 | uiSum += abs( piOrg[51] - piCur[51] - iDeltaC ); |
---|
2116 | uiSum += abs( piOrg[52] - piCur[52] - iDeltaC ); |
---|
2117 | uiSum += abs( piOrg[53] - piCur[53] - iDeltaC ); |
---|
2118 | uiSum += abs( piOrg[54] - piCur[54] - iDeltaC ); |
---|
2119 | uiSum += abs( piOrg[55] - piCur[55] - iDeltaC ); |
---|
2120 | uiSum += abs( piOrg[56] - piCur[56] - iDeltaC ); |
---|
2121 | uiSum += abs( piOrg[57] - piCur[57] - iDeltaC ); |
---|
2122 | uiSum += abs( piOrg[58] - piCur[58] - iDeltaC ); |
---|
2123 | uiSum += abs( piOrg[59] - piCur[59] - iDeltaC ); |
---|
2124 | uiSum += abs( piOrg[60] - piCur[60] - iDeltaC ); |
---|
2125 | uiSum += abs( piOrg[61] - piCur[61] - iDeltaC ); |
---|
2126 | uiSum += abs( piOrg[62] - piCur[62] - iDeltaC ); |
---|
2127 | uiSum += abs( piOrg[63] - piCur[63] - iDeltaC ); |
---|
2128 | |
---|
2129 | piOrg += iStrideOrg; |
---|
2130 | piCur += iStrideCur; |
---|
2131 | } |
---|
2132 | |
---|
2133 | uiSum <<= iSubShift; |
---|
2134 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
2135 | } |
---|
2136 | |
---|
2137 | #if AMP_SAD |
---|
2138 | UInt TComRdCost::xGetSAD48ic( DistParam* pcDtParam ) |
---|
2139 | { |
---|
2140 | if ( pcDtParam->bApplyWeight ) |
---|
2141 | { |
---|
2142 | return xGetSADw( pcDtParam ); |
---|
2143 | } |
---|
2144 | |
---|
2145 | Pel* piOrg = pcDtParam->pOrg; |
---|
2146 | Pel* piCur = pcDtParam->pCur; |
---|
2147 | Int iRows = pcDtParam->iRows; |
---|
2148 | Int iSubShift = pcDtParam->iSubShift; |
---|
2149 | Int iSubStep = ( 1 << iSubShift ); |
---|
2150 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
2151 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
2152 | |
---|
2153 | UInt uiSum = 0; |
---|
2154 | |
---|
2155 | Int iOrigAvg = 0, iCurAvg = 0, uiRowCnt = 0; |
---|
2156 | Int iDeltaC; |
---|
2157 | |
---|
2158 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
2159 | { |
---|
2160 | iOrigAvg += piOrg[0] ; |
---|
2161 | iOrigAvg += piOrg[1] ; |
---|
2162 | iOrigAvg += piOrg[2] ; |
---|
2163 | iOrigAvg += piOrg[3] ; |
---|
2164 | iOrigAvg += piOrg[4] ; |
---|
2165 | iOrigAvg += piOrg[5] ; |
---|
2166 | iOrigAvg += piOrg[6] ; |
---|
2167 | iOrigAvg += piOrg[7] ; |
---|
2168 | iOrigAvg += piOrg[8] ; |
---|
2169 | iOrigAvg += piOrg[9] ; |
---|
2170 | iOrigAvg += piOrg[10] ; |
---|
2171 | iOrigAvg += piOrg[11] ; |
---|
2172 | iOrigAvg += piOrg[12] ; |
---|
2173 | iOrigAvg += piOrg[13] ; |
---|
2174 | iOrigAvg += piOrg[14] ; |
---|
2175 | iOrigAvg += piOrg[15] ; |
---|
2176 | iOrigAvg += piOrg[16] ; |
---|
2177 | iOrigAvg += piOrg[17] ; |
---|
2178 | iOrigAvg += piOrg[18] ; |
---|
2179 | iOrigAvg += piOrg[19] ; |
---|
2180 | iOrigAvg += piOrg[20] ; |
---|
2181 | iOrigAvg += piOrg[21] ; |
---|
2182 | iOrigAvg += piOrg[22] ; |
---|
2183 | iOrigAvg += piOrg[23] ; |
---|
2184 | iOrigAvg += piOrg[24] ; |
---|
2185 | iOrigAvg += piOrg[25] ; |
---|
2186 | iOrigAvg += piOrg[26] ; |
---|
2187 | iOrigAvg += piOrg[27] ; |
---|
2188 | iOrigAvg += piOrg[28] ; |
---|
2189 | iOrigAvg += piOrg[29] ; |
---|
2190 | iOrigAvg += piOrg[30] ; |
---|
2191 | iOrigAvg += piOrg[31] ; |
---|
2192 | iOrigAvg += piOrg[32] ; |
---|
2193 | iOrigAvg += piOrg[33] ; |
---|
2194 | iOrigAvg += piOrg[34] ; |
---|
2195 | iOrigAvg += piOrg[35] ; |
---|
2196 | iOrigAvg += piOrg[36] ; |
---|
2197 | iOrigAvg += piOrg[37] ; |
---|
2198 | iOrigAvg += piOrg[38] ; |
---|
2199 | iOrigAvg += piOrg[39] ; |
---|
2200 | iOrigAvg += piOrg[40] ; |
---|
2201 | iOrigAvg += piOrg[41] ; |
---|
2202 | iOrigAvg += piOrg[42] ; |
---|
2203 | iOrigAvg += piOrg[43] ; |
---|
2204 | iOrigAvg += piOrg[44] ; |
---|
2205 | iOrigAvg += piOrg[45] ; |
---|
2206 | iOrigAvg += piOrg[46] ; |
---|
2207 | iOrigAvg += piOrg[47] ; |
---|
2208 | |
---|
2209 | iCurAvg += piCur[0] ; |
---|
2210 | iCurAvg += piCur[1] ; |
---|
2211 | iCurAvg += piCur[2] ; |
---|
2212 | iCurAvg += piCur[3] ; |
---|
2213 | iCurAvg += piCur[4] ; |
---|
2214 | iCurAvg += piCur[5] ; |
---|
2215 | iCurAvg += piCur[6] ; |
---|
2216 | iCurAvg += piCur[7] ; |
---|
2217 | iCurAvg += piCur[8] ; |
---|
2218 | iCurAvg += piCur[9] ; |
---|
2219 | iCurAvg += piCur[10] ; |
---|
2220 | iCurAvg += piCur[11] ; |
---|
2221 | iCurAvg += piCur[12] ; |
---|
2222 | iCurAvg += piCur[13] ; |
---|
2223 | iCurAvg += piCur[14] ; |
---|
2224 | iCurAvg += piCur[15] ; |
---|
2225 | iCurAvg += piCur[16] ; |
---|
2226 | iCurAvg += piCur[17] ; |
---|
2227 | iCurAvg += piCur[18] ; |
---|
2228 | iCurAvg += piCur[19] ; |
---|
2229 | iCurAvg += piCur[20] ; |
---|
2230 | iCurAvg += piCur[21] ; |
---|
2231 | iCurAvg += piCur[22] ; |
---|
2232 | iCurAvg += piCur[23] ; |
---|
2233 | iCurAvg += piCur[24] ; |
---|
2234 | iCurAvg += piCur[25] ; |
---|
2235 | iCurAvg += piCur[26] ; |
---|
2236 | iCurAvg += piCur[27] ; |
---|
2237 | iCurAvg += piCur[28] ; |
---|
2238 | iCurAvg += piCur[29] ; |
---|
2239 | iCurAvg += piCur[30] ; |
---|
2240 | iCurAvg += piCur[31] ; |
---|
2241 | iCurAvg += piCur[32] ; |
---|
2242 | iCurAvg += piCur[33] ; |
---|
2243 | iCurAvg += piCur[34] ; |
---|
2244 | iCurAvg += piCur[35] ; |
---|
2245 | iCurAvg += piCur[36] ; |
---|
2246 | iCurAvg += piCur[37] ; |
---|
2247 | iCurAvg += piCur[38] ; |
---|
2248 | iCurAvg += piCur[39] ; |
---|
2249 | iCurAvg += piCur[40] ; |
---|
2250 | iCurAvg += piCur[41] ; |
---|
2251 | iCurAvg += piCur[42] ; |
---|
2252 | iCurAvg += piCur[43] ; |
---|
2253 | iCurAvg += piCur[44] ; |
---|
2254 | iCurAvg += piCur[45] ; |
---|
2255 | iCurAvg += piCur[46] ; |
---|
2256 | iCurAvg += piCur[47] ; |
---|
2257 | |
---|
2258 | piOrg += iStrideOrg; |
---|
2259 | piCur += iStrideCur; |
---|
2260 | uiRowCnt++; |
---|
2261 | } |
---|
2262 | |
---|
2263 | piOrg = pcDtParam->pOrg; |
---|
2264 | piCur = pcDtParam->pCur; |
---|
2265 | iRows = pcDtParam->iRows; |
---|
2266 | |
---|
2267 | iDeltaC = uiRowCnt ? ((iOrigAvg - iCurAvg)/uiRowCnt/48) : 0; |
---|
2268 | |
---|
2269 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
2270 | { |
---|
2271 | uiSum += abs( piOrg[0] - piCur[0] - iDeltaC ); |
---|
2272 | uiSum += abs( piOrg[1] - piCur[1] - iDeltaC ); |
---|
2273 | uiSum += abs( piOrg[2] - piCur[2] - iDeltaC ); |
---|
2274 | uiSum += abs( piOrg[3] - piCur[3] - iDeltaC ); |
---|
2275 | uiSum += abs( piOrg[4] - piCur[4] - iDeltaC ); |
---|
2276 | uiSum += abs( piOrg[5] - piCur[5] - iDeltaC ); |
---|
2277 | uiSum += abs( piOrg[6] - piCur[6] - iDeltaC ); |
---|
2278 | uiSum += abs( piOrg[7] - piCur[7] - iDeltaC ); |
---|
2279 | uiSum += abs( piOrg[8] - piCur[8] - iDeltaC ); |
---|
2280 | uiSum += abs( piOrg[9] - piCur[9] - iDeltaC ); |
---|
2281 | uiSum += abs( piOrg[10] - piCur[10] - iDeltaC ); |
---|
2282 | uiSum += abs( piOrg[11] - piCur[11] - iDeltaC ); |
---|
2283 | uiSum += abs( piOrg[12] - piCur[12] - iDeltaC ); |
---|
2284 | uiSum += abs( piOrg[13] - piCur[13] - iDeltaC ); |
---|
2285 | uiSum += abs( piOrg[14] - piCur[14] - iDeltaC ); |
---|
2286 | uiSum += abs( piOrg[15] - piCur[15] - iDeltaC ); |
---|
2287 | uiSum += abs( piOrg[16] - piCur[16] - iDeltaC ); |
---|
2288 | uiSum += abs( piOrg[17] - piCur[17] - iDeltaC ); |
---|
2289 | uiSum += abs( piOrg[18] - piCur[18] - iDeltaC ); |
---|
2290 | uiSum += abs( piOrg[19] - piCur[19] - iDeltaC ); |
---|
2291 | uiSum += abs( piOrg[20] - piCur[20] - iDeltaC ); |
---|
2292 | uiSum += abs( piOrg[21] - piCur[21] - iDeltaC ); |
---|
2293 | uiSum += abs( piOrg[22] - piCur[22] - iDeltaC ); |
---|
2294 | uiSum += abs( piOrg[23] - piCur[23] - iDeltaC ); |
---|
2295 | uiSum += abs( piOrg[24] - piCur[24] - iDeltaC ); |
---|
2296 | uiSum += abs( piOrg[25] - piCur[25] - iDeltaC ); |
---|
2297 | uiSum += abs( piOrg[26] - piCur[26] - iDeltaC ); |
---|
2298 | uiSum += abs( piOrg[27] - piCur[27] - iDeltaC ); |
---|
2299 | uiSum += abs( piOrg[28] - piCur[28] - iDeltaC ); |
---|
2300 | uiSum += abs( piOrg[29] - piCur[29] - iDeltaC ); |
---|
2301 | uiSum += abs( piOrg[30] - piCur[30] - iDeltaC ); |
---|
2302 | uiSum += abs( piOrg[31] - piCur[31] - iDeltaC ); |
---|
2303 | uiSum += abs( piOrg[32] - piCur[32] - iDeltaC ); |
---|
2304 | uiSum += abs( piOrg[33] - piCur[33] - iDeltaC ); |
---|
2305 | uiSum += abs( piOrg[34] - piCur[34] - iDeltaC ); |
---|
2306 | uiSum += abs( piOrg[35] - piCur[35] - iDeltaC ); |
---|
2307 | uiSum += abs( piOrg[36] - piCur[36] - iDeltaC ); |
---|
2308 | uiSum += abs( piOrg[37] - piCur[37] - iDeltaC ); |
---|
2309 | uiSum += abs( piOrg[38] - piCur[38] - iDeltaC ); |
---|
2310 | uiSum += abs( piOrg[39] - piCur[39] - iDeltaC ); |
---|
2311 | uiSum += abs( piOrg[40] - piCur[40] - iDeltaC ); |
---|
2312 | uiSum += abs( piOrg[41] - piCur[41] - iDeltaC ); |
---|
2313 | uiSum += abs( piOrg[42] - piCur[42] - iDeltaC ); |
---|
2314 | uiSum += abs( piOrg[43] - piCur[43] - iDeltaC ); |
---|
2315 | uiSum += abs( piOrg[44] - piCur[44] - iDeltaC ); |
---|
2316 | uiSum += abs( piOrg[45] - piCur[45] - iDeltaC ); |
---|
2317 | uiSum += abs( piOrg[46] - piCur[46] - iDeltaC ); |
---|
2318 | uiSum += abs( piOrg[47] - piCur[47] - iDeltaC ); |
---|
2319 | |
---|
2320 | piOrg += iStrideOrg; |
---|
2321 | piCur += iStrideCur; |
---|
2322 | } |
---|
2323 | |
---|
2324 | uiSum <<= iSubShift; |
---|
2325 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
2326 | } |
---|
2327 | #endif |
---|
2328 | |
---|
2329 | #endif |
---|
2330 | // -------------------------------------------------------------------------------------------------------------------- |
---|
2331 | // SSE |
---|
2332 | // -------------------------------------------------------------------------------------------------------------------- |
---|
2333 | |
---|
2334 | UInt TComRdCost::xGetSSE( DistParam* pcDtParam ) |
---|
2335 | { |
---|
2336 | if ( pcDtParam->bApplyWeight ) |
---|
2337 | { |
---|
2338 | return xGetSSEw( pcDtParam ); |
---|
2339 | } |
---|
2340 | Pel* piOrg = pcDtParam->pOrg; |
---|
2341 | Pel* piCur = pcDtParam->pCur; |
---|
2342 | Int iRows = pcDtParam->iRows; |
---|
2343 | Int iCols = pcDtParam->iCols; |
---|
2344 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2345 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2346 | |
---|
2347 | UInt uiSum = 0; |
---|
2348 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
2349 | |
---|
2350 | Int iTemp; |
---|
2351 | |
---|
2352 | for( ; iRows != 0; iRows-- ) |
---|
2353 | { |
---|
2354 | for (Int n = 0; n < iCols; n++ ) |
---|
2355 | { |
---|
2356 | iTemp = piOrg[n ] - piCur[n ]; |
---|
2357 | uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2358 | } |
---|
2359 | piOrg += iStrideOrg; |
---|
2360 | piCur += iStrideCur; |
---|
2361 | } |
---|
2362 | |
---|
2363 | return ( uiSum ); |
---|
2364 | } |
---|
2365 | |
---|
2366 | UInt TComRdCost::xGetSSE4( DistParam* pcDtParam ) |
---|
2367 | { |
---|
2368 | if ( pcDtParam->bApplyWeight ) |
---|
2369 | { |
---|
2370 | assert( pcDtParam->iCols == 4 ); |
---|
2371 | return xGetSSEw( pcDtParam ); |
---|
2372 | } |
---|
2373 | Pel* piOrg = pcDtParam->pOrg; |
---|
2374 | Pel* piCur = pcDtParam->pCur; |
---|
2375 | Int iRows = pcDtParam->iRows; |
---|
2376 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2377 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2378 | |
---|
2379 | UInt uiSum = 0; |
---|
2380 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
2381 | |
---|
2382 | Int iTemp; |
---|
2383 | |
---|
2384 | for( ; iRows != 0; iRows-- ) |
---|
2385 | { |
---|
2386 | |
---|
2387 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2388 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2389 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2390 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2391 | |
---|
2392 | piOrg += iStrideOrg; |
---|
2393 | piCur += iStrideCur; |
---|
2394 | } |
---|
2395 | |
---|
2396 | return ( uiSum ); |
---|
2397 | } |
---|
2398 | |
---|
2399 | UInt TComRdCost::xGetSSE8( DistParam* pcDtParam ) |
---|
2400 | { |
---|
2401 | if ( pcDtParam->bApplyWeight ) |
---|
2402 | { |
---|
2403 | assert( pcDtParam->iCols == 8 ); |
---|
2404 | return xGetSSEw( pcDtParam ); |
---|
2405 | } |
---|
2406 | Pel* piOrg = pcDtParam->pOrg; |
---|
2407 | Pel* piCur = pcDtParam->pCur; |
---|
2408 | Int iRows = pcDtParam->iRows; |
---|
2409 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2410 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2411 | |
---|
2412 | UInt uiSum = 0; |
---|
2413 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
2414 | |
---|
2415 | Int iTemp; |
---|
2416 | |
---|
2417 | for( ; iRows != 0; iRows-- ) |
---|
2418 | { |
---|
2419 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2420 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2421 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2422 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2423 | iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2424 | iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2425 | iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2426 | iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2427 | |
---|
2428 | piOrg += iStrideOrg; |
---|
2429 | piCur += iStrideCur; |
---|
2430 | } |
---|
2431 | |
---|
2432 | return ( uiSum ); |
---|
2433 | } |
---|
2434 | |
---|
2435 | UInt TComRdCost::xGetSSE16( DistParam* pcDtParam ) |
---|
2436 | { |
---|
2437 | if ( pcDtParam->bApplyWeight ) |
---|
2438 | { |
---|
2439 | assert( pcDtParam->iCols == 16 ); |
---|
2440 | return xGetSSEw( pcDtParam ); |
---|
2441 | } |
---|
2442 | Pel* piOrg = pcDtParam->pOrg; |
---|
2443 | Pel* piCur = pcDtParam->pCur; |
---|
2444 | Int iRows = pcDtParam->iRows; |
---|
2445 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2446 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2447 | |
---|
2448 | UInt uiSum = 0; |
---|
2449 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
2450 | |
---|
2451 | Int iTemp; |
---|
2452 | |
---|
2453 | for( ; iRows != 0; iRows-- ) |
---|
2454 | { |
---|
2455 | |
---|
2456 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2457 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2458 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2459 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2460 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2461 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2462 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2463 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2464 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2465 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2466 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2467 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2468 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2469 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2470 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2471 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2472 | |
---|
2473 | piOrg += iStrideOrg; |
---|
2474 | piCur += iStrideCur; |
---|
2475 | } |
---|
2476 | |
---|
2477 | return ( uiSum ); |
---|
2478 | } |
---|
2479 | |
---|
2480 | UInt TComRdCost::xGetSSE16N( DistParam* pcDtParam ) |
---|
2481 | { |
---|
2482 | if ( pcDtParam->bApplyWeight ) |
---|
2483 | { |
---|
2484 | return xGetSSEw( pcDtParam ); |
---|
2485 | } |
---|
2486 | Pel* piOrg = pcDtParam->pOrg; |
---|
2487 | Pel* piCur = pcDtParam->pCur; |
---|
2488 | Int iRows = pcDtParam->iRows; |
---|
2489 | Int iCols = pcDtParam->iCols; |
---|
2490 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2491 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2492 | |
---|
2493 | UInt uiSum = 0; |
---|
2494 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
2495 | Int iTemp; |
---|
2496 | |
---|
2497 | for( ; iRows != 0; iRows-- ) |
---|
2498 | { |
---|
2499 | for (Int n = 0; n < iCols; n+=16 ) |
---|
2500 | { |
---|
2501 | |
---|
2502 | iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2503 | iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2504 | iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2505 | iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2506 | iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2507 | iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2508 | iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2509 | iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2510 | iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2511 | iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2512 | iTemp = piOrg[n+10] - piCur[n+10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2513 | iTemp = piOrg[n+11] - piCur[n+11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2514 | iTemp = piOrg[n+12] - piCur[n+12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2515 | iTemp = piOrg[n+13] - piCur[n+13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2516 | iTemp = piOrg[n+14] - piCur[n+14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2517 | iTemp = piOrg[n+15] - piCur[n+15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2518 | |
---|
2519 | } |
---|
2520 | piOrg += iStrideOrg; |
---|
2521 | piCur += iStrideCur; |
---|
2522 | } |
---|
2523 | |
---|
2524 | return ( uiSum ); |
---|
2525 | } |
---|
2526 | |
---|
2527 | UInt TComRdCost::xGetSSE32( DistParam* pcDtParam ) |
---|
2528 | { |
---|
2529 | if ( pcDtParam->bApplyWeight ) |
---|
2530 | { |
---|
2531 | assert( pcDtParam->iCols == 32 ); |
---|
2532 | return xGetSSEw( pcDtParam ); |
---|
2533 | } |
---|
2534 | Pel* piOrg = pcDtParam->pOrg; |
---|
2535 | Pel* piCur = pcDtParam->pCur; |
---|
2536 | Int iRows = pcDtParam->iRows; |
---|
2537 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2538 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2539 | |
---|
2540 | UInt uiSum = 0; |
---|
2541 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
2542 | Int iTemp; |
---|
2543 | |
---|
2544 | for( ; iRows != 0; iRows-- ) |
---|
2545 | { |
---|
2546 | |
---|
2547 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2548 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2549 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2550 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2551 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2552 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2553 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2554 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2555 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2556 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2557 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2558 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2559 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2560 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2561 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2562 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2563 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2564 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2565 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2566 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2567 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2568 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2569 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2570 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2571 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2572 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2573 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2574 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2575 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2576 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2577 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2578 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2579 | |
---|
2580 | piOrg += iStrideOrg; |
---|
2581 | piCur += iStrideCur; |
---|
2582 | } |
---|
2583 | |
---|
2584 | return ( uiSum ); |
---|
2585 | } |
---|
2586 | |
---|
2587 | UInt TComRdCost::xGetSSE64( DistParam* pcDtParam ) |
---|
2588 | { |
---|
2589 | if ( pcDtParam->bApplyWeight ) |
---|
2590 | { |
---|
2591 | assert( pcDtParam->iCols == 64 ); |
---|
2592 | return xGetSSEw( pcDtParam ); |
---|
2593 | } |
---|
2594 | Pel* piOrg = pcDtParam->pOrg; |
---|
2595 | Pel* piCur = pcDtParam->pCur; |
---|
2596 | Int iRows = pcDtParam->iRows; |
---|
2597 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2598 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2599 | |
---|
2600 | UInt uiSum = 0; |
---|
2601 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
2602 | Int iTemp; |
---|
2603 | |
---|
2604 | for( ; iRows != 0; iRows-- ) |
---|
2605 | { |
---|
2606 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2607 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2608 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2609 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2610 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2611 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2612 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2613 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2614 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2615 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2616 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2617 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2618 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2619 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2620 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2621 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2622 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2623 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2624 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2625 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2626 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2627 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2628 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2629 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2630 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2631 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2632 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2633 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2634 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2635 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2636 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2637 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2638 | iTemp = piOrg[32] - piCur[32]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2639 | iTemp = piOrg[33] - piCur[33]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2640 | iTemp = piOrg[34] - piCur[34]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2641 | iTemp = piOrg[35] - piCur[35]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2642 | iTemp = piOrg[36] - piCur[36]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2643 | iTemp = piOrg[37] - piCur[37]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2644 | iTemp = piOrg[38] - piCur[38]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2645 | iTemp = piOrg[39] - piCur[39]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2646 | iTemp = piOrg[40] - piCur[40]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2647 | iTemp = piOrg[41] - piCur[41]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2648 | iTemp = piOrg[42] - piCur[42]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2649 | iTemp = piOrg[43] - piCur[43]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2650 | iTemp = piOrg[44] - piCur[44]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2651 | iTemp = piOrg[45] - piCur[45]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2652 | iTemp = piOrg[46] - piCur[46]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2653 | iTemp = piOrg[47] - piCur[47]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2654 | iTemp = piOrg[48] - piCur[48]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2655 | iTemp = piOrg[49] - piCur[49]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2656 | iTemp = piOrg[50] - piCur[50]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2657 | iTemp = piOrg[51] - piCur[51]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2658 | iTemp = piOrg[52] - piCur[52]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2659 | iTemp = piOrg[53] - piCur[53]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2660 | iTemp = piOrg[54] - piCur[54]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2661 | iTemp = piOrg[55] - piCur[55]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2662 | iTemp = piOrg[56] - piCur[56]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2663 | iTemp = piOrg[57] - piCur[57]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2664 | iTemp = piOrg[58] - piCur[58]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2665 | iTemp = piOrg[59] - piCur[59]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2666 | iTemp = piOrg[60] - piCur[60]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2667 | iTemp = piOrg[61] - piCur[61]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2668 | iTemp = piOrg[62] - piCur[62]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2669 | iTemp = piOrg[63] - piCur[63]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
2670 | |
---|
2671 | piOrg += iStrideOrg; |
---|
2672 | piCur += iStrideCur; |
---|
2673 | } |
---|
2674 | |
---|
2675 | return ( uiSum ); |
---|
2676 | } |
---|
2677 | #if H_3D_VSO |
---|
2678 | //SAIT_VSO_EST_A0033 |
---|
2679 | UInt TComRdCost::getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride, Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y ) |
---|
2680 | { |
---|
2681 | Double dD; |
---|
2682 | Int iTemp; |
---|
2683 | |
---|
2684 | dD = ( (Double) ( dDM >> DISTORTION_PRECISION_ADJUSTMENT( g_bitDepthY - 8 ) ) ) * m_dDisparityCoeff; |
---|
2685 | |
---|
2686 | Double dTemp = ( 0.5 * fabs(dD) * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) ); |
---|
2687 | iTemp = (Int) (((dTemp) < 0)? (Int)((dTemp) - 0.5) : (Int)((dTemp) + 0.5)); |
---|
2688 | |
---|
2689 | return (UInt) ( (iTemp*iTemp)>>1 ); |
---|
2690 | } |
---|
2691 | |
---|
2692 | UInt TComRdCost::xGetVSD( DistParam* pcDtParam ) |
---|
2693 | { |
---|
2694 | Pel* piOrg = pcDtParam->pOrg; |
---|
2695 | Pel* piCur = pcDtParam->pCur; |
---|
2696 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
2697 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
2698 | Int iRows = pcDtParam->iRows; |
---|
2699 | Int iCols = pcDtParam->iCols; |
---|
2700 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2701 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2702 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
2703 | |
---|
2704 | UInt uiSum = 0; |
---|
2705 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
2706 | |
---|
2707 | Int dDM; |
---|
2708 | |
---|
2709 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
2710 | { |
---|
2711 | for (Int x = 0; x < iCols; x++ ) |
---|
2712 | { |
---|
2713 | dDM = (Int) ( piOrg[x ] - piCur[x ] ); |
---|
2714 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
2715 | } |
---|
2716 | piOrg += iStrideOrg; |
---|
2717 | piCur += iStrideCur; |
---|
2718 | } |
---|
2719 | |
---|
2720 | return ( uiSum ); |
---|
2721 | } |
---|
2722 | |
---|
2723 | UInt TComRdCost::xGetVSD4( DistParam* pcDtParam ) |
---|
2724 | { |
---|
2725 | Pel* piOrg = pcDtParam->pOrg; |
---|
2726 | Pel* piCur = pcDtParam->pCur; |
---|
2727 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
2728 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
2729 | Int iRows = pcDtParam->iRows; |
---|
2730 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2731 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2732 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
2733 | |
---|
2734 | UInt uiSum = 0; |
---|
2735 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
2736 | |
---|
2737 | Int dDM; |
---|
2738 | |
---|
2739 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
2740 | { |
---|
2741 | dDM = (Int) ( piOrg[0] - piCur[0] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 0, y ) ) >> uiShift; |
---|
2742 | dDM = (Int) ( piOrg[1] - piCur[1] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 1, y ) ) >> uiShift; |
---|
2743 | dDM = (Int) ( piOrg[2] - piCur[2] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 2, y ) ) >> uiShift; |
---|
2744 | dDM = (Int) ( piOrg[3] - piCur[3] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 3, y ) ) >> uiShift; |
---|
2745 | |
---|
2746 | piOrg += iStrideOrg; |
---|
2747 | piCur += iStrideCur; |
---|
2748 | } |
---|
2749 | |
---|
2750 | return ( uiSum ); |
---|
2751 | } |
---|
2752 | |
---|
2753 | UInt TComRdCost::xGetVSD8( DistParam* pcDtParam ) |
---|
2754 | { |
---|
2755 | Pel* piOrg = pcDtParam->pOrg; |
---|
2756 | Pel* piCur = pcDtParam->pCur; |
---|
2757 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
2758 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
2759 | Int iRows = pcDtParam->iRows; |
---|
2760 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2761 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2762 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
2763 | |
---|
2764 | UInt uiSum = 0; |
---|
2765 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
2766 | |
---|
2767 | Int dDM; |
---|
2768 | |
---|
2769 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
2770 | { |
---|
2771 | for (Int x = 0; x < 8; x++ ) |
---|
2772 | { |
---|
2773 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
2774 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
2775 | } |
---|
2776 | piOrg += iStrideOrg; |
---|
2777 | piCur += iStrideCur; |
---|
2778 | } |
---|
2779 | |
---|
2780 | return ( uiSum ); |
---|
2781 | } |
---|
2782 | |
---|
2783 | UInt TComRdCost::xGetVSD16( DistParam* pcDtParam ) |
---|
2784 | { |
---|
2785 | Pel* piOrg = pcDtParam->pOrg; |
---|
2786 | Pel* piCur = pcDtParam->pCur; |
---|
2787 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
2788 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
2789 | Int iRows = pcDtParam->iRows; |
---|
2790 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2791 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2792 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
2793 | |
---|
2794 | UInt uiSum = 0; |
---|
2795 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
2796 | |
---|
2797 | Int dDM; |
---|
2798 | |
---|
2799 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
2800 | { |
---|
2801 | for (Int x = 0; x < 16; x++ ) |
---|
2802 | { |
---|
2803 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
2804 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
2805 | } |
---|
2806 | piOrg += iStrideOrg; |
---|
2807 | piCur += iStrideCur; |
---|
2808 | } |
---|
2809 | |
---|
2810 | return ( uiSum ); |
---|
2811 | } |
---|
2812 | |
---|
2813 | UInt TComRdCost::xGetVSD16N( DistParam* pcDtParam ) |
---|
2814 | { |
---|
2815 | Pel* piOrg = pcDtParam->pOrg; |
---|
2816 | Pel* piCur = pcDtParam->pCur; |
---|
2817 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
2818 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
2819 | Int iRows = pcDtParam->iRows; |
---|
2820 | Int iCols = pcDtParam->iCols; |
---|
2821 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2822 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2823 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
2824 | |
---|
2825 | UInt uiSum = 0; |
---|
2826 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
2827 | |
---|
2828 | Int dDM; |
---|
2829 | |
---|
2830 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
2831 | { |
---|
2832 | for (Int x = 0; x < iCols; x+=16 ) |
---|
2833 | { |
---|
2834 | for ( Int k = 0 ; k < 16 ; k++ ) |
---|
2835 | { |
---|
2836 | dDM = (Int) ( piOrg[x+k] - piCur[x+k] ); |
---|
2837 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x+k, y ) >> uiShift; |
---|
2838 | } |
---|
2839 | } |
---|
2840 | piOrg += iStrideOrg; |
---|
2841 | piCur += iStrideCur; |
---|
2842 | } |
---|
2843 | |
---|
2844 | return ( uiSum ); |
---|
2845 | } |
---|
2846 | |
---|
2847 | UInt TComRdCost::xGetVSD32( DistParam* pcDtParam ) |
---|
2848 | { |
---|
2849 | Pel* piOrg = pcDtParam->pOrg; |
---|
2850 | Pel* piCur = pcDtParam->pCur; |
---|
2851 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
2852 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
2853 | Int iRows = pcDtParam->iRows; |
---|
2854 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2855 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2856 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
2857 | |
---|
2858 | UInt uiSum = 0; |
---|
2859 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
2860 | |
---|
2861 | Int dDM; |
---|
2862 | |
---|
2863 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
2864 | { |
---|
2865 | for (Int x = 0; x < 32 ; x++ ) |
---|
2866 | { |
---|
2867 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
2868 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
2869 | } |
---|
2870 | piOrg += iStrideOrg; |
---|
2871 | piCur += iStrideCur; |
---|
2872 | } |
---|
2873 | |
---|
2874 | return ( uiSum ); |
---|
2875 | } |
---|
2876 | |
---|
2877 | UInt TComRdCost::xGetVSD64( DistParam* pcDtParam ) |
---|
2878 | { |
---|
2879 | Pel* piOrg = pcDtParam->pOrg; |
---|
2880 | Pel* piCur = pcDtParam->pCur; |
---|
2881 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
2882 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
2883 | Int iRows = pcDtParam->iRows; |
---|
2884 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2885 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2886 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
2887 | |
---|
2888 | UInt uiSum = 0; |
---|
2889 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
2890 | |
---|
2891 | Int dDM; |
---|
2892 | |
---|
2893 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
2894 | { |
---|
2895 | for (Int x = 0; x < 64; x++ ) |
---|
2896 | { |
---|
2897 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
2898 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
2899 | } |
---|
2900 | piOrg += iStrideOrg; |
---|
2901 | piCur += iStrideCur; |
---|
2902 | } |
---|
2903 | |
---|
2904 | return ( uiSum ); |
---|
2905 | } |
---|
2906 | |
---|
2907 | #endif |
---|
2908 | |
---|
2909 | // -------------------------------------------------------------------------------------------------------------------- |
---|
2910 | // HADAMARD with step (used in fractional search) |
---|
2911 | // -------------------------------------------------------------------------------------------------------------------- |
---|
2912 | |
---|
2913 | UInt TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
2914 | { |
---|
2915 | Int satd = 0, diff[4], m[4]; |
---|
2916 | assert( iStep == 1 ); |
---|
2917 | diff[0] = piOrg[0 ] - piCur[0]; |
---|
2918 | diff[1] = piOrg[1 ] - piCur[1]; |
---|
2919 | diff[2] = piOrg[iStrideOrg ] - piCur[0 + iStrideCur]; |
---|
2920 | diff[3] = piOrg[iStrideOrg + 1] - piCur[1 + iStrideCur]; |
---|
2921 | m[0] = diff[0] + diff[2]; |
---|
2922 | m[1] = diff[1] + diff[3]; |
---|
2923 | m[2] = diff[0] - diff[2]; |
---|
2924 | m[3] = diff[1] - diff[3]; |
---|
2925 | |
---|
2926 | satd += abs(m[0] + m[1]); |
---|
2927 | satd += abs(m[0] - m[1]); |
---|
2928 | satd += abs(m[2] + m[3]); |
---|
2929 | satd += abs(m[2] - m[3]); |
---|
2930 | |
---|
2931 | return satd; |
---|
2932 | } |
---|
2933 | |
---|
2934 | UInt TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
2935 | { |
---|
2936 | Int k, satd = 0, diff[16], m[16], d[16]; |
---|
2937 | |
---|
2938 | assert( iStep == 1 ); |
---|
2939 | for( k = 0; k < 16; k+=4 ) |
---|
2940 | { |
---|
2941 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
2942 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
2943 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
2944 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
2945 | |
---|
2946 | piCur += iStrideCur; |
---|
2947 | piOrg += iStrideOrg; |
---|
2948 | } |
---|
2949 | |
---|
2950 | /*===== hadamard transform =====*/ |
---|
2951 | m[ 0] = diff[ 0] + diff[12]; |
---|
2952 | m[ 1] = diff[ 1] + diff[13]; |
---|
2953 | m[ 2] = diff[ 2] + diff[14]; |
---|
2954 | m[ 3] = diff[ 3] + diff[15]; |
---|
2955 | m[ 4] = diff[ 4] + diff[ 8]; |
---|
2956 | m[ 5] = diff[ 5] + diff[ 9]; |
---|
2957 | m[ 6] = diff[ 6] + diff[10]; |
---|
2958 | m[ 7] = diff[ 7] + diff[11]; |
---|
2959 | m[ 8] = diff[ 4] - diff[ 8]; |
---|
2960 | m[ 9] = diff[ 5] - diff[ 9]; |
---|
2961 | m[10] = diff[ 6] - diff[10]; |
---|
2962 | m[11] = diff[ 7] - diff[11]; |
---|
2963 | m[12] = diff[ 0] - diff[12]; |
---|
2964 | m[13] = diff[ 1] - diff[13]; |
---|
2965 | m[14] = diff[ 2] - diff[14]; |
---|
2966 | m[15] = diff[ 3] - diff[15]; |
---|
2967 | |
---|
2968 | d[ 0] = m[ 0] + m[ 4]; |
---|
2969 | d[ 1] = m[ 1] + m[ 5]; |
---|
2970 | d[ 2] = m[ 2] + m[ 6]; |
---|
2971 | d[ 3] = m[ 3] + m[ 7]; |
---|
2972 | d[ 4] = m[ 8] + m[12]; |
---|
2973 | d[ 5] = m[ 9] + m[13]; |
---|
2974 | d[ 6] = m[10] + m[14]; |
---|
2975 | d[ 7] = m[11] + m[15]; |
---|
2976 | d[ 8] = m[ 0] - m[ 4]; |
---|
2977 | d[ 9] = m[ 1] - m[ 5]; |
---|
2978 | d[10] = m[ 2] - m[ 6]; |
---|
2979 | d[11] = m[ 3] - m[ 7]; |
---|
2980 | d[12] = m[12] - m[ 8]; |
---|
2981 | d[13] = m[13] - m[ 9]; |
---|
2982 | d[14] = m[14] - m[10]; |
---|
2983 | d[15] = m[15] - m[11]; |
---|
2984 | |
---|
2985 | m[ 0] = d[ 0] + d[ 3]; |
---|
2986 | m[ 1] = d[ 1] + d[ 2]; |
---|
2987 | m[ 2] = d[ 1] - d[ 2]; |
---|
2988 | m[ 3] = d[ 0] - d[ 3]; |
---|
2989 | m[ 4] = d[ 4] + d[ 7]; |
---|
2990 | m[ 5] = d[ 5] + d[ 6]; |
---|
2991 | m[ 6] = d[ 5] - d[ 6]; |
---|
2992 | m[ 7] = d[ 4] - d[ 7]; |
---|
2993 | m[ 8] = d[ 8] + d[11]; |
---|
2994 | m[ 9] = d[ 9] + d[10]; |
---|
2995 | m[10] = d[ 9] - d[10]; |
---|
2996 | m[11] = d[ 8] - d[11]; |
---|
2997 | m[12] = d[12] + d[15]; |
---|
2998 | m[13] = d[13] + d[14]; |
---|
2999 | m[14] = d[13] - d[14]; |
---|
3000 | m[15] = d[12] - d[15]; |
---|
3001 | |
---|
3002 | d[ 0] = m[ 0] + m[ 1]; |
---|
3003 | d[ 1] = m[ 0] - m[ 1]; |
---|
3004 | d[ 2] = m[ 2] + m[ 3]; |
---|
3005 | d[ 3] = m[ 3] - m[ 2]; |
---|
3006 | d[ 4] = m[ 4] + m[ 5]; |
---|
3007 | d[ 5] = m[ 4] - m[ 5]; |
---|
3008 | d[ 6] = m[ 6] + m[ 7]; |
---|
3009 | d[ 7] = m[ 7] - m[ 6]; |
---|
3010 | d[ 8] = m[ 8] + m[ 9]; |
---|
3011 | d[ 9] = m[ 8] - m[ 9]; |
---|
3012 | d[10] = m[10] + m[11]; |
---|
3013 | d[11] = m[11] - m[10]; |
---|
3014 | d[12] = m[12] + m[13]; |
---|
3015 | d[13] = m[12] - m[13]; |
---|
3016 | d[14] = m[14] + m[15]; |
---|
3017 | d[15] = m[15] - m[14]; |
---|
3018 | |
---|
3019 | for (k=0; k<16; ++k) |
---|
3020 | { |
---|
3021 | satd += abs(d[k]); |
---|
3022 | } |
---|
3023 | satd = ((satd+1)>>1); |
---|
3024 | |
---|
3025 | return satd; |
---|
3026 | } |
---|
3027 | |
---|
3028 | UInt TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
3029 | { |
---|
3030 | Int k, i, j, jj, sad=0; |
---|
3031 | Int diff[64], m1[8][8], m2[8][8], m3[8][8]; |
---|
3032 | assert( iStep == 1 ); |
---|
3033 | for( k = 0; k < 64; k += 8 ) |
---|
3034 | { |
---|
3035 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
3036 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
3037 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
3038 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
3039 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
3040 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
3041 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
3042 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
3043 | |
---|
3044 | piCur += iStrideCur; |
---|
3045 | piOrg += iStrideOrg; |
---|
3046 | } |
---|
3047 | |
---|
3048 | //horizontal |
---|
3049 | for (j=0; j < 8; j++) |
---|
3050 | { |
---|
3051 | jj = j << 3; |
---|
3052 | m2[j][0] = diff[jj ] + diff[jj+4]; |
---|
3053 | m2[j][1] = diff[jj+1] + diff[jj+5]; |
---|
3054 | m2[j][2] = diff[jj+2] + diff[jj+6]; |
---|
3055 | m2[j][3] = diff[jj+3] + diff[jj+7]; |
---|
3056 | m2[j][4] = diff[jj ] - diff[jj+4]; |
---|
3057 | m2[j][5] = diff[jj+1] - diff[jj+5]; |
---|
3058 | m2[j][6] = diff[jj+2] - diff[jj+6]; |
---|
3059 | m2[j][7] = diff[jj+3] - diff[jj+7]; |
---|
3060 | |
---|
3061 | m1[j][0] = m2[j][0] + m2[j][2]; |
---|
3062 | m1[j][1] = m2[j][1] + m2[j][3]; |
---|
3063 | m1[j][2] = m2[j][0] - m2[j][2]; |
---|
3064 | m1[j][3] = m2[j][1] - m2[j][3]; |
---|
3065 | m1[j][4] = m2[j][4] + m2[j][6]; |
---|
3066 | m1[j][5] = m2[j][5] + m2[j][7]; |
---|
3067 | m1[j][6] = m2[j][4] - m2[j][6]; |
---|
3068 | m1[j][7] = m2[j][5] - m2[j][7]; |
---|
3069 | |
---|
3070 | m2[j][0] = m1[j][0] + m1[j][1]; |
---|
3071 | m2[j][1] = m1[j][0] - m1[j][1]; |
---|
3072 | m2[j][2] = m1[j][2] + m1[j][3]; |
---|
3073 | m2[j][3] = m1[j][2] - m1[j][3]; |
---|
3074 | m2[j][4] = m1[j][4] + m1[j][5]; |
---|
3075 | m2[j][5] = m1[j][4] - m1[j][5]; |
---|
3076 | m2[j][6] = m1[j][6] + m1[j][7]; |
---|
3077 | m2[j][7] = m1[j][6] - m1[j][7]; |
---|
3078 | } |
---|
3079 | |
---|
3080 | //vertical |
---|
3081 | for (i=0; i < 8; i++) |
---|
3082 | { |
---|
3083 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
3084 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
3085 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
3086 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
3087 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
3088 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
3089 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
3090 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
3091 | |
---|
3092 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
3093 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
3094 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
3095 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
3096 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
3097 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
3098 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
3099 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
3100 | |
---|
3101 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
3102 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
3103 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
3104 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
3105 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
3106 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
3107 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
3108 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
3109 | } |
---|
3110 | |
---|
3111 | for (i = 0; i < 8; i++) |
---|
3112 | { |
---|
3113 | for (j = 0; j < 8; j++) |
---|
3114 | { |
---|
3115 | sad += abs(m2[i][j]); |
---|
3116 | } |
---|
3117 | } |
---|
3118 | |
---|
3119 | sad=((sad+2)>>2); |
---|
3120 | |
---|
3121 | return sad; |
---|
3122 | } |
---|
3123 | |
---|
3124 | #if NS_HAD |
---|
3125 | UInt TComRdCost::xCalcHADs16x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
3126 | { |
---|
3127 | Int k, i, j, jj, sad=0; |
---|
3128 | Int diff[64], m1[4][16], m2[4][16]; |
---|
3129 | assert( iStep == 1 ); |
---|
3130 | for( k = 0; k < 64; k += 16 ) |
---|
3131 | { |
---|
3132 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
3133 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
3134 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
3135 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
3136 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
3137 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
3138 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
3139 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
3140 | |
---|
3141 | diff[k+8] = piOrg[8] - piCur[8] ; |
---|
3142 | diff[k+9] = piOrg[9] - piCur[9] ; |
---|
3143 | diff[k+10] = piOrg[10] - piCur[10]; |
---|
3144 | diff[k+11] = piOrg[11] - piCur[11]; |
---|
3145 | diff[k+12] = piOrg[12] - piCur[12]; |
---|
3146 | diff[k+13] = piOrg[13] - piCur[13]; |
---|
3147 | diff[k+14] = piOrg[14] - piCur[14]; |
---|
3148 | diff[k+15] = piOrg[15] - piCur[15]; |
---|
3149 | |
---|
3150 | piCur += iStrideCur; |
---|
3151 | piOrg += iStrideOrg; |
---|
3152 | } |
---|
3153 | |
---|
3154 | //horizontal |
---|
3155 | for (j=0; j < 4; j++) |
---|
3156 | { |
---|
3157 | jj = j << 4; |
---|
3158 | |
---|
3159 | m2[j][0] = diff[jj ] + diff[jj+8]; |
---|
3160 | m2[j][1] = diff[jj+1] + diff[jj+9]; |
---|
3161 | m2[j][2] = diff[jj+2] + diff[jj+10]; |
---|
3162 | m2[j][3] = diff[jj+3] + diff[jj+11]; |
---|
3163 | m2[j][4] = diff[jj+4] + diff[jj+12]; |
---|
3164 | m2[j][5] = diff[jj+5] + diff[jj+13]; |
---|
3165 | m2[j][6] = diff[jj+6] + diff[jj+14]; |
---|
3166 | m2[j][7] = diff[jj+7] + diff[jj+15]; |
---|
3167 | m2[j][8] = diff[jj ] - diff[jj+8]; |
---|
3168 | m2[j][9] = diff[jj+1] - diff[jj+9]; |
---|
3169 | m2[j][10] = diff[jj+2] - diff[jj+10]; |
---|
3170 | m2[j][11] = diff[jj+3] - diff[jj+11]; |
---|
3171 | m2[j][12] = diff[jj+4] - diff[jj+12]; |
---|
3172 | m2[j][13] = diff[jj+5] - diff[jj+13]; |
---|
3173 | m2[j][14] = diff[jj+6] - diff[jj+14]; |
---|
3174 | m2[j][15] = diff[jj+7] - diff[jj+15]; |
---|
3175 | |
---|
3176 | m1[j][0] = m2[j][0] + m2[j][4]; |
---|
3177 | m1[j][1] = m2[j][1] + m2[j][5]; |
---|
3178 | m1[j][2] = m2[j][2] + m2[j][6]; |
---|
3179 | m1[j][3] = m2[j][3] + m2[j][7]; |
---|
3180 | m1[j][4] = m2[j][0] - m2[j][4]; |
---|
3181 | m1[j][5] = m2[j][1] - m2[j][5]; |
---|
3182 | m1[j][6] = m2[j][2] - m2[j][6]; |
---|
3183 | m1[j][7] = m2[j][3] - m2[j][7]; |
---|
3184 | m1[j][8] = m2[j][8] + m2[j][12]; |
---|
3185 | m1[j][9] = m2[j][9] + m2[j][13]; |
---|
3186 | m1[j][10] = m2[j][10] + m2[j][14]; |
---|
3187 | m1[j][11] = m2[j][11] + m2[j][15]; |
---|
3188 | m1[j][12] = m2[j][8] - m2[j][12]; |
---|
3189 | m1[j][13] = m2[j][9] - m2[j][13]; |
---|
3190 | m1[j][14] = m2[j][10] - m2[j][14]; |
---|
3191 | m1[j][15] = m2[j][11] - m2[j][15]; |
---|
3192 | |
---|
3193 | m2[j][0] = m1[j][0] + m1[j][2]; |
---|
3194 | m2[j][1] = m1[j][1] + m1[j][3]; |
---|
3195 | m2[j][2] = m1[j][0] - m1[j][2]; |
---|
3196 | m2[j][3] = m1[j][1] - m1[j][3]; |
---|
3197 | m2[j][4] = m1[j][4] + m1[j][6]; |
---|
3198 | m2[j][5] = m1[j][5] + m1[j][7]; |
---|
3199 | m2[j][6] = m1[j][4] - m1[j][6]; |
---|
3200 | m2[j][7] = m1[j][5] - m1[j][7]; |
---|
3201 | m2[j][8] = m1[j][8] + m1[j][10]; |
---|
3202 | m2[j][9] = m1[j][9] + m1[j][11]; |
---|
3203 | m2[j][10] = m1[j][8] - m1[j][10]; |
---|
3204 | m2[j][11] = m1[j][9] - m1[j][11]; |
---|
3205 | m2[j][12] = m1[j][12] + m1[j][14]; |
---|
3206 | m2[j][13] = m1[j][13] + m1[j][15]; |
---|
3207 | m2[j][14] = m1[j][12] - m1[j][14]; |
---|
3208 | m2[j][15] = m1[j][13] - m1[j][15]; |
---|
3209 | |
---|
3210 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
3211 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
3212 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
3213 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
3214 | m1[j][4] = m2[j][4] + m2[j][5]; |
---|
3215 | m1[j][5] = m2[j][4] - m2[j][5]; |
---|
3216 | m1[j][6] = m2[j][6] + m2[j][7]; |
---|
3217 | m1[j][7] = m2[j][6] - m2[j][7]; |
---|
3218 | m1[j][8] = m2[j][8] + m2[j][9]; |
---|
3219 | m1[j][9] = m2[j][8] - m2[j][9]; |
---|
3220 | m1[j][10] = m2[j][10] + m2[j][11]; |
---|
3221 | m1[j][11] = m2[j][10] - m2[j][11]; |
---|
3222 | m1[j][12] = m2[j][12] + m2[j][13]; |
---|
3223 | m1[j][13] = m2[j][12] - m2[j][13]; |
---|
3224 | m1[j][14] = m2[j][14] + m2[j][15]; |
---|
3225 | m1[j][15] = m2[j][14] - m2[j][15]; |
---|
3226 | } |
---|
3227 | |
---|
3228 | //vertical |
---|
3229 | for (i=0; i < 16; i++) |
---|
3230 | { |
---|
3231 | m2[0][i] = m1[0][i] + m1[2][i]; |
---|
3232 | m2[1][i] = m1[1][i] + m1[3][i]; |
---|
3233 | m2[2][i] = m1[0][i] - m1[2][i]; |
---|
3234 | m2[3][i] = m1[1][i] - m1[3][i]; |
---|
3235 | |
---|
3236 | m1[0][i] = m2[0][i] + m2[1][i]; |
---|
3237 | m1[1][i] = m2[0][i] - m2[1][i]; |
---|
3238 | m1[2][i] = m2[2][i] + m2[3][i]; |
---|
3239 | m1[3][i] = m2[2][i] - m2[3][i]; |
---|
3240 | } |
---|
3241 | |
---|
3242 | for (i = 0; i < 4; i++) |
---|
3243 | { |
---|
3244 | for (j = 0; j < 16; j++) |
---|
3245 | { |
---|
3246 | sad += abs(m1[i][j]); |
---|
3247 | } |
---|
3248 | } |
---|
3249 | |
---|
3250 | sad=((sad+2)>>2); |
---|
3251 | |
---|
3252 | return sad; |
---|
3253 | } |
---|
3254 | |
---|
3255 | UInt TComRdCost::xCalcHADs4x16( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
3256 | { |
---|
3257 | Int k, i, j, jj, sad=0; |
---|
3258 | Int diff[64], m1[16][4], m2[16][4], m3[16][4]; |
---|
3259 | assert( iStep == 1 ); |
---|
3260 | for( k = 0; k < 64; k += 4 ) |
---|
3261 | { |
---|
3262 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
3263 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
3264 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
3265 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
3266 | |
---|
3267 | piCur += iStrideCur; |
---|
3268 | piOrg += iStrideOrg; |
---|
3269 | } |
---|
3270 | |
---|
3271 | //horizontal |
---|
3272 | for (j=0; j < 16; j++) |
---|
3273 | { |
---|
3274 | jj = j << 2; |
---|
3275 | m2[j][0] = diff[jj ] + diff[jj+2]; |
---|
3276 | m2[j][1] = diff[jj+1] + diff[jj+3]; |
---|
3277 | m2[j][2] = diff[jj ] - diff[jj+2]; |
---|
3278 | m2[j][3] = diff[jj+1] - diff[jj+3]; |
---|
3279 | |
---|
3280 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
3281 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
3282 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
3283 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
3284 | } |
---|
3285 | |
---|
3286 | //vertical |
---|
3287 | for (i=0; i < 4; i++) |
---|
3288 | { |
---|
3289 | m2[0][i] = m1[0][i] + m1[8][i]; |
---|
3290 | m2[1][i] = m1[1][i] + m1[9][i]; |
---|
3291 | m2[2][i] = m1[2][i] + m1[10][i]; |
---|
3292 | m2[3][i] = m1[3][i] + m1[11][i]; |
---|
3293 | m2[4][i] = m1[4][i] + m1[12][i]; |
---|
3294 | m2[5][i] = m1[5][i] + m1[13][i]; |
---|
3295 | m2[6][i] = m1[6][i] + m1[14][i]; |
---|
3296 | m2[7][i] = m1[7][i] + m1[15][i]; |
---|
3297 | m2[8][i] = m1[0][i] - m1[8][i]; |
---|
3298 | m2[9][i] = m1[1][i] - m1[9][i]; |
---|
3299 | m2[10][i] = m1[2][i] - m1[10][i]; |
---|
3300 | m2[11][i] = m1[3][i] - m1[11][i]; |
---|
3301 | m2[12][i] = m1[4][i] - m1[12][i]; |
---|
3302 | m2[13][i] = m1[5][i] - m1[13][i]; |
---|
3303 | m2[14][i] = m1[6][i] - m1[14][i]; |
---|
3304 | m2[15][i] = m1[7][i] - m1[15][i]; |
---|
3305 | |
---|
3306 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
3307 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
3308 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
3309 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
3310 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
3311 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
3312 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
3313 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
3314 | m3[8][i] = m2[8][i] + m2[12][i]; |
---|
3315 | m3[9][i] = m2[9][i] + m2[13][i]; |
---|
3316 | m3[10][i] = m2[10][i] + m2[14][i]; |
---|
3317 | m3[11][i] = m2[11][i] + m2[15][i]; |
---|
3318 | m3[12][i] = m2[8][i] - m2[12][i]; |
---|
3319 | m3[13][i] = m2[9][i] - m2[13][i]; |
---|
3320 | m3[14][i] = m2[10][i] - m2[14][i]; |
---|
3321 | m3[15][i] = m2[11][i] - m2[15][i]; |
---|
3322 | |
---|
3323 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
3324 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
3325 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
3326 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
3327 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
3328 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
3329 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
3330 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
3331 | m1[8][i] = m3[8][i] + m3[10][i]; |
---|
3332 | m1[9][i] = m3[9][i] + m3[11][i]; |
---|
3333 | m1[10][i] = m3[8][i] - m3[10][i]; |
---|
3334 | m1[11][i] = m3[9][i] - m3[11][i]; |
---|
3335 | m1[12][i] = m3[12][i] + m3[14][i]; |
---|
3336 | m1[13][i] = m3[13][i] + m3[15][i]; |
---|
3337 | m1[14][i] = m3[12][i] - m3[14][i]; |
---|
3338 | m1[15][i] = m3[13][i] - m3[15][i]; |
---|
3339 | |
---|
3340 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
3341 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
3342 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
3343 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
3344 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
3345 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
3346 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
3347 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
3348 | m2[8][i] = m1[8][i] + m1[9][i]; |
---|
3349 | m2[9][i] = m1[8][i] - m1[9][i]; |
---|
3350 | m2[10][i] = m1[10][i] + m1[11][i]; |
---|
3351 | m2[11][i] = m1[10][i] - m1[11][i]; |
---|
3352 | m2[12][i] = m1[12][i] + m1[13][i]; |
---|
3353 | m2[13][i] = m1[12][i] - m1[13][i]; |
---|
3354 | m2[14][i] = m1[14][i] + m1[15][i]; |
---|
3355 | m2[15][i] = m1[14][i] - m1[15][i]; |
---|
3356 | } |
---|
3357 | |
---|
3358 | for (i = 0; i < 16; i++) |
---|
3359 | { |
---|
3360 | for (j = 0; j < 4; j++) |
---|
3361 | { |
---|
3362 | sad += abs(m2[i][j]); |
---|
3363 | } |
---|
3364 | } |
---|
3365 | |
---|
3366 | sad=((sad+2)>>2); |
---|
3367 | |
---|
3368 | return sad; |
---|
3369 | } |
---|
3370 | #endif |
---|
3371 | |
---|
3372 | UInt TComRdCost::xGetHADs4( DistParam* pcDtParam ) |
---|
3373 | { |
---|
3374 | if ( pcDtParam->bApplyWeight ) |
---|
3375 | { |
---|
3376 | return xGetHADs4w( pcDtParam ); |
---|
3377 | } |
---|
3378 | Pel* piOrg = pcDtParam->pOrg; |
---|
3379 | Pel* piCur = pcDtParam->pCur; |
---|
3380 | Int iRows = pcDtParam->iRows; |
---|
3381 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
3382 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
3383 | Int iStep = pcDtParam->iStep; |
---|
3384 | Int y; |
---|
3385 | Int iOffsetOrg = iStrideOrg<<2; |
---|
3386 | Int iOffsetCur = iStrideCur<<2; |
---|
3387 | |
---|
3388 | UInt uiSum = 0; |
---|
3389 | |
---|
3390 | for ( y=0; y<iRows; y+= 4 ) |
---|
3391 | { |
---|
3392 | uiSum += xCalcHADs4x4( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
3393 | piOrg += iOffsetOrg; |
---|
3394 | piCur += iOffsetCur; |
---|
3395 | } |
---|
3396 | |
---|
3397 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
3398 | } |
---|
3399 | |
---|
3400 | UInt TComRdCost::xGetHADs8( DistParam* pcDtParam ) |
---|
3401 | { |
---|
3402 | if ( pcDtParam->bApplyWeight ) |
---|
3403 | { |
---|
3404 | return xGetHADs8w( pcDtParam ); |
---|
3405 | } |
---|
3406 | Pel* piOrg = pcDtParam->pOrg; |
---|
3407 | Pel* piCur = pcDtParam->pCur; |
---|
3408 | Int iRows = pcDtParam->iRows; |
---|
3409 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
3410 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
3411 | Int iStep = pcDtParam->iStep; |
---|
3412 | Int y; |
---|
3413 | |
---|
3414 | UInt uiSum = 0; |
---|
3415 | |
---|
3416 | if ( iRows == 4 ) |
---|
3417 | { |
---|
3418 | uiSum += xCalcHADs4x4( piOrg+0, piCur , iStrideOrg, iStrideCur, iStep ); |
---|
3419 | uiSum += xCalcHADs4x4( piOrg+4, piCur+4*iStep, iStrideOrg, iStrideCur, iStep ); |
---|
3420 | } |
---|
3421 | else |
---|
3422 | { |
---|
3423 | Int iOffsetOrg = iStrideOrg<<3; |
---|
3424 | Int iOffsetCur = iStrideCur<<3; |
---|
3425 | for ( y=0; y<iRows; y+= 8 ) |
---|
3426 | { |
---|
3427 | uiSum += xCalcHADs8x8( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
3428 | piOrg += iOffsetOrg; |
---|
3429 | piCur += iOffsetCur; |
---|
3430 | } |
---|
3431 | } |
---|
3432 | |
---|
3433 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
3434 | } |
---|
3435 | |
---|
3436 | UInt TComRdCost::xGetHADs( DistParam* pcDtParam ) |
---|
3437 | { |
---|
3438 | if ( pcDtParam->bApplyWeight ) |
---|
3439 | { |
---|
3440 | return xGetHADsw( pcDtParam ); |
---|
3441 | } |
---|
3442 | #if H_3D_IC |
---|
3443 | if( pcDtParam->bUseIC ) |
---|
3444 | { |
---|
3445 | return xGetHADsic( pcDtParam ); |
---|
3446 | } |
---|
3447 | #endif |
---|
3448 | Pel* piOrg = pcDtParam->pOrg; |
---|
3449 | Pel* piCur = pcDtParam->pCur; |
---|
3450 | Int iRows = pcDtParam->iRows; |
---|
3451 | Int iCols = pcDtParam->iCols; |
---|
3452 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
3453 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
3454 | Int iStep = pcDtParam->iStep; |
---|
3455 | |
---|
3456 | Int x, y; |
---|
3457 | |
---|
3458 | UInt uiSum = 0; |
---|
3459 | |
---|
3460 | #if NS_HAD |
---|
3461 | if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) ) |
---|
3462 | #else |
---|
3463 | if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) |
---|
3464 | #endif |
---|
3465 | { |
---|
3466 | Int iOffsetOrg = iStrideOrg<<3; |
---|
3467 | Int iOffsetCur = iStrideCur<<3; |
---|
3468 | for ( y=0; y<iRows; y+= 8 ) |
---|
3469 | { |
---|
3470 | for ( x=0; x<iCols; x+= 8 ) |
---|
3471 | { |
---|
3472 | uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
3473 | } |
---|
3474 | piOrg += iOffsetOrg; |
---|
3475 | piCur += iOffsetCur; |
---|
3476 | } |
---|
3477 | } |
---|
3478 | #if NS_HAD |
---|
3479 | else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD ) |
---|
3480 | { |
---|
3481 | Int iOffsetOrg = iStrideOrg<<2; |
---|
3482 | Int iOffsetCur = iStrideCur<<2; |
---|
3483 | for ( y=0; y<iRows; y+= 4 ) |
---|
3484 | { |
---|
3485 | for ( x=0; x<iCols; x+= 16 ) |
---|
3486 | { |
---|
3487 | uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
3488 | } |
---|
3489 | piOrg += iOffsetOrg; |
---|
3490 | piCur += iOffsetCur; |
---|
3491 | } |
---|
3492 | } |
---|
3493 | else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD ) |
---|
3494 | { |
---|
3495 | Int iOffsetOrg = iStrideOrg<<4; |
---|
3496 | Int iOffsetCur = iStrideCur<<4; |
---|
3497 | for ( y=0; y<iRows; y+= 16 ) |
---|
3498 | { |
---|
3499 | for ( x=0; x<iCols; x+= 4 ) |
---|
3500 | { |
---|
3501 | uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
3502 | } |
---|
3503 | piOrg += iOffsetOrg; |
---|
3504 | piCur += iOffsetCur; |
---|
3505 | } |
---|
3506 | } |
---|
3507 | #endif |
---|
3508 | else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) |
---|
3509 | { |
---|
3510 | Int iOffsetOrg = iStrideOrg<<2; |
---|
3511 | Int iOffsetCur = iStrideCur<<2; |
---|
3512 | |
---|
3513 | for ( y=0; y<iRows; y+= 4 ) |
---|
3514 | { |
---|
3515 | for ( x=0; x<iCols; x+= 4 ) |
---|
3516 | { |
---|
3517 | uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
3518 | } |
---|
3519 | piOrg += iOffsetOrg; |
---|
3520 | piCur += iOffsetCur; |
---|
3521 | } |
---|
3522 | } |
---|
3523 | else if( ( iRows % 2 == 0) && (iCols % 2 == 0) ) |
---|
3524 | { |
---|
3525 | Int iOffsetOrg = iStrideOrg<<1; |
---|
3526 | Int iOffsetCur = iStrideCur<<1; |
---|
3527 | for ( y=0; y<iRows; y+=2 ) |
---|
3528 | { |
---|
3529 | for ( x=0; x<iCols; x+=2 ) |
---|
3530 | { |
---|
3531 | uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
3532 | } |
---|
3533 | piOrg += iOffsetOrg; |
---|
3534 | piCur += iOffsetCur; |
---|
3535 | } |
---|
3536 | } |
---|
3537 | else |
---|
3538 | { |
---|
3539 | assert(false); |
---|
3540 | } |
---|
3541 | |
---|
3542 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
3543 | } |
---|
3544 | |
---|
3545 | #if H_3D_IC |
---|
3546 | UInt TComRdCost::xGetHADsic( DistParam* pcDtParam ) |
---|
3547 | { |
---|
3548 | if ( pcDtParam->bApplyWeight ) |
---|
3549 | { |
---|
3550 | return xGetHADsw( pcDtParam ); |
---|
3551 | } |
---|
3552 | Pel* piOrg = pcDtParam->pOrg; |
---|
3553 | Pel* piCur = pcDtParam->pCur; |
---|
3554 | Int iRows = pcDtParam->iRows; |
---|
3555 | Int iCols = pcDtParam->iCols; |
---|
3556 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
3557 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
3558 | Int iStep = pcDtParam->iStep; |
---|
3559 | |
---|
3560 | Int x, y; |
---|
3561 | |
---|
3562 | UInt uiSum = 0; |
---|
3563 | |
---|
3564 | Int iOrigAvg = 0, iCurAvg = 0; |
---|
3565 | Int iDeltaC; |
---|
3566 | |
---|
3567 | for ( y=0; y<iRows; y++ ) |
---|
3568 | { |
---|
3569 | for ( x=0; x<iCols; x++ ) |
---|
3570 | { |
---|
3571 | iOrigAvg += piOrg[x]; |
---|
3572 | iCurAvg += piCur[x]; |
---|
3573 | } |
---|
3574 | piOrg += iStrideOrg; |
---|
3575 | piCur += iStrideCur; |
---|
3576 | } |
---|
3577 | |
---|
3578 | piOrg = pcDtParam->pOrg; |
---|
3579 | piCur = pcDtParam->pCur; |
---|
3580 | |
---|
3581 | iDeltaC = (iOrigAvg - iCurAvg)/iRows/iCols; |
---|
3582 | |
---|
3583 | for ( y=0; y<iRows; y++ ) |
---|
3584 | { |
---|
3585 | for ( x=0; x<iCols; x++ ) |
---|
3586 | { |
---|
3587 | piOrg[x] -= iDeltaC; |
---|
3588 | } |
---|
3589 | piOrg += iStrideOrg; |
---|
3590 | } |
---|
3591 | |
---|
3592 | piOrg = pcDtParam->pOrg; |
---|
3593 | |
---|
3594 | #if NS_HAD |
---|
3595 | if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) ) |
---|
3596 | #else |
---|
3597 | if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) |
---|
3598 | #endif |
---|
3599 | { |
---|
3600 | Int iOffsetOrg = iStrideOrg<<3; |
---|
3601 | Int iOffsetCur = iStrideCur<<3; |
---|
3602 | for ( y=0; y<iRows; y+= 8 ) |
---|
3603 | { |
---|
3604 | for ( x=0; x<iCols; x+= 8 ) |
---|
3605 | { |
---|
3606 | uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
3607 | } |
---|
3608 | piOrg += iOffsetOrg; |
---|
3609 | piCur += iOffsetCur; |
---|
3610 | } |
---|
3611 | } |
---|
3612 | #if NS_HAD |
---|
3613 | else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD ) |
---|
3614 | { |
---|
3615 | Int iOffsetOrg = iStrideOrg<<2; |
---|
3616 | Int iOffsetCur = iStrideCur<<2; |
---|
3617 | for ( y=0; y<iRows; y+= 4 ) |
---|
3618 | { |
---|
3619 | for ( x=0; x<iCols; x+= 16 ) |
---|
3620 | { |
---|
3621 | uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
3622 | } |
---|
3623 | piOrg += iOffsetOrg; |
---|
3624 | piCur += iOffsetCur; |
---|
3625 | } |
---|
3626 | } |
---|
3627 | else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD ) |
---|
3628 | { |
---|
3629 | Int iOffsetOrg = iStrideOrg<<4; |
---|
3630 | Int iOffsetCur = iStrideCur<<4; |
---|
3631 | for ( y=0; y<iRows; y+= 16 ) |
---|
3632 | { |
---|
3633 | for ( x=0; x<iCols; x+= 4 ) |
---|
3634 | { |
---|
3635 | uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
3636 | } |
---|
3637 | piOrg += iOffsetOrg; |
---|
3638 | piCur += iOffsetCur; |
---|
3639 | } |
---|
3640 | } |
---|
3641 | #endif |
---|
3642 | else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) |
---|
3643 | { |
---|
3644 | Int iOffsetOrg = iStrideOrg<<2; |
---|
3645 | Int iOffsetCur = iStrideCur<<2; |
---|
3646 | |
---|
3647 | for ( y=0; y<iRows; y+= 4 ) |
---|
3648 | { |
---|
3649 | for ( x=0; x<iCols; x+= 4 ) |
---|
3650 | { |
---|
3651 | uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
3652 | } |
---|
3653 | piOrg += iOffsetOrg; |
---|
3654 | piCur += iOffsetCur; |
---|
3655 | } |
---|
3656 | } |
---|
3657 | else if( ( iRows % 2 == 0) && (iCols % 2 == 0) ) |
---|
3658 | { |
---|
3659 | Int iOffsetOrg = iStrideOrg<<1; |
---|
3660 | Int iOffsetCur = iStrideCur<<1; |
---|
3661 | for ( y=0; y<iRows; y+=2 ) |
---|
3662 | { |
---|
3663 | for ( x=0; x<iCols; x+=2 ) |
---|
3664 | { |
---|
3665 | uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
3666 | } |
---|
3667 | piOrg += iOffsetOrg; |
---|
3668 | piCur += iOffsetCur; |
---|
3669 | } |
---|
3670 | } |
---|
3671 | else |
---|
3672 | { |
---|
3673 | assert(false); |
---|
3674 | } |
---|
3675 | |
---|
3676 | piOrg = pcDtParam->pOrg; |
---|
3677 | |
---|
3678 | for ( y=0; y<iRows; y++ ) |
---|
3679 | { |
---|
3680 | for ( x=0; x<iCols; x++ ) |
---|
3681 | { |
---|
3682 | piOrg[x] += iDeltaC; |
---|
3683 | } |
---|
3684 | piOrg += iStrideOrg; |
---|
3685 | } |
---|
3686 | |
---|
3687 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT( pcDtParam->bitDepth - 8 ) ); |
---|
3688 | } |
---|
3689 | #endif |
---|
3690 | |
---|
3691 | #if H_3D_VSO |
---|
3692 | Void TComRdCost::setLambdaVSO( Double dLambdaVSO ) |
---|
3693 | { |
---|
3694 | m_dLambdaVSO = dLambdaVSO; |
---|
3695 | m_dSqrtLambdaVSO = sqrt(m_dLambdaVSO); |
---|
3696 | m_uiLambdaMotionSADVSO = (UInt)floor(65536.0 * m_dSqrtLambdaVSO); |
---|
3697 | m_uiLambdaMotionSSEVSO = (UInt)floor(65536.0 * m_dLambdaVSO ); |
---|
3698 | } |
---|
3699 | |
---|
3700 | Dist TComRdCost::xGetDistVSOMode4( Int iStartPosX, Int iStartPosY, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD ) |
---|
3701 | { |
---|
3702 | AOT(bSAD); |
---|
3703 | #if H_3D_VSO_EARLY_SKIP |
---|
3704 | RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur, piOrg, iOrgStride); |
---|
3705 | #else |
---|
3706 | RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur ); |
---|
3707 | #endif |
---|
3708 | |
---|
3709 | RMDist iDistMin = (RMDist) RDO_DIST_MIN; |
---|
3710 | iDistMin = m_bAllowNegDist ? RDO_DIST_MIN : 0; |
---|
3711 | |
---|
3712 | iDist = std::min( iDist, (RMDist) RDO_DIST_MAX); |
---|
3713 | iDist = std::max( iDist, iDistMin); |
---|
3714 | return (Dist) iDist; |
---|
3715 | } |
---|
3716 | |
---|
3717 | |
---|
3718 | Dist TComRdCost::getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHAD ) |
---|
3719 | { |
---|
3720 | assert( m_bUseVSO ); |
---|
3721 | assert( this->m_fpDistortFuncVSO != 0 ); |
---|
3722 | |
---|
3723 | Int iPosX; |
---|
3724 | Int iPosY; |
---|
3725 | |
---|
3726 | pcCU->getPosInPic( uiAbsPartIndex, iPosX, iPosY ); |
---|
3727 | |
---|
3728 | Dist dist = (this->*m_fpDistortFuncVSO) ( iPosX, iPosY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight, bHAD ); |
---|
3729 | |
---|
3730 | if ( m_bUseWVSO ) |
---|
3731 | { |
---|
3732 | Int iDWeight = m_iDWeight * m_iDWeight; |
---|
3733 | Int iVSOWeight = m_iVSOWeight * m_iVSOWeight; |
---|
3734 | Dist distDepth; |
---|
3735 | |
---|
3736 | if ( !bHAD ) |
---|
3737 | { |
---|
3738 | distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
3739 | } |
---|
3740 | else |
---|
3741 | { |
---|
3742 | distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
3743 | } |
---|
3744 | |
---|
3745 | dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight); |
---|
3746 | } |
---|
3747 | return dist; |
---|
3748 | }; |
---|
3749 | |
---|
3750 | |
---|
3751 | Void TComRdCost::setVSOMode( UInt uiIn ) |
---|
3752 | { |
---|
3753 | m_uiVSOMode = uiIn; |
---|
3754 | switch (m_uiVSOMode ) |
---|
3755 | { |
---|
3756 | case 4: |
---|
3757 | m_fpDistortFuncVSO = &TComRdCost::xGetDistVSOMode4; |
---|
3758 | break; |
---|
3759 | default: |
---|
3760 | assert(0); |
---|
3761 | break; |
---|
3762 | } |
---|
3763 | } |
---|
3764 | |
---|
3765 | |
---|
3766 | Double TComRdCost::calcRdCostVSO( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
3767 | { |
---|
3768 | assert( m_bUseLambdaScaleVSO ); |
---|
3769 | |
---|
3770 | Double dRdCost = 0.0; |
---|
3771 | Double dLambda = 0.0; |
---|
3772 | |
---|
3773 | switch ( eDFunc ) |
---|
3774 | { |
---|
3775 | case DF_SSE: |
---|
3776 | assert(0); |
---|
3777 | break; |
---|
3778 | case DF_SAD: |
---|
3779 | dLambda = (Double)m_uiLambdaMotionSADVSO; |
---|
3780 | break; |
---|
3781 | case DF_DEFAULT: |
---|
3782 | dLambda = m_dLambdaVSO; |
---|
3783 | break; |
---|
3784 | case DF_SSE_FRAME: |
---|
3785 | dLambda = m_dFrameLambdaVSO; |
---|
3786 | break; |
---|
3787 | default: |
---|
3788 | assert (0); |
---|
3789 | break; |
---|
3790 | } |
---|
3791 | |
---|
3792 | if (bFlag) |
---|
3793 | { |
---|
3794 | // Intra8x8, Intra4x4 Block only... |
---|
3795 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
3796 | dRdCost = (Double)(uiBits); |
---|
3797 | #else |
---|
3798 | dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda)); |
---|
3799 | #endif |
---|
3800 | } |
---|
3801 | else |
---|
3802 | { |
---|
3803 | if (eDFunc == DF_SAD) |
---|
3804 | { |
---|
3805 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16)); |
---|
3806 | dRdCost = (Double)(Dist)floor(dRdCost); |
---|
3807 | } |
---|
3808 | else |
---|
3809 | { |
---|
3810 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
3811 | dRdCost = (Double)(uiBits); |
---|
3812 | #else |
---|
3813 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5))); |
---|
3814 | dRdCost = (Double)(Dist)floor(dRdCost); |
---|
3815 | #endif |
---|
3816 | } |
---|
3817 | } |
---|
3818 | |
---|
3819 | return dRdCost; |
---|
3820 | } |
---|
3821 | |
---|
3822 | Void TComRdCost::setRenModelData( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight ) |
---|
3823 | { |
---|
3824 | UInt iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]]; |
---|
3825 | UInt iBlkY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]]; |
---|
3826 | |
---|
3827 | Int iStartPosX = iBlkX + pcCU->getCUPelX(); |
---|
3828 | Int iStartPosY = iBlkY + pcCU->getCUPelY(); |
---|
3829 | |
---|
3830 | m_pcRenModel->setData( iStartPosX, iStartPosY, iBlkWidth, iBlkHeight, iStride, piData ); |
---|
3831 | } |
---|
3832 | |
---|
3833 | Void TComRdCost::setAllowNegDist( Bool bAllowNegDist ) |
---|
3834 | { |
---|
3835 | m_bAllowNegDist = bAllowNegDist; |
---|
3836 | } |
---|
3837 | #endif |
---|
3838 | |
---|
3839 | //! \} |
---|