1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TComRdCost.cpp |
---|
35 | \brief RD cost computation class |
---|
36 | */ |
---|
37 | |
---|
38 | #include <math.h> |
---|
39 | #include <assert.h> |
---|
40 | #include "TComRom.h" |
---|
41 | #include "TComRdCost.h" |
---|
42 | #if H_3D |
---|
43 | #include "TComDataCU.h" |
---|
44 | #endif |
---|
45 | |
---|
46 | //! \ingroup TLibCommon |
---|
47 | //! \{ |
---|
48 | |
---|
49 | #if H_3D_VSO |
---|
50 | // SAIT_VSO_EST_A0033 |
---|
51 | Double TComRdCost::m_dDisparityCoeff = 1.0; |
---|
52 | #endif |
---|
53 | |
---|
54 | TComRdCost::TComRdCost() |
---|
55 | { |
---|
56 | init(); |
---|
57 | } |
---|
58 | |
---|
59 | TComRdCost::~TComRdCost() |
---|
60 | { |
---|
61 | #if !FIX203 |
---|
62 | xUninit(); |
---|
63 | #endif |
---|
64 | } |
---|
65 | |
---|
66 | // Calculate RD functions |
---|
67 | #if H_3D_VSO |
---|
68 | Double TComRdCost::calcRdCost( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
69 | #else |
---|
70 | Double TComRdCost::calcRdCost( UInt uiBits, UInt uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
71 | #endif |
---|
72 | { |
---|
73 | Double dRdCost = 0.0; |
---|
74 | Double dLambda = 0.0; |
---|
75 | |
---|
76 | switch ( eDFunc ) |
---|
77 | { |
---|
78 | case DF_SSE: |
---|
79 | assert(0); |
---|
80 | break; |
---|
81 | case DF_SAD: |
---|
82 | dLambda = (Double)m_uiLambdaMotionSAD; |
---|
83 | break; |
---|
84 | case DF_DEFAULT: |
---|
85 | dLambda = m_dLambda; |
---|
86 | break; |
---|
87 | case DF_SSE_FRAME: |
---|
88 | dLambda = m_dFrameLambda; |
---|
89 | break; |
---|
90 | default: |
---|
91 | assert (0); |
---|
92 | break; |
---|
93 | } |
---|
94 | |
---|
95 | if (bFlag) |
---|
96 | { |
---|
97 | // Intra8x8, Intra4x4 Block only... |
---|
98 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
99 | dRdCost = (Double)(uiBits); |
---|
100 | #else |
---|
101 | dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda)); |
---|
102 | #endif |
---|
103 | } |
---|
104 | else |
---|
105 | { |
---|
106 | if (eDFunc == DF_SAD) |
---|
107 | { |
---|
108 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16)); |
---|
109 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
110 | } |
---|
111 | else |
---|
112 | { |
---|
113 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
114 | dRdCost = (Double)(uiBits); |
---|
115 | #else |
---|
116 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5))); |
---|
117 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
118 | #endif |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | return dRdCost; |
---|
123 | } |
---|
124 | |
---|
125 | #if H_3D_VSO |
---|
126 | Double TComRdCost::calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
127 | #else |
---|
128 | Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
129 | #endif |
---|
130 | { |
---|
131 | Double dRdCost = 0.0; |
---|
132 | Double dLambda = 0.0; |
---|
133 | |
---|
134 | switch ( eDFunc ) |
---|
135 | { |
---|
136 | case DF_SSE: |
---|
137 | assert(0); |
---|
138 | break; |
---|
139 | case DF_SAD: |
---|
140 | dLambda = (Double)m_uiLambdaMotionSAD; |
---|
141 | break; |
---|
142 | case DF_DEFAULT: |
---|
143 | dLambda = m_dLambda; |
---|
144 | break; |
---|
145 | case DF_SSE_FRAME: |
---|
146 | dLambda = m_dFrameLambda; |
---|
147 | break; |
---|
148 | default: |
---|
149 | assert (0); |
---|
150 | break; |
---|
151 | } |
---|
152 | |
---|
153 | if (bFlag) |
---|
154 | { |
---|
155 | // Intra8x8, Intra4x4 Block only... |
---|
156 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
157 | dRdCost = (Double)(uiBits); |
---|
158 | #else |
---|
159 | dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda)); |
---|
160 | #endif |
---|
161 | } |
---|
162 | else |
---|
163 | { |
---|
164 | if (eDFunc == DF_SAD) |
---|
165 | { |
---|
166 | dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5)>>16)); |
---|
167 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
168 | } |
---|
169 | else |
---|
170 | { |
---|
171 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
172 | dRdCost = (Double)(uiBits); |
---|
173 | #else |
---|
174 | dRdCost = ((Double)(Int64)uiDistortion + (Double)((Int)((Int64)uiBits * dLambda+.5))); |
---|
175 | dRdCost = (Double)(UInt)floor(dRdCost); |
---|
176 | #endif |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | return dRdCost; |
---|
181 | } |
---|
182 | |
---|
183 | Void TComRdCost::setLambda( Double dLambda ) |
---|
184 | { |
---|
185 | m_dLambda = dLambda; |
---|
186 | m_sqrtLambda = sqrt(m_dLambda); |
---|
187 | m_uiLambdaMotionSAD = (UInt)floor(65536.0 * m_sqrtLambda); |
---|
188 | m_uiLambdaMotionSSE = (UInt)floor(65536.0 * m_dLambda ); |
---|
189 | } |
---|
190 | |
---|
191 | |
---|
192 | // Initalize Function Pointer by [eDFunc] |
---|
193 | Void TComRdCost::init() |
---|
194 | { |
---|
195 | m_afpDistortFunc[0] = NULL; // for DF_DEFAULT |
---|
196 | |
---|
197 | m_afpDistortFunc[1] = TComRdCost::xGetSSE; |
---|
198 | m_afpDistortFunc[2] = TComRdCost::xGetSSE4; |
---|
199 | m_afpDistortFunc[3] = TComRdCost::xGetSSE8; |
---|
200 | m_afpDistortFunc[4] = TComRdCost::xGetSSE16; |
---|
201 | m_afpDistortFunc[5] = TComRdCost::xGetSSE32; |
---|
202 | m_afpDistortFunc[6] = TComRdCost::xGetSSE64; |
---|
203 | m_afpDistortFunc[7] = TComRdCost::xGetSSE16N; |
---|
204 | |
---|
205 | m_afpDistortFunc[8] = TComRdCost::xGetSAD; |
---|
206 | m_afpDistortFunc[9] = TComRdCost::xGetSAD4; |
---|
207 | m_afpDistortFunc[10] = TComRdCost::xGetSAD8; |
---|
208 | m_afpDistortFunc[11] = TComRdCost::xGetSAD16; |
---|
209 | m_afpDistortFunc[12] = TComRdCost::xGetSAD32; |
---|
210 | m_afpDistortFunc[13] = TComRdCost::xGetSAD64; |
---|
211 | m_afpDistortFunc[14] = TComRdCost::xGetSAD16N; |
---|
212 | |
---|
213 | m_afpDistortFunc[15] = TComRdCost::xGetSAD; |
---|
214 | m_afpDistortFunc[16] = TComRdCost::xGetSAD4; |
---|
215 | m_afpDistortFunc[17] = TComRdCost::xGetSAD8; |
---|
216 | m_afpDistortFunc[18] = TComRdCost::xGetSAD16; |
---|
217 | m_afpDistortFunc[19] = TComRdCost::xGetSAD32; |
---|
218 | m_afpDistortFunc[20] = TComRdCost::xGetSAD64; |
---|
219 | m_afpDistortFunc[21] = TComRdCost::xGetSAD16N; |
---|
220 | |
---|
221 | #if AMP_SAD |
---|
222 | m_afpDistortFunc[43] = TComRdCost::xGetSAD12; |
---|
223 | m_afpDistortFunc[44] = TComRdCost::xGetSAD24; |
---|
224 | m_afpDistortFunc[45] = TComRdCost::xGetSAD48; |
---|
225 | |
---|
226 | m_afpDistortFunc[46] = TComRdCost::xGetSAD12; |
---|
227 | m_afpDistortFunc[47] = TComRdCost::xGetSAD24; |
---|
228 | m_afpDistortFunc[48] = TComRdCost::xGetSAD48; |
---|
229 | #endif |
---|
230 | m_afpDistortFunc[22] = TComRdCost::xGetHADs; |
---|
231 | m_afpDistortFunc[23] = TComRdCost::xGetHADs; |
---|
232 | m_afpDistortFunc[24] = TComRdCost::xGetHADs; |
---|
233 | m_afpDistortFunc[25] = TComRdCost::xGetHADs; |
---|
234 | m_afpDistortFunc[26] = TComRdCost::xGetHADs; |
---|
235 | m_afpDistortFunc[27] = TComRdCost::xGetHADs; |
---|
236 | m_afpDistortFunc[28] = TComRdCost::xGetHADs; |
---|
237 | |
---|
238 | #if H_3D_VSO |
---|
239 | // SAIT_VSO_EST_A0033 |
---|
240 | m_afpDistortFunc[29] = TComRdCost::xGetVSD; |
---|
241 | m_afpDistortFunc[30] = TComRdCost::xGetVSD4; |
---|
242 | m_afpDistortFunc[31] = TComRdCost::xGetVSD8; |
---|
243 | m_afpDistortFunc[32] = TComRdCost::xGetVSD16; |
---|
244 | m_afpDistortFunc[33] = TComRdCost::xGetVSD32; |
---|
245 | m_afpDistortFunc[34] = TComRdCost::xGetVSD64; |
---|
246 | m_afpDistortFunc[35] = TComRdCost::xGetVSD16N; |
---|
247 | #endif |
---|
248 | #if !FIX203 |
---|
249 | m_puiComponentCostOriginP = NULL; |
---|
250 | m_puiComponentCost = NULL; |
---|
251 | m_puiVerCost = NULL; |
---|
252 | m_puiHorCost = NULL; |
---|
253 | #endif |
---|
254 | m_uiCost = 0; |
---|
255 | m_iCostScale = 0; |
---|
256 | #if !FIX203 |
---|
257 | m_iSearchLimit = 0xdeaddead; |
---|
258 | #endif |
---|
259 | #if H_3D_VSO |
---|
260 | m_bUseVSO = false; |
---|
261 | m_uiVSOMode = 0; |
---|
262 | m_fpDistortFuncVSO = NULL; |
---|
263 | m_pcRenModel = NULL; |
---|
264 | |
---|
265 | // SAIT_VSO_EST_A0033 |
---|
266 | m_bUseEstimatedVSD = false; |
---|
267 | #endif |
---|
268 | } |
---|
269 | |
---|
270 | #if !FIX203 |
---|
271 | Void TComRdCost::initRateDistortionModel( Int iSubPelSearchLimit ) |
---|
272 | { |
---|
273 | // make it larger |
---|
274 | iSubPelSearchLimit += 4; |
---|
275 | iSubPelSearchLimit *= 8; |
---|
276 | |
---|
277 | if( m_iSearchLimit != iSubPelSearchLimit ) |
---|
278 | { |
---|
279 | xUninit(); |
---|
280 | |
---|
281 | m_iSearchLimit = iSubPelSearchLimit; |
---|
282 | |
---|
283 | m_puiComponentCostOriginP = new UInt[ 4 * iSubPelSearchLimit ]; |
---|
284 | iSubPelSearchLimit *= 2; |
---|
285 | |
---|
286 | m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit; |
---|
287 | |
---|
288 | for( Int n = -iSubPelSearchLimit; n < iSubPelSearchLimit; n++) |
---|
289 | { |
---|
290 | m_puiComponentCost[n] = xGetComponentBits( n ); |
---|
291 | } |
---|
292 | } |
---|
293 | } |
---|
294 | |
---|
295 | Void TComRdCost::xUninit() |
---|
296 | { |
---|
297 | if( NULL != m_puiComponentCostOriginP ) |
---|
298 | { |
---|
299 | delete [] m_puiComponentCostOriginP; |
---|
300 | m_puiComponentCostOriginP = NULL; |
---|
301 | } |
---|
302 | } |
---|
303 | #endif |
---|
304 | |
---|
305 | UInt TComRdCost::xGetComponentBits( Int iVal ) |
---|
306 | { |
---|
307 | UInt uiLength = 1; |
---|
308 | UInt uiTemp = ( iVal <= 0) ? (-iVal<<1)+1: (iVal<<1); |
---|
309 | |
---|
310 | assert ( uiTemp ); |
---|
311 | |
---|
312 | while ( 1 != uiTemp ) |
---|
313 | { |
---|
314 | uiTemp >>= 1; |
---|
315 | uiLength += 2; |
---|
316 | } |
---|
317 | |
---|
318 | return uiLength; |
---|
319 | } |
---|
320 | |
---|
321 | Void TComRdCost::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam ) |
---|
322 | { |
---|
323 | // set Block Width / Height |
---|
324 | rcDistParam.iCols = uiBlkWidth; |
---|
325 | rcDistParam.iRows = uiBlkHeight; |
---|
326 | rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
327 | |
---|
328 | // initialize |
---|
329 | rcDistParam.iSubShift = 0; |
---|
330 | } |
---|
331 | |
---|
332 | // Setting the Distortion Parameter for Inter (ME) |
---|
333 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam ) |
---|
334 | { |
---|
335 | // set Original & Curr Pointer / Stride |
---|
336 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
337 | rcDistParam.pCur = piRefY; |
---|
338 | |
---|
339 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
340 | rcDistParam.iStrideCur = iRefStride; |
---|
341 | |
---|
342 | // set Block Width / Height |
---|
343 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
344 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
345 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
346 | |
---|
347 | #if AMP_SAD |
---|
348 | if (rcDistParam.iCols == 12) |
---|
349 | { |
---|
350 | rcDistParam.DistFunc = m_afpDistortFunc[43 ]; |
---|
351 | } |
---|
352 | else if (rcDistParam.iCols == 24) |
---|
353 | { |
---|
354 | rcDistParam.DistFunc = m_afpDistortFunc[44 ]; |
---|
355 | } |
---|
356 | else if (rcDistParam.iCols == 48) |
---|
357 | { |
---|
358 | rcDistParam.DistFunc = m_afpDistortFunc[45 ]; |
---|
359 | } |
---|
360 | #endif |
---|
361 | |
---|
362 | // initialize |
---|
363 | rcDistParam.iSubShift = 0; |
---|
364 | } |
---|
365 | |
---|
366 | // Setting the Distortion Parameter for Inter (subpel ME with step) |
---|
367 | #if NS_HAD |
---|
368 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME, Bool bUseNSHAD ) |
---|
369 | #else |
---|
370 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME ) |
---|
371 | #endif |
---|
372 | { |
---|
373 | // set Original & Curr Pointer / Stride |
---|
374 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
375 | rcDistParam.pCur = piRefY; |
---|
376 | |
---|
377 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
378 | rcDistParam.iStrideCur = iRefStride * iStep; |
---|
379 | |
---|
380 | // set Step for interpolated buffer |
---|
381 | rcDistParam.iStep = iStep; |
---|
382 | |
---|
383 | // set Block Width / Height |
---|
384 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
385 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
386 | #if NS_HAD |
---|
387 | rcDistParam.bUseNSHAD = bUseNSHAD; |
---|
388 | #endif |
---|
389 | |
---|
390 | // set distortion function |
---|
391 | if ( !bHADME ) |
---|
392 | { |
---|
393 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
394 | #if AMP_SAD |
---|
395 | if (rcDistParam.iCols == 12) |
---|
396 | { |
---|
397 | rcDistParam.DistFunc = m_afpDistortFunc[46 ]; |
---|
398 | } |
---|
399 | else if (rcDistParam.iCols == 24) |
---|
400 | { |
---|
401 | rcDistParam.DistFunc = m_afpDistortFunc[47 ]; |
---|
402 | } |
---|
403 | else if (rcDistParam.iCols == 48) |
---|
404 | { |
---|
405 | rcDistParam.DistFunc = m_afpDistortFunc[48 ]; |
---|
406 | } |
---|
407 | #endif |
---|
408 | } |
---|
409 | else |
---|
410 | { |
---|
411 | rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
412 | } |
---|
413 | |
---|
414 | // initialize |
---|
415 | rcDistParam.iSubShift = 0; |
---|
416 | } |
---|
417 | |
---|
418 | Void |
---|
419 | #if NS_HAD |
---|
420 | TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard, Bool bUseNSHAD ) |
---|
421 | #else |
---|
422 | TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard ) |
---|
423 | #endif |
---|
424 | { |
---|
425 | rcDP.pOrg = p1; |
---|
426 | rcDP.pCur = p2; |
---|
427 | rcDP.iStrideOrg = iStride1; |
---|
428 | rcDP.iStrideCur = iStride2; |
---|
429 | rcDP.iCols = iWidth; |
---|
430 | rcDP.iRows = iHeight; |
---|
431 | rcDP.iStep = 1; |
---|
432 | rcDP.iSubShift = 0; |
---|
433 | rcDP.bitDepth = bitDepth; |
---|
434 | rcDP.DistFunc = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ]; |
---|
435 | #if NS_HAD |
---|
436 | rcDP.bUseNSHAD = bUseNSHAD; |
---|
437 | #endif |
---|
438 | } |
---|
439 | |
---|
440 | UInt TComRdCost::calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight ) |
---|
441 | { |
---|
442 | UInt uiSum = 0; |
---|
443 | Int x, y; |
---|
444 | |
---|
445 | if ( ( (iWidth % 8) == 0 ) && ( (iHeight % 8) == 0 ) ) |
---|
446 | { |
---|
447 | for ( y=0; y<iHeight; y+= 8 ) |
---|
448 | { |
---|
449 | for ( x=0; x<iWidth; x+= 8 ) |
---|
450 | { |
---|
451 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
452 | } |
---|
453 | pi0 += iStride0*8; |
---|
454 | pi1 += iStride1*8; |
---|
455 | } |
---|
456 | } |
---|
457 | else if ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) ) |
---|
458 | { |
---|
459 | for ( y=0; y<iHeight; y+= 4 ) |
---|
460 | { |
---|
461 | for ( x=0; x<iWidth; x+= 4 ) |
---|
462 | { |
---|
463 | uiSum += xCalcHADs4x4( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
464 | } |
---|
465 | pi0 += iStride0*4; |
---|
466 | pi1 += iStride1*4; |
---|
467 | } |
---|
468 | } |
---|
469 | else |
---|
470 | { |
---|
471 | for ( y=0; y<iHeight; y+= 2 ) |
---|
472 | { |
---|
473 | for ( x=0; x<iWidth; x+= 2 ) |
---|
474 | { |
---|
475 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
476 | } |
---|
477 | pi0 += iStride0*2; |
---|
478 | pi1 += iStride1*2; |
---|
479 | } |
---|
480 | } |
---|
481 | |
---|
482 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); |
---|
483 | |
---|
484 | } |
---|
485 | |
---|
486 | #if WEIGHTED_CHROMA_DISTORTION |
---|
487 | UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText, DFunc eDFunc) |
---|
488 | #else |
---|
489 | UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc ) |
---|
490 | #endif |
---|
491 | { |
---|
492 | DistParam cDtParam; |
---|
493 | setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam ); |
---|
494 | cDtParam.pOrg = piOrg; |
---|
495 | cDtParam.pCur = piCur; |
---|
496 | cDtParam.iStrideOrg = iOrgStride; |
---|
497 | cDtParam.iStrideCur = iCurStride; |
---|
498 | cDtParam.iStep = 1; |
---|
499 | |
---|
500 | cDtParam.bApplyWeight = false; |
---|
501 | cDtParam.uiComp = 255; // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed. |
---|
502 | cDtParam.bitDepth = bitDepth; |
---|
503 | |
---|
504 | #if WEIGHTED_CHROMA_DISTORTION |
---|
505 | if (eText == TEXT_CHROMA_U) |
---|
506 | { |
---|
507 | return ((Int) (m_cbDistortionWeight * cDtParam.DistFunc( &cDtParam ))); |
---|
508 | } |
---|
509 | else if (eText == TEXT_CHROMA_V) |
---|
510 | { |
---|
511 | return ((Int) (m_crDistortionWeight * cDtParam.DistFunc( &cDtParam ))); |
---|
512 | } |
---|
513 | else |
---|
514 | { |
---|
515 | return cDtParam.DistFunc( &cDtParam ); |
---|
516 | } |
---|
517 | #else |
---|
518 | return cDtParam.DistFunc( &cDtParam ); |
---|
519 | #endif |
---|
520 | } |
---|
521 | #if H_3D_VSO |
---|
522 | // SAIT_VSO_EST_A0033 |
---|
523 | UInt TComRdCost::getDistPartVSD( TComDataCU* pcCU, UInt uiPartOffset, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHAD, DFunc eDFunc ) |
---|
524 | { |
---|
525 | AOT( ( m_dDisparityCoeff <= 0 ) || ( m_dDisparityCoeff > 10 ) ); |
---|
526 | |
---|
527 | Pel* piVirRec = m_pcVideoRecPicYuv->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset); |
---|
528 | Pel* piVirOrg = m_pcDepthPicYuv ->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()+uiPartOffset); |
---|
529 | Int iVirStride = m_pcVideoRecPicYuv->getStride(); |
---|
530 | |
---|
531 | DistParam cDtParam; |
---|
532 | setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam ); |
---|
533 | cDtParam.pOrg = piOrg; |
---|
534 | cDtParam.pCur = piCur; |
---|
535 | cDtParam.pVirRec = piVirRec; |
---|
536 | cDtParam.pVirOrg = piVirOrg; |
---|
537 | cDtParam.iStrideVir = iVirStride; |
---|
538 | cDtParam.iStrideOrg = iOrgStride; |
---|
539 | cDtParam.iStrideCur = iCurStride; |
---|
540 | cDtParam.iStep = 1; |
---|
541 | |
---|
542 | cDtParam.bApplyWeight = false; |
---|
543 | cDtParam.uiComp = 255; // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed. |
---|
544 | |
---|
545 | Dist dist = cDtParam.DistFunc( &cDtParam ); |
---|
546 | |
---|
547 | if ( m_bUseWVSO ) |
---|
548 | { |
---|
549 | Int iDWeight = m_iDWeight * m_iDWeight; |
---|
550 | Int iVSOWeight = m_iVSDWeight * m_iVSDWeight; |
---|
551 | Dist distDepth; |
---|
552 | |
---|
553 | if ( !bHAD ) |
---|
554 | { |
---|
555 | distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
556 | } |
---|
557 | else |
---|
558 | { |
---|
559 | distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
560 | } |
---|
561 | |
---|
562 | dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight); |
---|
563 | } |
---|
564 | return dist; |
---|
565 | |
---|
566 | } |
---|
567 | #endif |
---|
568 | |
---|
569 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
570 | UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride, Pel* pelOrg, Int orgStride, UInt width, UInt height ) |
---|
571 | { |
---|
572 | UInt SAD = 0; |
---|
573 | Int shift = DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8); |
---|
574 | for ( Int i=0; i<height; i++ ) |
---|
575 | { |
---|
576 | for( Int j=0; j<width; j++ ) |
---|
577 | { |
---|
578 | SAD += abs((pelCur[j] - pelOrg[j])) >> shift; |
---|
579 | } |
---|
580 | pelCur = pelCur + curStride; |
---|
581 | pelOrg = pelOrg + orgStride; |
---|
582 | } |
---|
583 | return SAD; |
---|
584 | } |
---|
585 | #endif |
---|
586 | |
---|
587 | // ==================================================================================================================== |
---|
588 | // Distortion functions |
---|
589 | // ==================================================================================================================== |
---|
590 | |
---|
591 | // -------------------------------------------------------------------------------------------------------------------- |
---|
592 | // SAD |
---|
593 | // -------------------------------------------------------------------------------------------------------------------- |
---|
594 | |
---|
595 | UInt TComRdCost::xGetSAD( DistParam* pcDtParam ) |
---|
596 | { |
---|
597 | if ( pcDtParam->bApplyWeight ) |
---|
598 | { |
---|
599 | return xGetSADw( pcDtParam ); |
---|
600 | } |
---|
601 | Pel* piOrg = pcDtParam->pOrg; |
---|
602 | Pel* piCur = pcDtParam->pCur; |
---|
603 | Int iRows = pcDtParam->iRows; |
---|
604 | Int iCols = pcDtParam->iCols; |
---|
605 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
606 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
607 | |
---|
608 | UInt uiSum = 0; |
---|
609 | |
---|
610 | for( ; iRows != 0; iRows-- ) |
---|
611 | { |
---|
612 | for (Int n = 0; n < iCols; n++ ) |
---|
613 | { |
---|
614 | uiSum += abs( piOrg[n] - piCur[n] ); |
---|
615 | } |
---|
616 | piOrg += iStrideOrg; |
---|
617 | piCur += iStrideCur; |
---|
618 | } |
---|
619 | |
---|
620 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
621 | } |
---|
622 | |
---|
623 | UInt TComRdCost::xGetSAD4( DistParam* pcDtParam ) |
---|
624 | { |
---|
625 | if ( pcDtParam->bApplyWeight ) |
---|
626 | { |
---|
627 | return xGetSADw( pcDtParam ); |
---|
628 | } |
---|
629 | Pel* piOrg = pcDtParam->pOrg; |
---|
630 | Pel* piCur = pcDtParam->pCur; |
---|
631 | Int iRows = pcDtParam->iRows; |
---|
632 | Int iSubShift = pcDtParam->iSubShift; |
---|
633 | Int iSubStep = ( 1 << iSubShift ); |
---|
634 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
635 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
636 | |
---|
637 | UInt uiSum = 0; |
---|
638 | |
---|
639 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
640 | { |
---|
641 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
642 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
643 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
644 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
645 | |
---|
646 | piOrg += iStrideOrg; |
---|
647 | piCur += iStrideCur; |
---|
648 | } |
---|
649 | |
---|
650 | uiSum <<= iSubShift; |
---|
651 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
652 | } |
---|
653 | |
---|
654 | UInt TComRdCost::xGetSAD8( DistParam* pcDtParam ) |
---|
655 | { |
---|
656 | if ( pcDtParam->bApplyWeight ) |
---|
657 | { |
---|
658 | return xGetSADw( pcDtParam ); |
---|
659 | } |
---|
660 | Pel* piOrg = pcDtParam->pOrg; |
---|
661 | Pel* piCur = pcDtParam->pCur; |
---|
662 | Int iRows = pcDtParam->iRows; |
---|
663 | Int iSubShift = pcDtParam->iSubShift; |
---|
664 | Int iSubStep = ( 1 << iSubShift ); |
---|
665 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
666 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
667 | |
---|
668 | UInt uiSum = 0; |
---|
669 | |
---|
670 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
671 | { |
---|
672 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
673 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
674 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
675 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
676 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
677 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
678 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
679 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
680 | |
---|
681 | piOrg += iStrideOrg; |
---|
682 | piCur += iStrideCur; |
---|
683 | } |
---|
684 | |
---|
685 | uiSum <<= iSubShift; |
---|
686 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
687 | } |
---|
688 | |
---|
689 | UInt TComRdCost::xGetSAD16( DistParam* pcDtParam ) |
---|
690 | { |
---|
691 | if ( pcDtParam->bApplyWeight ) |
---|
692 | { |
---|
693 | return xGetSADw( pcDtParam ); |
---|
694 | } |
---|
695 | Pel* piOrg = pcDtParam->pOrg; |
---|
696 | Pel* piCur = pcDtParam->pCur; |
---|
697 | Int iRows = pcDtParam->iRows; |
---|
698 | Int iSubShift = pcDtParam->iSubShift; |
---|
699 | Int iSubStep = ( 1 << iSubShift ); |
---|
700 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
701 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
702 | |
---|
703 | UInt uiSum = 0; |
---|
704 | |
---|
705 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
706 | { |
---|
707 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
708 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
709 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
710 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
711 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
712 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
713 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
714 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
715 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
716 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
717 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
718 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
719 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
720 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
721 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
722 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
723 | |
---|
724 | piOrg += iStrideOrg; |
---|
725 | piCur += iStrideCur; |
---|
726 | } |
---|
727 | |
---|
728 | uiSum <<= iSubShift; |
---|
729 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
730 | } |
---|
731 | |
---|
732 | #if AMP_SAD |
---|
733 | UInt TComRdCost::xGetSAD12( DistParam* pcDtParam ) |
---|
734 | { |
---|
735 | if ( pcDtParam->bApplyWeight ) |
---|
736 | { |
---|
737 | return xGetSADw( pcDtParam ); |
---|
738 | } |
---|
739 | Pel* piOrg = pcDtParam->pOrg; |
---|
740 | Pel* piCur = pcDtParam->pCur; |
---|
741 | Int iRows = pcDtParam->iRows; |
---|
742 | Int iSubShift = pcDtParam->iSubShift; |
---|
743 | Int iSubStep = ( 1 << iSubShift ); |
---|
744 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
745 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
746 | |
---|
747 | UInt uiSum = 0; |
---|
748 | |
---|
749 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
750 | { |
---|
751 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
752 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
753 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
754 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
755 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
756 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
757 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
758 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
759 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
760 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
761 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
762 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
763 | |
---|
764 | piOrg += iStrideOrg; |
---|
765 | piCur += iStrideCur; |
---|
766 | } |
---|
767 | |
---|
768 | uiSum <<= iSubShift; |
---|
769 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
770 | } |
---|
771 | #endif |
---|
772 | |
---|
773 | UInt TComRdCost::xGetSAD16N( DistParam* pcDtParam ) |
---|
774 | { |
---|
775 | Pel* piOrg = pcDtParam->pOrg; |
---|
776 | Pel* piCur = pcDtParam->pCur; |
---|
777 | Int iRows = pcDtParam->iRows; |
---|
778 | Int iCols = pcDtParam->iCols; |
---|
779 | Int iSubShift = pcDtParam->iSubShift; |
---|
780 | Int iSubStep = ( 1 << iSubShift ); |
---|
781 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
782 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
783 | |
---|
784 | UInt uiSum = 0; |
---|
785 | |
---|
786 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
787 | { |
---|
788 | for (Int n = 0; n < iCols; n+=16 ) |
---|
789 | { |
---|
790 | uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] ); |
---|
791 | uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] ); |
---|
792 | uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] ); |
---|
793 | uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] ); |
---|
794 | uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] ); |
---|
795 | uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] ); |
---|
796 | uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] ); |
---|
797 | uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] ); |
---|
798 | uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] ); |
---|
799 | uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] ); |
---|
800 | uiSum += abs( piOrg[n+10] - piCur[n+10] ); |
---|
801 | uiSum += abs( piOrg[n+11] - piCur[n+11] ); |
---|
802 | uiSum += abs( piOrg[n+12] - piCur[n+12] ); |
---|
803 | uiSum += abs( piOrg[n+13] - piCur[n+13] ); |
---|
804 | uiSum += abs( piOrg[n+14] - piCur[n+14] ); |
---|
805 | uiSum += abs( piOrg[n+15] - piCur[n+15] ); |
---|
806 | } |
---|
807 | piOrg += iStrideOrg; |
---|
808 | piCur += iStrideCur; |
---|
809 | } |
---|
810 | |
---|
811 | uiSum <<= iSubShift; |
---|
812 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
813 | } |
---|
814 | |
---|
815 | UInt TComRdCost::xGetSAD32( DistParam* pcDtParam ) |
---|
816 | { |
---|
817 | if ( pcDtParam->bApplyWeight ) |
---|
818 | { |
---|
819 | return xGetSADw( pcDtParam ); |
---|
820 | } |
---|
821 | Pel* piOrg = pcDtParam->pOrg; |
---|
822 | Pel* piCur = pcDtParam->pCur; |
---|
823 | Int iRows = pcDtParam->iRows; |
---|
824 | Int iSubShift = pcDtParam->iSubShift; |
---|
825 | Int iSubStep = ( 1 << iSubShift ); |
---|
826 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
827 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
828 | |
---|
829 | UInt uiSum = 0; |
---|
830 | |
---|
831 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
832 | { |
---|
833 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
834 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
835 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
836 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
837 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
838 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
839 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
840 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
841 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
842 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
843 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
844 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
845 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
846 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
847 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
848 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
849 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
850 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
851 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
852 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
853 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
854 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
855 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
856 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
857 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
858 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
859 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
860 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
861 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
862 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
863 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
864 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
865 | |
---|
866 | piOrg += iStrideOrg; |
---|
867 | piCur += iStrideCur; |
---|
868 | } |
---|
869 | |
---|
870 | uiSum <<= iSubShift; |
---|
871 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
872 | } |
---|
873 | |
---|
874 | #if AMP_SAD |
---|
875 | UInt TComRdCost::xGetSAD24( DistParam* pcDtParam ) |
---|
876 | { |
---|
877 | if ( pcDtParam->bApplyWeight ) |
---|
878 | { |
---|
879 | return xGetSADw( pcDtParam ); |
---|
880 | } |
---|
881 | Pel* piOrg = pcDtParam->pOrg; |
---|
882 | Pel* piCur = pcDtParam->pCur; |
---|
883 | Int iRows = pcDtParam->iRows; |
---|
884 | Int iSubShift = pcDtParam->iSubShift; |
---|
885 | Int iSubStep = ( 1 << iSubShift ); |
---|
886 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
887 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
888 | |
---|
889 | UInt uiSum = 0; |
---|
890 | |
---|
891 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
892 | { |
---|
893 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
894 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
895 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
896 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
897 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
898 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
899 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
900 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
901 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
902 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
903 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
904 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
905 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
906 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
907 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
908 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
909 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
910 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
911 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
912 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
913 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
914 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
915 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
916 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
917 | |
---|
918 | piOrg += iStrideOrg; |
---|
919 | piCur += iStrideCur; |
---|
920 | } |
---|
921 | |
---|
922 | uiSum <<= iSubShift; |
---|
923 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
924 | } |
---|
925 | |
---|
926 | #endif |
---|
927 | |
---|
928 | UInt TComRdCost::xGetSAD64( DistParam* pcDtParam ) |
---|
929 | { |
---|
930 | if ( pcDtParam->bApplyWeight ) |
---|
931 | { |
---|
932 | return xGetSADw( pcDtParam ); |
---|
933 | } |
---|
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 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
951 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
952 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
953 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
954 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
955 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
956 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
957 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
958 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
959 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
960 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
961 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
962 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
963 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
964 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
965 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
966 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
967 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
968 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
969 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
970 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
971 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
972 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
973 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
974 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
975 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
976 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
977 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
978 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
979 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
980 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
981 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
982 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
983 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
984 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
985 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
986 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
987 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
988 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
989 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
990 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
991 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
992 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
993 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
994 | uiSum += abs( piOrg[48] - piCur[48] ); |
---|
995 | uiSum += abs( piOrg[49] - piCur[49] ); |
---|
996 | uiSum += abs( piOrg[50] - piCur[50] ); |
---|
997 | uiSum += abs( piOrg[51] - piCur[51] ); |
---|
998 | uiSum += abs( piOrg[52] - piCur[52] ); |
---|
999 | uiSum += abs( piOrg[53] - piCur[53] ); |
---|
1000 | uiSum += abs( piOrg[54] - piCur[54] ); |
---|
1001 | uiSum += abs( piOrg[55] - piCur[55] ); |
---|
1002 | uiSum += abs( piOrg[56] - piCur[56] ); |
---|
1003 | uiSum += abs( piOrg[57] - piCur[57] ); |
---|
1004 | uiSum += abs( piOrg[58] - piCur[58] ); |
---|
1005 | uiSum += abs( piOrg[59] - piCur[59] ); |
---|
1006 | uiSum += abs( piOrg[60] - piCur[60] ); |
---|
1007 | uiSum += abs( piOrg[61] - piCur[61] ); |
---|
1008 | uiSum += abs( piOrg[62] - piCur[62] ); |
---|
1009 | uiSum += abs( piOrg[63] - piCur[63] ); |
---|
1010 | |
---|
1011 | piOrg += iStrideOrg; |
---|
1012 | piCur += iStrideCur; |
---|
1013 | } |
---|
1014 | |
---|
1015 | uiSum <<= iSubShift; |
---|
1016 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
1017 | } |
---|
1018 | |
---|
1019 | #if AMP_SAD |
---|
1020 | UInt TComRdCost::xGetSAD48( DistParam* pcDtParam ) |
---|
1021 | { |
---|
1022 | if ( pcDtParam->bApplyWeight ) |
---|
1023 | { |
---|
1024 | return xGetSADw( pcDtParam ); |
---|
1025 | } |
---|
1026 | Pel* piOrg = pcDtParam->pOrg; |
---|
1027 | Pel* piCur = pcDtParam->pCur; |
---|
1028 | Int iRows = pcDtParam->iRows; |
---|
1029 | Int iSubShift = pcDtParam->iSubShift; |
---|
1030 | Int iSubStep = ( 1 << iSubShift ); |
---|
1031 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
1032 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
1033 | |
---|
1034 | UInt uiSum = 0; |
---|
1035 | |
---|
1036 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
1037 | { |
---|
1038 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
1039 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
1040 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
1041 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
1042 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
1043 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
1044 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
1045 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
1046 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
1047 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
1048 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
1049 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
1050 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
1051 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
1052 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
1053 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
1054 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
1055 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
1056 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
1057 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
1058 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
1059 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
1060 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
1061 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
1062 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
1063 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
1064 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
1065 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
1066 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
1067 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
1068 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
1069 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
1070 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
1071 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
1072 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
1073 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
1074 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
1075 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
1076 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
1077 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
1078 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
1079 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
1080 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
1081 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
1082 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
1083 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
1084 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
1085 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
1086 | |
---|
1087 | piOrg += iStrideOrg; |
---|
1088 | piCur += iStrideCur; |
---|
1089 | } |
---|
1090 | |
---|
1091 | uiSum <<= iSubShift; |
---|
1092 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
1093 | } |
---|
1094 | #endif |
---|
1095 | |
---|
1096 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1097 | // SSE |
---|
1098 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1099 | |
---|
1100 | UInt TComRdCost::xGetSSE( DistParam* pcDtParam ) |
---|
1101 | { |
---|
1102 | if ( pcDtParam->bApplyWeight ) |
---|
1103 | { |
---|
1104 | return xGetSSEw( pcDtParam ); |
---|
1105 | } |
---|
1106 | Pel* piOrg = pcDtParam->pOrg; |
---|
1107 | Pel* piCur = pcDtParam->pCur; |
---|
1108 | Int iRows = pcDtParam->iRows; |
---|
1109 | Int iCols = pcDtParam->iCols; |
---|
1110 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1111 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1112 | |
---|
1113 | UInt uiSum = 0; |
---|
1114 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1115 | |
---|
1116 | Int iTemp; |
---|
1117 | |
---|
1118 | for( ; iRows != 0; iRows-- ) |
---|
1119 | { |
---|
1120 | for (Int n = 0; n < iCols; n++ ) |
---|
1121 | { |
---|
1122 | iTemp = piOrg[n ] - piCur[n ]; |
---|
1123 | uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1124 | } |
---|
1125 | piOrg += iStrideOrg; |
---|
1126 | piCur += iStrideCur; |
---|
1127 | } |
---|
1128 | |
---|
1129 | return ( uiSum ); |
---|
1130 | } |
---|
1131 | |
---|
1132 | UInt TComRdCost::xGetSSE4( DistParam* pcDtParam ) |
---|
1133 | { |
---|
1134 | if ( pcDtParam->bApplyWeight ) |
---|
1135 | { |
---|
1136 | assert( pcDtParam->iCols == 4 ); |
---|
1137 | return xGetSSEw( pcDtParam ); |
---|
1138 | } |
---|
1139 | Pel* piOrg = pcDtParam->pOrg; |
---|
1140 | Pel* piCur = pcDtParam->pCur; |
---|
1141 | Int iRows = pcDtParam->iRows; |
---|
1142 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1143 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1144 | |
---|
1145 | UInt uiSum = 0; |
---|
1146 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1147 | |
---|
1148 | Int iTemp; |
---|
1149 | |
---|
1150 | for( ; iRows != 0; iRows-- ) |
---|
1151 | { |
---|
1152 | |
---|
1153 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1154 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1155 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1156 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1157 | |
---|
1158 | piOrg += iStrideOrg; |
---|
1159 | piCur += iStrideCur; |
---|
1160 | } |
---|
1161 | |
---|
1162 | return ( uiSum ); |
---|
1163 | } |
---|
1164 | |
---|
1165 | UInt TComRdCost::xGetSSE8( DistParam* pcDtParam ) |
---|
1166 | { |
---|
1167 | if ( pcDtParam->bApplyWeight ) |
---|
1168 | { |
---|
1169 | assert( pcDtParam->iCols == 8 ); |
---|
1170 | return xGetSSEw( pcDtParam ); |
---|
1171 | } |
---|
1172 | Pel* piOrg = pcDtParam->pOrg; |
---|
1173 | Pel* piCur = pcDtParam->pCur; |
---|
1174 | Int iRows = pcDtParam->iRows; |
---|
1175 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1176 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1177 | |
---|
1178 | UInt uiSum = 0; |
---|
1179 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1180 | |
---|
1181 | Int iTemp; |
---|
1182 | |
---|
1183 | for( ; iRows != 0; iRows-- ) |
---|
1184 | { |
---|
1185 | iTemp = piOrg[0] - piCur[0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1186 | iTemp = piOrg[1] - piCur[1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1187 | iTemp = piOrg[2] - piCur[2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1188 | iTemp = piOrg[3] - piCur[3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1189 | iTemp = piOrg[4] - piCur[4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1190 | iTemp = piOrg[5] - piCur[5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1191 | iTemp = piOrg[6] - piCur[6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1192 | iTemp = piOrg[7] - piCur[7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1193 | |
---|
1194 | piOrg += iStrideOrg; |
---|
1195 | piCur += iStrideCur; |
---|
1196 | } |
---|
1197 | |
---|
1198 | return ( uiSum ); |
---|
1199 | } |
---|
1200 | |
---|
1201 | UInt TComRdCost::xGetSSE16( DistParam* pcDtParam ) |
---|
1202 | { |
---|
1203 | if ( pcDtParam->bApplyWeight ) |
---|
1204 | { |
---|
1205 | assert( pcDtParam->iCols == 16 ); |
---|
1206 | return xGetSSEw( pcDtParam ); |
---|
1207 | } |
---|
1208 | Pel* piOrg = pcDtParam->pOrg; |
---|
1209 | Pel* piCur = pcDtParam->pCur; |
---|
1210 | Int iRows = pcDtParam->iRows; |
---|
1211 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1212 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1213 | |
---|
1214 | UInt uiSum = 0; |
---|
1215 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1216 | |
---|
1217 | Int iTemp; |
---|
1218 | |
---|
1219 | for( ; iRows != 0; iRows-- ) |
---|
1220 | { |
---|
1221 | |
---|
1222 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1223 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1224 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1225 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1226 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1227 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1228 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1229 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1230 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1231 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1232 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1233 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1234 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1235 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1236 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1237 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1238 | |
---|
1239 | piOrg += iStrideOrg; |
---|
1240 | piCur += iStrideCur; |
---|
1241 | } |
---|
1242 | |
---|
1243 | return ( uiSum ); |
---|
1244 | } |
---|
1245 | |
---|
1246 | UInt TComRdCost::xGetSSE16N( DistParam* pcDtParam ) |
---|
1247 | { |
---|
1248 | if ( pcDtParam->bApplyWeight ) |
---|
1249 | { |
---|
1250 | return xGetSSEw( pcDtParam ); |
---|
1251 | } |
---|
1252 | Pel* piOrg = pcDtParam->pOrg; |
---|
1253 | Pel* piCur = pcDtParam->pCur; |
---|
1254 | Int iRows = pcDtParam->iRows; |
---|
1255 | Int iCols = pcDtParam->iCols; |
---|
1256 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1257 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1258 | |
---|
1259 | UInt uiSum = 0; |
---|
1260 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1261 | Int iTemp; |
---|
1262 | |
---|
1263 | for( ; iRows != 0; iRows-- ) |
---|
1264 | { |
---|
1265 | for (Int n = 0; n < iCols; n+=16 ) |
---|
1266 | { |
---|
1267 | |
---|
1268 | iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1269 | iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1270 | iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1271 | iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1272 | iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1273 | iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1274 | iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1275 | iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1276 | iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1277 | iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1278 | iTemp = piOrg[n+10] - piCur[n+10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1279 | iTemp = piOrg[n+11] - piCur[n+11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1280 | iTemp = piOrg[n+12] - piCur[n+12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1281 | iTemp = piOrg[n+13] - piCur[n+13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1282 | iTemp = piOrg[n+14] - piCur[n+14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1283 | iTemp = piOrg[n+15] - piCur[n+15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1284 | |
---|
1285 | } |
---|
1286 | piOrg += iStrideOrg; |
---|
1287 | piCur += iStrideCur; |
---|
1288 | } |
---|
1289 | |
---|
1290 | return ( uiSum ); |
---|
1291 | } |
---|
1292 | |
---|
1293 | UInt TComRdCost::xGetSSE32( DistParam* pcDtParam ) |
---|
1294 | { |
---|
1295 | if ( pcDtParam->bApplyWeight ) |
---|
1296 | { |
---|
1297 | assert( pcDtParam->iCols == 32 ); |
---|
1298 | return xGetSSEw( pcDtParam ); |
---|
1299 | } |
---|
1300 | Pel* piOrg = pcDtParam->pOrg; |
---|
1301 | Pel* piCur = pcDtParam->pCur; |
---|
1302 | Int iRows = pcDtParam->iRows; |
---|
1303 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1304 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1305 | |
---|
1306 | UInt uiSum = 0; |
---|
1307 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1308 | Int iTemp; |
---|
1309 | |
---|
1310 | for( ; iRows != 0; iRows-- ) |
---|
1311 | { |
---|
1312 | |
---|
1313 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1314 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1315 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1316 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1317 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1318 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1319 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1320 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1321 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1322 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1323 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1324 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1325 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1326 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1327 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1328 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1329 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1330 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1331 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1332 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1333 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1334 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1335 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1336 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1337 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1338 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1339 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1340 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1341 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1342 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1343 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1344 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1345 | |
---|
1346 | piOrg += iStrideOrg; |
---|
1347 | piCur += iStrideCur; |
---|
1348 | } |
---|
1349 | |
---|
1350 | return ( uiSum ); |
---|
1351 | } |
---|
1352 | |
---|
1353 | UInt TComRdCost::xGetSSE64( DistParam* pcDtParam ) |
---|
1354 | { |
---|
1355 | if ( pcDtParam->bApplyWeight ) |
---|
1356 | { |
---|
1357 | assert( pcDtParam->iCols == 64 ); |
---|
1358 | return xGetSSEw( pcDtParam ); |
---|
1359 | } |
---|
1360 | Pel* piOrg = pcDtParam->pOrg; |
---|
1361 | Pel* piCur = pcDtParam->pCur; |
---|
1362 | Int iRows = pcDtParam->iRows; |
---|
1363 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1364 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1365 | |
---|
1366 | UInt uiSum = 0; |
---|
1367 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1368 | Int iTemp; |
---|
1369 | |
---|
1370 | for( ; iRows != 0; iRows-- ) |
---|
1371 | { |
---|
1372 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1373 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1374 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1375 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1376 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1377 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1378 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1379 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1380 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1381 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1382 | iTemp = piOrg[10] - piCur[10]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1383 | iTemp = piOrg[11] - piCur[11]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1384 | iTemp = piOrg[12] - piCur[12]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1385 | iTemp = piOrg[13] - piCur[13]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1386 | iTemp = piOrg[14] - piCur[14]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1387 | iTemp = piOrg[15] - piCur[15]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1388 | iTemp = piOrg[16] - piCur[16]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1389 | iTemp = piOrg[17] - piCur[17]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1390 | iTemp = piOrg[18] - piCur[18]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1391 | iTemp = piOrg[19] - piCur[19]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1392 | iTemp = piOrg[20] - piCur[20]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1393 | iTemp = piOrg[21] - piCur[21]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1394 | iTemp = piOrg[22] - piCur[22]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1395 | iTemp = piOrg[23] - piCur[23]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1396 | iTemp = piOrg[24] - piCur[24]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1397 | iTemp = piOrg[25] - piCur[25]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1398 | iTemp = piOrg[26] - piCur[26]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1399 | iTemp = piOrg[27] - piCur[27]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1400 | iTemp = piOrg[28] - piCur[28]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1401 | iTemp = piOrg[29] - piCur[29]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1402 | iTemp = piOrg[30] - piCur[30]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1403 | iTemp = piOrg[31] - piCur[31]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1404 | iTemp = piOrg[32] - piCur[32]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1405 | iTemp = piOrg[33] - piCur[33]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1406 | iTemp = piOrg[34] - piCur[34]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1407 | iTemp = piOrg[35] - piCur[35]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1408 | iTemp = piOrg[36] - piCur[36]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1409 | iTemp = piOrg[37] - piCur[37]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1410 | iTemp = piOrg[38] - piCur[38]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1411 | iTemp = piOrg[39] - piCur[39]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1412 | iTemp = piOrg[40] - piCur[40]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1413 | iTemp = piOrg[41] - piCur[41]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1414 | iTemp = piOrg[42] - piCur[42]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1415 | iTemp = piOrg[43] - piCur[43]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1416 | iTemp = piOrg[44] - piCur[44]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1417 | iTemp = piOrg[45] - piCur[45]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1418 | iTemp = piOrg[46] - piCur[46]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1419 | iTemp = piOrg[47] - piCur[47]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1420 | iTemp = piOrg[48] - piCur[48]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1421 | iTemp = piOrg[49] - piCur[49]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1422 | iTemp = piOrg[50] - piCur[50]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1423 | iTemp = piOrg[51] - piCur[51]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1424 | iTemp = piOrg[52] - piCur[52]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1425 | iTemp = piOrg[53] - piCur[53]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1426 | iTemp = piOrg[54] - piCur[54]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1427 | iTemp = piOrg[55] - piCur[55]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1428 | iTemp = piOrg[56] - piCur[56]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1429 | iTemp = piOrg[57] - piCur[57]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1430 | iTemp = piOrg[58] - piCur[58]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1431 | iTemp = piOrg[59] - piCur[59]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1432 | iTemp = piOrg[60] - piCur[60]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1433 | iTemp = piOrg[61] - piCur[61]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1434 | iTemp = piOrg[62] - piCur[62]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1435 | iTemp = piOrg[63] - piCur[63]; uiSum += ( iTemp * iTemp ) >> uiShift; |
---|
1436 | |
---|
1437 | piOrg += iStrideOrg; |
---|
1438 | piCur += iStrideCur; |
---|
1439 | } |
---|
1440 | |
---|
1441 | return ( uiSum ); |
---|
1442 | } |
---|
1443 | #if H_3D_VSO |
---|
1444 | //SAIT_VSO_EST_A0033 |
---|
1445 | UInt TComRdCost::getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride, Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y ) |
---|
1446 | { |
---|
1447 | Double dD; |
---|
1448 | Int iTemp; |
---|
1449 | |
---|
1450 | dD = ( (Double) ( dDM >> DISTORTION_PRECISION_ADJUSTMENT( g_bitDepthY - 8 ) ) ) * m_dDisparityCoeff; |
---|
1451 | |
---|
1452 | 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 ] ) ) ); |
---|
1453 | iTemp = (Int) (((dTemp) < 0)? (Int)((dTemp) - 0.5) : (Int)((dTemp) + 0.5)); |
---|
1454 | |
---|
1455 | return (UInt) ( (iTemp*iTemp)>>1 ); |
---|
1456 | } |
---|
1457 | |
---|
1458 | UInt TComRdCost::xGetVSD( DistParam* pcDtParam ) |
---|
1459 | { |
---|
1460 | Pel* piOrg = pcDtParam->pOrg; |
---|
1461 | Pel* piCur = pcDtParam->pCur; |
---|
1462 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
1463 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
1464 | Int iRows = pcDtParam->iRows; |
---|
1465 | Int iCols = pcDtParam->iCols; |
---|
1466 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1467 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1468 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
1469 | |
---|
1470 | UInt uiSum = 0; |
---|
1471 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
1472 | |
---|
1473 | Int dDM; |
---|
1474 | |
---|
1475 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
1476 | { |
---|
1477 | for (Int x = 0; x < iCols; x++ ) |
---|
1478 | { |
---|
1479 | dDM = (Int) ( piOrg[x ] - piCur[x ] ); |
---|
1480 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
1481 | } |
---|
1482 | piOrg += iStrideOrg; |
---|
1483 | piCur += iStrideCur; |
---|
1484 | } |
---|
1485 | |
---|
1486 | return ( uiSum ); |
---|
1487 | } |
---|
1488 | |
---|
1489 | UInt TComRdCost::xGetVSD4( DistParam* pcDtParam ) |
---|
1490 | { |
---|
1491 | Pel* piOrg = pcDtParam->pOrg; |
---|
1492 | Pel* piCur = pcDtParam->pCur; |
---|
1493 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
1494 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
1495 | Int iRows = pcDtParam->iRows; |
---|
1496 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1497 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1498 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
1499 | |
---|
1500 | UInt uiSum = 0; |
---|
1501 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
1502 | |
---|
1503 | Int dDM; |
---|
1504 | |
---|
1505 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
1506 | { |
---|
1507 | dDM = (Int) ( piOrg[0] - piCur[0] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 0, y ) ) >> uiShift; |
---|
1508 | dDM = (Int) ( piOrg[1] - piCur[1] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 1, y ) ) >> uiShift; |
---|
1509 | dDM = (Int) ( piOrg[2] - piCur[2] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 2, y ) ) >> uiShift; |
---|
1510 | dDM = (Int) ( piOrg[3] - piCur[3] ); uiSum += ( getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, 3, y ) ) >> uiShift; |
---|
1511 | |
---|
1512 | piOrg += iStrideOrg; |
---|
1513 | piCur += iStrideCur; |
---|
1514 | } |
---|
1515 | |
---|
1516 | return ( uiSum ); |
---|
1517 | } |
---|
1518 | |
---|
1519 | UInt TComRdCost::xGetVSD8( DistParam* pcDtParam ) |
---|
1520 | { |
---|
1521 | Pel* piOrg = pcDtParam->pOrg; |
---|
1522 | Pel* piCur = pcDtParam->pCur; |
---|
1523 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
1524 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
1525 | Int iRows = pcDtParam->iRows; |
---|
1526 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1527 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1528 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
1529 | |
---|
1530 | UInt uiSum = 0; |
---|
1531 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
1532 | |
---|
1533 | Int dDM; |
---|
1534 | |
---|
1535 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
1536 | { |
---|
1537 | for (Int x = 0; x < 8; x++ ) |
---|
1538 | { |
---|
1539 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
1540 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
1541 | } |
---|
1542 | piOrg += iStrideOrg; |
---|
1543 | piCur += iStrideCur; |
---|
1544 | } |
---|
1545 | |
---|
1546 | return ( uiSum ); |
---|
1547 | } |
---|
1548 | |
---|
1549 | UInt TComRdCost::xGetVSD16( DistParam* pcDtParam ) |
---|
1550 | { |
---|
1551 | Pel* piOrg = pcDtParam->pOrg; |
---|
1552 | Pel* piCur = pcDtParam->pCur; |
---|
1553 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
1554 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
1555 | Int iRows = pcDtParam->iRows; |
---|
1556 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1557 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1558 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
1559 | |
---|
1560 | UInt uiSum = 0; |
---|
1561 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
1562 | |
---|
1563 | Int dDM; |
---|
1564 | |
---|
1565 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
1566 | { |
---|
1567 | for (Int x = 0; x < 16; x++ ) |
---|
1568 | { |
---|
1569 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
1570 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
1571 | } |
---|
1572 | piOrg += iStrideOrg; |
---|
1573 | piCur += iStrideCur; |
---|
1574 | } |
---|
1575 | |
---|
1576 | return ( uiSum ); |
---|
1577 | } |
---|
1578 | |
---|
1579 | UInt TComRdCost::xGetVSD16N( DistParam* pcDtParam ) |
---|
1580 | { |
---|
1581 | Pel* piOrg = pcDtParam->pOrg; |
---|
1582 | Pel* piCur = pcDtParam->pCur; |
---|
1583 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
1584 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
1585 | Int iRows = pcDtParam->iRows; |
---|
1586 | Int iCols = pcDtParam->iCols; |
---|
1587 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1588 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1589 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
1590 | |
---|
1591 | UInt uiSum = 0; |
---|
1592 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
1593 | |
---|
1594 | Int dDM; |
---|
1595 | |
---|
1596 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
1597 | { |
---|
1598 | for (Int x = 0; x < iCols; x+=16 ) |
---|
1599 | { |
---|
1600 | for ( Int k = 0 ; k < 16 ; k++ ) |
---|
1601 | { |
---|
1602 | dDM = (Int) ( piOrg[x+k] - piCur[x+k] ); |
---|
1603 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x+k, y ) >> uiShift; |
---|
1604 | } |
---|
1605 | } |
---|
1606 | piOrg += iStrideOrg; |
---|
1607 | piCur += iStrideCur; |
---|
1608 | } |
---|
1609 | |
---|
1610 | return ( uiSum ); |
---|
1611 | } |
---|
1612 | |
---|
1613 | UInt TComRdCost::xGetVSD32( DistParam* pcDtParam ) |
---|
1614 | { |
---|
1615 | Pel* piOrg = pcDtParam->pOrg; |
---|
1616 | Pel* piCur = pcDtParam->pCur; |
---|
1617 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
1618 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
1619 | Int iRows = pcDtParam->iRows; |
---|
1620 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1621 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1622 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
1623 | |
---|
1624 | UInt uiSum = 0; |
---|
1625 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
1626 | |
---|
1627 | Int dDM; |
---|
1628 | |
---|
1629 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
1630 | { |
---|
1631 | for (Int x = 0; x < 32 ; x++ ) |
---|
1632 | { |
---|
1633 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
1634 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
1635 | } |
---|
1636 | piOrg += iStrideOrg; |
---|
1637 | piCur += iStrideCur; |
---|
1638 | } |
---|
1639 | |
---|
1640 | return ( uiSum ); |
---|
1641 | } |
---|
1642 | |
---|
1643 | UInt TComRdCost::xGetVSD64( DistParam* pcDtParam ) |
---|
1644 | { |
---|
1645 | Pel* piOrg = pcDtParam->pOrg; |
---|
1646 | Pel* piCur = pcDtParam->pCur; |
---|
1647 | Pel* piVirRec = pcDtParam->pVirRec; |
---|
1648 | Pel* piVirOrg = pcDtParam->pVirOrg; |
---|
1649 | Int iRows = pcDtParam->iRows; |
---|
1650 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1651 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1652 | Int iStrideVir = pcDtParam->iStrideVir; |
---|
1653 | |
---|
1654 | UInt uiSum = 0; |
---|
1655 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1; |
---|
1656 | |
---|
1657 | Int dDM; |
---|
1658 | |
---|
1659 | for ( Int y = 0 ; y < iRows ; y++ ) |
---|
1660 | { |
---|
1661 | for (Int x = 0; x < 64; x++ ) |
---|
1662 | { |
---|
1663 | dDM = (Int) ( piOrg[x] - piCur[x] ); |
---|
1664 | uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift; |
---|
1665 | } |
---|
1666 | piOrg += iStrideOrg; |
---|
1667 | piCur += iStrideCur; |
---|
1668 | } |
---|
1669 | |
---|
1670 | return ( uiSum ); |
---|
1671 | } |
---|
1672 | |
---|
1673 | #endif |
---|
1674 | |
---|
1675 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1676 | // HADAMARD with step (used in fractional search) |
---|
1677 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1678 | |
---|
1679 | UInt TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1680 | { |
---|
1681 | Int satd = 0, diff[4], m[4]; |
---|
1682 | assert( iStep == 1 ); |
---|
1683 | diff[0] = piOrg[0 ] - piCur[0]; |
---|
1684 | diff[1] = piOrg[1 ] - piCur[1]; |
---|
1685 | diff[2] = piOrg[iStrideOrg ] - piCur[0 + iStrideCur]; |
---|
1686 | diff[3] = piOrg[iStrideOrg + 1] - piCur[1 + iStrideCur]; |
---|
1687 | m[0] = diff[0] + diff[2]; |
---|
1688 | m[1] = diff[1] + diff[3]; |
---|
1689 | m[2] = diff[0] - diff[2]; |
---|
1690 | m[3] = diff[1] - diff[3]; |
---|
1691 | |
---|
1692 | satd += abs(m[0] + m[1]); |
---|
1693 | satd += abs(m[0] - m[1]); |
---|
1694 | satd += abs(m[2] + m[3]); |
---|
1695 | satd += abs(m[2] - m[3]); |
---|
1696 | |
---|
1697 | return satd; |
---|
1698 | } |
---|
1699 | |
---|
1700 | UInt TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1701 | { |
---|
1702 | Int k, satd = 0, diff[16], m[16], d[16]; |
---|
1703 | |
---|
1704 | assert( iStep == 1 ); |
---|
1705 | for( k = 0; k < 16; k+=4 ) |
---|
1706 | { |
---|
1707 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1708 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1709 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1710 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1711 | |
---|
1712 | piCur += iStrideCur; |
---|
1713 | piOrg += iStrideOrg; |
---|
1714 | } |
---|
1715 | |
---|
1716 | /*===== hadamard transform =====*/ |
---|
1717 | m[ 0] = diff[ 0] + diff[12]; |
---|
1718 | m[ 1] = diff[ 1] + diff[13]; |
---|
1719 | m[ 2] = diff[ 2] + diff[14]; |
---|
1720 | m[ 3] = diff[ 3] + diff[15]; |
---|
1721 | m[ 4] = diff[ 4] + diff[ 8]; |
---|
1722 | m[ 5] = diff[ 5] + diff[ 9]; |
---|
1723 | m[ 6] = diff[ 6] + diff[10]; |
---|
1724 | m[ 7] = diff[ 7] + diff[11]; |
---|
1725 | m[ 8] = diff[ 4] - diff[ 8]; |
---|
1726 | m[ 9] = diff[ 5] - diff[ 9]; |
---|
1727 | m[10] = diff[ 6] - diff[10]; |
---|
1728 | m[11] = diff[ 7] - diff[11]; |
---|
1729 | m[12] = diff[ 0] - diff[12]; |
---|
1730 | m[13] = diff[ 1] - diff[13]; |
---|
1731 | m[14] = diff[ 2] - diff[14]; |
---|
1732 | m[15] = diff[ 3] - diff[15]; |
---|
1733 | |
---|
1734 | d[ 0] = m[ 0] + m[ 4]; |
---|
1735 | d[ 1] = m[ 1] + m[ 5]; |
---|
1736 | d[ 2] = m[ 2] + m[ 6]; |
---|
1737 | d[ 3] = m[ 3] + m[ 7]; |
---|
1738 | d[ 4] = m[ 8] + m[12]; |
---|
1739 | d[ 5] = m[ 9] + m[13]; |
---|
1740 | d[ 6] = m[10] + m[14]; |
---|
1741 | d[ 7] = m[11] + m[15]; |
---|
1742 | d[ 8] = m[ 0] - m[ 4]; |
---|
1743 | d[ 9] = m[ 1] - m[ 5]; |
---|
1744 | d[10] = m[ 2] - m[ 6]; |
---|
1745 | d[11] = m[ 3] - m[ 7]; |
---|
1746 | d[12] = m[12] - m[ 8]; |
---|
1747 | d[13] = m[13] - m[ 9]; |
---|
1748 | d[14] = m[14] - m[10]; |
---|
1749 | d[15] = m[15] - m[11]; |
---|
1750 | |
---|
1751 | m[ 0] = d[ 0] + d[ 3]; |
---|
1752 | m[ 1] = d[ 1] + d[ 2]; |
---|
1753 | m[ 2] = d[ 1] - d[ 2]; |
---|
1754 | m[ 3] = d[ 0] - d[ 3]; |
---|
1755 | m[ 4] = d[ 4] + d[ 7]; |
---|
1756 | m[ 5] = d[ 5] + d[ 6]; |
---|
1757 | m[ 6] = d[ 5] - d[ 6]; |
---|
1758 | m[ 7] = d[ 4] - d[ 7]; |
---|
1759 | m[ 8] = d[ 8] + d[11]; |
---|
1760 | m[ 9] = d[ 9] + d[10]; |
---|
1761 | m[10] = d[ 9] - d[10]; |
---|
1762 | m[11] = d[ 8] - d[11]; |
---|
1763 | m[12] = d[12] + d[15]; |
---|
1764 | m[13] = d[13] + d[14]; |
---|
1765 | m[14] = d[13] - d[14]; |
---|
1766 | m[15] = d[12] - d[15]; |
---|
1767 | |
---|
1768 | d[ 0] = m[ 0] + m[ 1]; |
---|
1769 | d[ 1] = m[ 0] - m[ 1]; |
---|
1770 | d[ 2] = m[ 2] + m[ 3]; |
---|
1771 | d[ 3] = m[ 3] - m[ 2]; |
---|
1772 | d[ 4] = m[ 4] + m[ 5]; |
---|
1773 | d[ 5] = m[ 4] - m[ 5]; |
---|
1774 | d[ 6] = m[ 6] + m[ 7]; |
---|
1775 | d[ 7] = m[ 7] - m[ 6]; |
---|
1776 | d[ 8] = m[ 8] + m[ 9]; |
---|
1777 | d[ 9] = m[ 8] - m[ 9]; |
---|
1778 | d[10] = m[10] + m[11]; |
---|
1779 | d[11] = m[11] - m[10]; |
---|
1780 | d[12] = m[12] + m[13]; |
---|
1781 | d[13] = m[12] - m[13]; |
---|
1782 | d[14] = m[14] + m[15]; |
---|
1783 | d[15] = m[15] - m[14]; |
---|
1784 | |
---|
1785 | for (k=0; k<16; ++k) |
---|
1786 | { |
---|
1787 | satd += abs(d[k]); |
---|
1788 | } |
---|
1789 | satd = ((satd+1)>>1); |
---|
1790 | |
---|
1791 | return satd; |
---|
1792 | } |
---|
1793 | |
---|
1794 | UInt TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1795 | { |
---|
1796 | Int k, i, j, jj, sad=0; |
---|
1797 | Int diff[64], m1[8][8], m2[8][8], m3[8][8]; |
---|
1798 | assert( iStep == 1 ); |
---|
1799 | for( k = 0; k < 64; k += 8 ) |
---|
1800 | { |
---|
1801 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1802 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1803 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1804 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1805 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
1806 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
1807 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
1808 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
1809 | |
---|
1810 | piCur += iStrideCur; |
---|
1811 | piOrg += iStrideOrg; |
---|
1812 | } |
---|
1813 | |
---|
1814 | //horizontal |
---|
1815 | for (j=0; j < 8; j++) |
---|
1816 | { |
---|
1817 | jj = j << 3; |
---|
1818 | m2[j][0] = diff[jj ] + diff[jj+4]; |
---|
1819 | m2[j][1] = diff[jj+1] + diff[jj+5]; |
---|
1820 | m2[j][2] = diff[jj+2] + diff[jj+6]; |
---|
1821 | m2[j][3] = diff[jj+3] + diff[jj+7]; |
---|
1822 | m2[j][4] = diff[jj ] - diff[jj+4]; |
---|
1823 | m2[j][5] = diff[jj+1] - diff[jj+5]; |
---|
1824 | m2[j][6] = diff[jj+2] - diff[jj+6]; |
---|
1825 | m2[j][7] = diff[jj+3] - diff[jj+7]; |
---|
1826 | |
---|
1827 | m1[j][0] = m2[j][0] + m2[j][2]; |
---|
1828 | m1[j][1] = m2[j][1] + m2[j][3]; |
---|
1829 | m1[j][2] = m2[j][0] - m2[j][2]; |
---|
1830 | m1[j][3] = m2[j][1] - m2[j][3]; |
---|
1831 | m1[j][4] = m2[j][4] + m2[j][6]; |
---|
1832 | m1[j][5] = m2[j][5] + m2[j][7]; |
---|
1833 | m1[j][6] = m2[j][4] - m2[j][6]; |
---|
1834 | m1[j][7] = m2[j][5] - m2[j][7]; |
---|
1835 | |
---|
1836 | m2[j][0] = m1[j][0] + m1[j][1]; |
---|
1837 | m2[j][1] = m1[j][0] - m1[j][1]; |
---|
1838 | m2[j][2] = m1[j][2] + m1[j][3]; |
---|
1839 | m2[j][3] = m1[j][2] - m1[j][3]; |
---|
1840 | m2[j][4] = m1[j][4] + m1[j][5]; |
---|
1841 | m2[j][5] = m1[j][4] - m1[j][5]; |
---|
1842 | m2[j][6] = m1[j][6] + m1[j][7]; |
---|
1843 | m2[j][7] = m1[j][6] - m1[j][7]; |
---|
1844 | } |
---|
1845 | |
---|
1846 | //vertical |
---|
1847 | for (i=0; i < 8; i++) |
---|
1848 | { |
---|
1849 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
1850 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
1851 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
1852 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
1853 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
1854 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
1855 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
1856 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
1857 | |
---|
1858 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
1859 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
1860 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
1861 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
1862 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
1863 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
1864 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
1865 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
1866 | |
---|
1867 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
1868 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
1869 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
1870 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
1871 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
1872 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
1873 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
1874 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
1875 | } |
---|
1876 | |
---|
1877 | for (i = 0; i < 8; i++) |
---|
1878 | { |
---|
1879 | for (j = 0; j < 8; j++) |
---|
1880 | { |
---|
1881 | sad += abs(m2[i][j]); |
---|
1882 | } |
---|
1883 | } |
---|
1884 | |
---|
1885 | sad=((sad+2)>>2); |
---|
1886 | |
---|
1887 | return sad; |
---|
1888 | } |
---|
1889 | |
---|
1890 | #if NS_HAD |
---|
1891 | UInt TComRdCost::xCalcHADs16x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1892 | { |
---|
1893 | Int k, i, j, jj, sad=0; |
---|
1894 | Int diff[64], m1[4][16], m2[4][16]; |
---|
1895 | assert( iStep == 1 ); |
---|
1896 | for( k = 0; k < 64; k += 16 ) |
---|
1897 | { |
---|
1898 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1899 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1900 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1901 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1902 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
1903 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
1904 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
1905 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
1906 | |
---|
1907 | diff[k+8] = piOrg[8] - piCur[8] ; |
---|
1908 | diff[k+9] = piOrg[9] - piCur[9] ; |
---|
1909 | diff[k+10] = piOrg[10] - piCur[10]; |
---|
1910 | diff[k+11] = piOrg[11] - piCur[11]; |
---|
1911 | diff[k+12] = piOrg[12] - piCur[12]; |
---|
1912 | diff[k+13] = piOrg[13] - piCur[13]; |
---|
1913 | diff[k+14] = piOrg[14] - piCur[14]; |
---|
1914 | diff[k+15] = piOrg[15] - piCur[15]; |
---|
1915 | |
---|
1916 | piCur += iStrideCur; |
---|
1917 | piOrg += iStrideOrg; |
---|
1918 | } |
---|
1919 | |
---|
1920 | //horizontal |
---|
1921 | for (j=0; j < 4; j++) |
---|
1922 | { |
---|
1923 | jj = j << 4; |
---|
1924 | |
---|
1925 | m2[j][0] = diff[jj ] + diff[jj+8]; |
---|
1926 | m2[j][1] = diff[jj+1] + diff[jj+9]; |
---|
1927 | m2[j][2] = diff[jj+2] + diff[jj+10]; |
---|
1928 | m2[j][3] = diff[jj+3] + diff[jj+11]; |
---|
1929 | m2[j][4] = diff[jj+4] + diff[jj+12]; |
---|
1930 | m2[j][5] = diff[jj+5] + diff[jj+13]; |
---|
1931 | m2[j][6] = diff[jj+6] + diff[jj+14]; |
---|
1932 | m2[j][7] = diff[jj+7] + diff[jj+15]; |
---|
1933 | m2[j][8] = diff[jj ] - diff[jj+8]; |
---|
1934 | m2[j][9] = diff[jj+1] - diff[jj+9]; |
---|
1935 | m2[j][10] = diff[jj+2] - diff[jj+10]; |
---|
1936 | m2[j][11] = diff[jj+3] - diff[jj+11]; |
---|
1937 | m2[j][12] = diff[jj+4] - diff[jj+12]; |
---|
1938 | m2[j][13] = diff[jj+5] - diff[jj+13]; |
---|
1939 | m2[j][14] = diff[jj+6] - diff[jj+14]; |
---|
1940 | m2[j][15] = diff[jj+7] - diff[jj+15]; |
---|
1941 | |
---|
1942 | m1[j][0] = m2[j][0] + m2[j][4]; |
---|
1943 | m1[j][1] = m2[j][1] + m2[j][5]; |
---|
1944 | m1[j][2] = m2[j][2] + m2[j][6]; |
---|
1945 | m1[j][3] = m2[j][3] + m2[j][7]; |
---|
1946 | m1[j][4] = m2[j][0] - m2[j][4]; |
---|
1947 | m1[j][5] = m2[j][1] - m2[j][5]; |
---|
1948 | m1[j][6] = m2[j][2] - m2[j][6]; |
---|
1949 | m1[j][7] = m2[j][3] - m2[j][7]; |
---|
1950 | m1[j][8] = m2[j][8] + m2[j][12]; |
---|
1951 | m1[j][9] = m2[j][9] + m2[j][13]; |
---|
1952 | m1[j][10] = m2[j][10] + m2[j][14]; |
---|
1953 | m1[j][11] = m2[j][11] + m2[j][15]; |
---|
1954 | m1[j][12] = m2[j][8] - m2[j][12]; |
---|
1955 | m1[j][13] = m2[j][9] - m2[j][13]; |
---|
1956 | m1[j][14] = m2[j][10] - m2[j][14]; |
---|
1957 | m1[j][15] = m2[j][11] - m2[j][15]; |
---|
1958 | |
---|
1959 | m2[j][0] = m1[j][0] + m1[j][2]; |
---|
1960 | m2[j][1] = m1[j][1] + m1[j][3]; |
---|
1961 | m2[j][2] = m1[j][0] - m1[j][2]; |
---|
1962 | m2[j][3] = m1[j][1] - m1[j][3]; |
---|
1963 | m2[j][4] = m1[j][4] + m1[j][6]; |
---|
1964 | m2[j][5] = m1[j][5] + m1[j][7]; |
---|
1965 | m2[j][6] = m1[j][4] - m1[j][6]; |
---|
1966 | m2[j][7] = m1[j][5] - m1[j][7]; |
---|
1967 | m2[j][8] = m1[j][8] + m1[j][10]; |
---|
1968 | m2[j][9] = m1[j][9] + m1[j][11]; |
---|
1969 | m2[j][10] = m1[j][8] - m1[j][10]; |
---|
1970 | m2[j][11] = m1[j][9] - m1[j][11]; |
---|
1971 | m2[j][12] = m1[j][12] + m1[j][14]; |
---|
1972 | m2[j][13] = m1[j][13] + m1[j][15]; |
---|
1973 | m2[j][14] = m1[j][12] - m1[j][14]; |
---|
1974 | m2[j][15] = m1[j][13] - m1[j][15]; |
---|
1975 | |
---|
1976 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
1977 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
1978 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
1979 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
1980 | m1[j][4] = m2[j][4] + m2[j][5]; |
---|
1981 | m1[j][5] = m2[j][4] - m2[j][5]; |
---|
1982 | m1[j][6] = m2[j][6] + m2[j][7]; |
---|
1983 | m1[j][7] = m2[j][6] - m2[j][7]; |
---|
1984 | m1[j][8] = m2[j][8] + m2[j][9]; |
---|
1985 | m1[j][9] = m2[j][8] - m2[j][9]; |
---|
1986 | m1[j][10] = m2[j][10] + m2[j][11]; |
---|
1987 | m1[j][11] = m2[j][10] - m2[j][11]; |
---|
1988 | m1[j][12] = m2[j][12] + m2[j][13]; |
---|
1989 | m1[j][13] = m2[j][12] - m2[j][13]; |
---|
1990 | m1[j][14] = m2[j][14] + m2[j][15]; |
---|
1991 | m1[j][15] = m2[j][14] - m2[j][15]; |
---|
1992 | } |
---|
1993 | |
---|
1994 | //vertical |
---|
1995 | for (i=0; i < 16; i++) |
---|
1996 | { |
---|
1997 | m2[0][i] = m1[0][i] + m1[2][i]; |
---|
1998 | m2[1][i] = m1[1][i] + m1[3][i]; |
---|
1999 | m2[2][i] = m1[0][i] - m1[2][i]; |
---|
2000 | m2[3][i] = m1[1][i] - m1[3][i]; |
---|
2001 | |
---|
2002 | m1[0][i] = m2[0][i] + m2[1][i]; |
---|
2003 | m1[1][i] = m2[0][i] - m2[1][i]; |
---|
2004 | m1[2][i] = m2[2][i] + m2[3][i]; |
---|
2005 | m1[3][i] = m2[2][i] - m2[3][i]; |
---|
2006 | } |
---|
2007 | |
---|
2008 | for (i = 0; i < 4; i++) |
---|
2009 | { |
---|
2010 | for (j = 0; j < 16; j++) |
---|
2011 | { |
---|
2012 | sad += abs(m1[i][j]); |
---|
2013 | } |
---|
2014 | } |
---|
2015 | |
---|
2016 | sad=((sad+2)>>2); |
---|
2017 | |
---|
2018 | return sad; |
---|
2019 | } |
---|
2020 | |
---|
2021 | UInt TComRdCost::xCalcHADs4x16( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
2022 | { |
---|
2023 | Int k, i, j, jj, sad=0; |
---|
2024 | Int diff[64], m1[16][4], m2[16][4], m3[16][4]; |
---|
2025 | assert( iStep == 1 ); |
---|
2026 | for( k = 0; k < 64; k += 4 ) |
---|
2027 | { |
---|
2028 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
2029 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
2030 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
2031 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
2032 | |
---|
2033 | piCur += iStrideCur; |
---|
2034 | piOrg += iStrideOrg; |
---|
2035 | } |
---|
2036 | |
---|
2037 | //horizontal |
---|
2038 | for (j=0; j < 16; j++) |
---|
2039 | { |
---|
2040 | jj = j << 2; |
---|
2041 | m2[j][0] = diff[jj ] + diff[jj+2]; |
---|
2042 | m2[j][1] = diff[jj+1] + diff[jj+3]; |
---|
2043 | m2[j][2] = diff[jj ] - diff[jj+2]; |
---|
2044 | m2[j][3] = diff[jj+1] - diff[jj+3]; |
---|
2045 | |
---|
2046 | m1[j][0] = m2[j][0] + m2[j][1]; |
---|
2047 | m1[j][1] = m2[j][0] - m2[j][1]; |
---|
2048 | m1[j][2] = m2[j][2] + m2[j][3]; |
---|
2049 | m1[j][3] = m2[j][2] - m2[j][3]; |
---|
2050 | } |
---|
2051 | |
---|
2052 | //vertical |
---|
2053 | for (i=0; i < 4; i++) |
---|
2054 | { |
---|
2055 | m2[0][i] = m1[0][i] + m1[8][i]; |
---|
2056 | m2[1][i] = m1[1][i] + m1[9][i]; |
---|
2057 | m2[2][i] = m1[2][i] + m1[10][i]; |
---|
2058 | m2[3][i] = m1[3][i] + m1[11][i]; |
---|
2059 | m2[4][i] = m1[4][i] + m1[12][i]; |
---|
2060 | m2[5][i] = m1[5][i] + m1[13][i]; |
---|
2061 | m2[6][i] = m1[6][i] + m1[14][i]; |
---|
2062 | m2[7][i] = m1[7][i] + m1[15][i]; |
---|
2063 | m2[8][i] = m1[0][i] - m1[8][i]; |
---|
2064 | m2[9][i] = m1[1][i] - m1[9][i]; |
---|
2065 | m2[10][i] = m1[2][i] - m1[10][i]; |
---|
2066 | m2[11][i] = m1[3][i] - m1[11][i]; |
---|
2067 | m2[12][i] = m1[4][i] - m1[12][i]; |
---|
2068 | m2[13][i] = m1[5][i] - m1[13][i]; |
---|
2069 | m2[14][i] = m1[6][i] - m1[14][i]; |
---|
2070 | m2[15][i] = m1[7][i] - m1[15][i]; |
---|
2071 | |
---|
2072 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
2073 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
2074 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
2075 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
2076 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
2077 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
2078 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
2079 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
2080 | m3[8][i] = m2[8][i] + m2[12][i]; |
---|
2081 | m3[9][i] = m2[9][i] + m2[13][i]; |
---|
2082 | m3[10][i] = m2[10][i] + m2[14][i]; |
---|
2083 | m3[11][i] = m2[11][i] + m2[15][i]; |
---|
2084 | m3[12][i] = m2[8][i] - m2[12][i]; |
---|
2085 | m3[13][i] = m2[9][i] - m2[13][i]; |
---|
2086 | m3[14][i] = m2[10][i] - m2[14][i]; |
---|
2087 | m3[15][i] = m2[11][i] - m2[15][i]; |
---|
2088 | |
---|
2089 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
2090 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
2091 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
2092 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
2093 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
2094 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
2095 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
2096 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
2097 | m1[8][i] = m3[8][i] + m3[10][i]; |
---|
2098 | m1[9][i] = m3[9][i] + m3[11][i]; |
---|
2099 | m1[10][i] = m3[8][i] - m3[10][i]; |
---|
2100 | m1[11][i] = m3[9][i] - m3[11][i]; |
---|
2101 | m1[12][i] = m3[12][i] + m3[14][i]; |
---|
2102 | m1[13][i] = m3[13][i] + m3[15][i]; |
---|
2103 | m1[14][i] = m3[12][i] - m3[14][i]; |
---|
2104 | m1[15][i] = m3[13][i] - m3[15][i]; |
---|
2105 | |
---|
2106 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
2107 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
2108 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
2109 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
2110 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
2111 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
2112 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
2113 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
2114 | m2[8][i] = m1[8][i] + m1[9][i]; |
---|
2115 | m2[9][i] = m1[8][i] - m1[9][i]; |
---|
2116 | m2[10][i] = m1[10][i] + m1[11][i]; |
---|
2117 | m2[11][i] = m1[10][i] - m1[11][i]; |
---|
2118 | m2[12][i] = m1[12][i] + m1[13][i]; |
---|
2119 | m2[13][i] = m1[12][i] - m1[13][i]; |
---|
2120 | m2[14][i] = m1[14][i] + m1[15][i]; |
---|
2121 | m2[15][i] = m1[14][i] - m1[15][i]; |
---|
2122 | } |
---|
2123 | |
---|
2124 | for (i = 0; i < 16; i++) |
---|
2125 | { |
---|
2126 | for (j = 0; j < 4; j++) |
---|
2127 | { |
---|
2128 | sad += abs(m2[i][j]); |
---|
2129 | } |
---|
2130 | } |
---|
2131 | |
---|
2132 | sad=((sad+2)>>2); |
---|
2133 | |
---|
2134 | return sad; |
---|
2135 | } |
---|
2136 | #endif |
---|
2137 | |
---|
2138 | UInt TComRdCost::xGetHADs4( DistParam* pcDtParam ) |
---|
2139 | { |
---|
2140 | if ( pcDtParam->bApplyWeight ) |
---|
2141 | { |
---|
2142 | return xGetHADs4w( pcDtParam ); |
---|
2143 | } |
---|
2144 | Pel* piOrg = pcDtParam->pOrg; |
---|
2145 | Pel* piCur = pcDtParam->pCur; |
---|
2146 | Int iRows = pcDtParam->iRows; |
---|
2147 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2148 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2149 | Int iStep = pcDtParam->iStep; |
---|
2150 | Int y; |
---|
2151 | Int iOffsetOrg = iStrideOrg<<2; |
---|
2152 | Int iOffsetCur = iStrideCur<<2; |
---|
2153 | |
---|
2154 | UInt uiSum = 0; |
---|
2155 | |
---|
2156 | for ( y=0; y<iRows; y+= 4 ) |
---|
2157 | { |
---|
2158 | uiSum += xCalcHADs4x4( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
2159 | piOrg += iOffsetOrg; |
---|
2160 | piCur += iOffsetCur; |
---|
2161 | } |
---|
2162 | |
---|
2163 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
2164 | } |
---|
2165 | |
---|
2166 | UInt TComRdCost::xGetHADs8( DistParam* pcDtParam ) |
---|
2167 | { |
---|
2168 | if ( pcDtParam->bApplyWeight ) |
---|
2169 | { |
---|
2170 | return xGetHADs8w( pcDtParam ); |
---|
2171 | } |
---|
2172 | Pel* piOrg = pcDtParam->pOrg; |
---|
2173 | Pel* piCur = pcDtParam->pCur; |
---|
2174 | Int iRows = pcDtParam->iRows; |
---|
2175 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2176 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2177 | Int iStep = pcDtParam->iStep; |
---|
2178 | Int y; |
---|
2179 | |
---|
2180 | UInt uiSum = 0; |
---|
2181 | |
---|
2182 | if ( iRows == 4 ) |
---|
2183 | { |
---|
2184 | uiSum += xCalcHADs4x4( piOrg+0, piCur , iStrideOrg, iStrideCur, iStep ); |
---|
2185 | uiSum += xCalcHADs4x4( piOrg+4, piCur+4*iStep, iStrideOrg, iStrideCur, iStep ); |
---|
2186 | } |
---|
2187 | else |
---|
2188 | { |
---|
2189 | Int iOffsetOrg = iStrideOrg<<3; |
---|
2190 | Int iOffsetCur = iStrideCur<<3; |
---|
2191 | for ( y=0; y<iRows; y+= 8 ) |
---|
2192 | { |
---|
2193 | uiSum += xCalcHADs8x8( piOrg, piCur, iStrideOrg, iStrideCur, iStep ); |
---|
2194 | piOrg += iOffsetOrg; |
---|
2195 | piCur += iOffsetCur; |
---|
2196 | } |
---|
2197 | } |
---|
2198 | |
---|
2199 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
2200 | } |
---|
2201 | |
---|
2202 | UInt TComRdCost::xGetHADs( DistParam* pcDtParam ) |
---|
2203 | { |
---|
2204 | if ( pcDtParam->bApplyWeight ) |
---|
2205 | { |
---|
2206 | return xGetHADsw( pcDtParam ); |
---|
2207 | } |
---|
2208 | Pel* piOrg = pcDtParam->pOrg; |
---|
2209 | Pel* piCur = pcDtParam->pCur; |
---|
2210 | Int iRows = pcDtParam->iRows; |
---|
2211 | Int iCols = pcDtParam->iCols; |
---|
2212 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
2213 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
2214 | Int iStep = pcDtParam->iStep; |
---|
2215 | |
---|
2216 | Int x, y; |
---|
2217 | |
---|
2218 | UInt uiSum = 0; |
---|
2219 | |
---|
2220 | #if NS_HAD |
---|
2221 | if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) ) |
---|
2222 | #else |
---|
2223 | if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) |
---|
2224 | #endif |
---|
2225 | { |
---|
2226 | Int iOffsetOrg = iStrideOrg<<3; |
---|
2227 | Int iOffsetCur = iStrideCur<<3; |
---|
2228 | for ( y=0; y<iRows; y+= 8 ) |
---|
2229 | { |
---|
2230 | for ( x=0; x<iCols; x+= 8 ) |
---|
2231 | { |
---|
2232 | uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
2233 | } |
---|
2234 | piOrg += iOffsetOrg; |
---|
2235 | piCur += iOffsetCur; |
---|
2236 | } |
---|
2237 | } |
---|
2238 | #if NS_HAD |
---|
2239 | else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD ) |
---|
2240 | { |
---|
2241 | Int iOffsetOrg = iStrideOrg<<2; |
---|
2242 | Int iOffsetCur = iStrideCur<<2; |
---|
2243 | for ( y=0; y<iRows; y+= 4 ) |
---|
2244 | { |
---|
2245 | for ( x=0; x<iCols; x+= 16 ) |
---|
2246 | { |
---|
2247 | uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
2248 | } |
---|
2249 | piOrg += iOffsetOrg; |
---|
2250 | piCur += iOffsetCur; |
---|
2251 | } |
---|
2252 | } |
---|
2253 | else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD ) |
---|
2254 | { |
---|
2255 | Int iOffsetOrg = iStrideOrg<<4; |
---|
2256 | Int iOffsetCur = iStrideCur<<4; |
---|
2257 | for ( y=0; y<iRows; y+= 16 ) |
---|
2258 | { |
---|
2259 | for ( x=0; x<iCols; x+= 4 ) |
---|
2260 | { |
---|
2261 | uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
2262 | } |
---|
2263 | piOrg += iOffsetOrg; |
---|
2264 | piCur += iOffsetCur; |
---|
2265 | } |
---|
2266 | } |
---|
2267 | #endif |
---|
2268 | else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) |
---|
2269 | { |
---|
2270 | Int iOffsetOrg = iStrideOrg<<2; |
---|
2271 | Int iOffsetCur = iStrideCur<<2; |
---|
2272 | |
---|
2273 | for ( y=0; y<iRows; y+= 4 ) |
---|
2274 | { |
---|
2275 | for ( x=0; x<iCols; x+= 4 ) |
---|
2276 | { |
---|
2277 | uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
2278 | } |
---|
2279 | piOrg += iOffsetOrg; |
---|
2280 | piCur += iOffsetCur; |
---|
2281 | } |
---|
2282 | } |
---|
2283 | else if( ( iRows % 2 == 0) && (iCols % 2 == 0) ) |
---|
2284 | { |
---|
2285 | Int iOffsetOrg = iStrideOrg<<1; |
---|
2286 | Int iOffsetCur = iStrideCur<<1; |
---|
2287 | for ( y=0; y<iRows; y+=2 ) |
---|
2288 | { |
---|
2289 | for ( x=0; x<iCols; x+=2 ) |
---|
2290 | { |
---|
2291 | uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
2292 | } |
---|
2293 | piOrg += iOffsetOrg; |
---|
2294 | piCur += iOffsetCur; |
---|
2295 | } |
---|
2296 | } |
---|
2297 | else |
---|
2298 | { |
---|
2299 | assert(false); |
---|
2300 | } |
---|
2301 | |
---|
2302 | return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8); |
---|
2303 | } |
---|
2304 | #if H_3D_VSO |
---|
2305 | Void TComRdCost::setLambdaVSO( Double dLambdaVSO ) |
---|
2306 | { |
---|
2307 | m_dLambdaVSO = dLambdaVSO; |
---|
2308 | m_dSqrtLambdaVSO = sqrt(m_dLambdaVSO); |
---|
2309 | m_uiLambdaMotionSADVSO = (UInt)floor(65536.0 * m_dSqrtLambdaVSO); |
---|
2310 | m_uiLambdaMotionSSEVSO = (UInt)floor(65536.0 * m_dLambdaVSO ); |
---|
2311 | } |
---|
2312 | |
---|
2313 | Dist TComRdCost::xGetDistVSOMode4( Int iStartPosX, Int iStartPosY, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD ) |
---|
2314 | { |
---|
2315 | AOT(bSAD); |
---|
2316 | #if H_3D_VSO_EARLY_SKIP |
---|
2317 | RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur, piOrg, iOrgStride); |
---|
2318 | #else |
---|
2319 | RMDist iDist = m_pcRenModel->getDist( iStartPosX, iStartPosY, (Int) uiBlkWidth, (Int) uiBlkHeight, iCurStride, piCur ); |
---|
2320 | #endif |
---|
2321 | |
---|
2322 | RMDist iDistMin = (RMDist) RDO_DIST_MIN; |
---|
2323 | iDistMin = m_bAllowNegDist ? RDO_DIST_MIN : 0; |
---|
2324 | |
---|
2325 | iDist = std::min( iDist, (RMDist) RDO_DIST_MAX); |
---|
2326 | iDist = std::max( iDist, iDistMin); |
---|
2327 | return (Dist) iDist; |
---|
2328 | } |
---|
2329 | |
---|
2330 | |
---|
2331 | Dist TComRdCost::getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHAD ) |
---|
2332 | { |
---|
2333 | assert( m_bUseVSO ); |
---|
2334 | assert( this->m_fpDistortFuncVSO != 0 ); |
---|
2335 | |
---|
2336 | Int iPosX; |
---|
2337 | Int iPosY; |
---|
2338 | |
---|
2339 | pcCU->getPosInPic( uiAbsPartIndex, iPosX, iPosY ); |
---|
2340 | |
---|
2341 | Dist dist = (this->*m_fpDistortFuncVSO) ( iPosX, iPosY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight, bHAD ); |
---|
2342 | |
---|
2343 | if ( m_bUseWVSO ) |
---|
2344 | { |
---|
2345 | Int iDWeight = m_iDWeight * m_iDWeight; |
---|
2346 | Int iVSOWeight = m_iVSOWeight * m_iVSOWeight; |
---|
2347 | Dist distDepth; |
---|
2348 | |
---|
2349 | if ( !bHAD ) |
---|
2350 | { |
---|
2351 | distDepth = (Dist) getDistPart( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
2352 | } |
---|
2353 | else |
---|
2354 | { |
---|
2355 | distDepth = (Dist) calcHAD( g_bitDepthY, piCur, iCurStride, piOrg, iOrgStride, uiBlkWidth, uiBlkHeight); |
---|
2356 | } |
---|
2357 | |
---|
2358 | dist = (Dist) (iDWeight * distDepth + iVSOWeight * dist ) / ( iDWeight + iVSOWeight); |
---|
2359 | } |
---|
2360 | return dist; |
---|
2361 | }; |
---|
2362 | |
---|
2363 | |
---|
2364 | Void TComRdCost::setVSOMode( UInt uiIn ) |
---|
2365 | { |
---|
2366 | m_uiVSOMode = uiIn; |
---|
2367 | switch (m_uiVSOMode ) |
---|
2368 | { |
---|
2369 | case 4: |
---|
2370 | m_fpDistortFuncVSO = &TComRdCost::xGetDistVSOMode4; |
---|
2371 | break; |
---|
2372 | default: |
---|
2373 | assert(0); |
---|
2374 | break; |
---|
2375 | } |
---|
2376 | } |
---|
2377 | |
---|
2378 | |
---|
2379 | Double TComRdCost::calcRdCostVSO( UInt uiBits, Dist uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
2380 | { |
---|
2381 | assert( m_bUseLambdaScaleVSO ); |
---|
2382 | |
---|
2383 | Double dRdCost = 0.0; |
---|
2384 | Double dLambda = 0.0; |
---|
2385 | |
---|
2386 | switch ( eDFunc ) |
---|
2387 | { |
---|
2388 | case DF_SSE: |
---|
2389 | assert(0); |
---|
2390 | break; |
---|
2391 | case DF_SAD: |
---|
2392 | dLambda = (Double)m_uiLambdaMotionSADVSO; |
---|
2393 | break; |
---|
2394 | case DF_DEFAULT: |
---|
2395 | dLambda = m_dLambdaVSO; |
---|
2396 | break; |
---|
2397 | case DF_SSE_FRAME: |
---|
2398 | dLambda = m_dFrameLambdaVSO; |
---|
2399 | break; |
---|
2400 | default: |
---|
2401 | assert (0); |
---|
2402 | break; |
---|
2403 | } |
---|
2404 | |
---|
2405 | if (bFlag) |
---|
2406 | { |
---|
2407 | // Intra8x8, Intra4x4 Block only... |
---|
2408 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
2409 | dRdCost = (Double)(uiBits); |
---|
2410 | #else |
---|
2411 | dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda)); |
---|
2412 | #endif |
---|
2413 | } |
---|
2414 | else |
---|
2415 | { |
---|
2416 | if (eDFunc == DF_SAD) |
---|
2417 | { |
---|
2418 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5)>>16)); |
---|
2419 | dRdCost = (Double)(Dist)floor(dRdCost); |
---|
2420 | } |
---|
2421 | else |
---|
2422 | { |
---|
2423 | #if SEQUENCE_LEVEL_LOSSLESS |
---|
2424 | dRdCost = (Double)(uiBits); |
---|
2425 | #else |
---|
2426 | dRdCost = ((Double)uiDistortion + (Double)((Int)(uiBits * dLambda+.5))); |
---|
2427 | dRdCost = (Double)(Dist)floor(dRdCost); |
---|
2428 | #endif |
---|
2429 | } |
---|
2430 | } |
---|
2431 | |
---|
2432 | return dRdCost; |
---|
2433 | } |
---|
2434 | |
---|
2435 | Void TComRdCost::setRenModelData( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight ) |
---|
2436 | { |
---|
2437 | UInt iBlkX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]]; |
---|
2438 | UInt iBlkY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]]; |
---|
2439 | |
---|
2440 | Int iStartPosX = iBlkX + pcCU->getCUPelX(); |
---|
2441 | Int iStartPosY = iBlkY + pcCU->getCUPelY(); |
---|
2442 | |
---|
2443 | m_pcRenModel->setData( iStartPosX, iStartPosY, iBlkWidth, iBlkHeight, iStride, piData ); |
---|
2444 | } |
---|
2445 | |
---|
2446 | Void TComRdCost::setAllowNegDist( Bool bAllowNegDist ) |
---|
2447 | { |
---|
2448 | m_bAllowNegDist = bAllowNegDist; |
---|
2449 | } |
---|
2450 | #endif |
---|
2451 | |
---|
2452 | //! \} |
---|