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