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