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