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