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