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