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-2015, 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 | //! \ingroup TLibCommon |
---|
45 | //! \{ |
---|
46 | |
---|
47 | TComRdCost::TComRdCost() |
---|
48 | { |
---|
49 | init(); |
---|
50 | } |
---|
51 | |
---|
52 | TComRdCost::~TComRdCost() |
---|
53 | { |
---|
54 | } |
---|
55 | |
---|
56 | // Calculate RD functions |
---|
57 | Double TComRdCost::calcRdCost( UInt uiBits, Distortion uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
58 | { |
---|
59 | Double dRdCost = 0.0; |
---|
60 | Double dLambda = 0.0; |
---|
61 | |
---|
62 | switch ( eDFunc ) |
---|
63 | { |
---|
64 | case DF_SSE: |
---|
65 | assert(0); |
---|
66 | break; |
---|
67 | case DF_SAD: |
---|
68 | #if RExt__HIGH_BIT_DEPTH_SUPPORT |
---|
69 | dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate. |
---|
70 | #else |
---|
71 | dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate. |
---|
72 | #endif |
---|
73 | break; |
---|
74 | case DF_DEFAULT: |
---|
75 | dLambda = m_dLambda; |
---|
76 | break; |
---|
77 | case DF_SSE_FRAME: |
---|
78 | dLambda = m_dFrameLambda; |
---|
79 | break; |
---|
80 | default: |
---|
81 | assert (0); |
---|
82 | break; |
---|
83 | } |
---|
84 | |
---|
85 | if (bFlag) //NOTE: this "bFlag" is never true |
---|
86 | { |
---|
87 | // Intra8x8, Intra4x4 Block only... |
---|
88 | if (m_costMode != COST_STANDARD_LOSSY) |
---|
89 | { |
---|
90 | dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. |
---|
91 | } |
---|
92 | else |
---|
93 | { |
---|
94 | dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda)); |
---|
95 | } |
---|
96 | } |
---|
97 | else |
---|
98 | { |
---|
99 | if (eDFunc == DF_SAD) |
---|
100 | { |
---|
101 | if (m_costMode != COST_STANDARD_LOSSY) |
---|
102 | { |
---|
103 | dRdCost = ((Double(uiDistortion) * 65536) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. |
---|
104 | } |
---|
105 | else |
---|
106 | { |
---|
107 | dRdCost = floor(Double(uiDistortion) + (floor((Double(uiBits) * dLambda) + 0.5) / 65536.0)); |
---|
108 | } |
---|
109 | } |
---|
110 | else |
---|
111 | { |
---|
112 | if (m_costMode != COST_STANDARD_LOSSY) |
---|
113 | { |
---|
114 | dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. |
---|
115 | } |
---|
116 | else |
---|
117 | { |
---|
118 | dRdCost = floor(Double(uiDistortion) + (Double(uiBits) * dLambda) + 0.5); |
---|
119 | } |
---|
120 | } |
---|
121 | } |
---|
122 | |
---|
123 | return dRdCost; |
---|
124 | } |
---|
125 | |
---|
126 | Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc ) |
---|
127 | { |
---|
128 | Double dRdCost = 0.0; |
---|
129 | Double dLambda = 0.0; |
---|
130 | |
---|
131 | switch ( eDFunc ) |
---|
132 | { |
---|
133 | case DF_SSE: |
---|
134 | assert(0); |
---|
135 | break; |
---|
136 | case DF_SAD: |
---|
137 | #if RExt__HIGH_BIT_DEPTH_SUPPORT |
---|
138 | dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate. |
---|
139 | #else |
---|
140 | dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate. |
---|
141 | #endif |
---|
142 | break; |
---|
143 | case DF_DEFAULT: |
---|
144 | dLambda = m_dLambda; |
---|
145 | break; |
---|
146 | case DF_SSE_FRAME: |
---|
147 | dLambda = m_dFrameLambda; |
---|
148 | break; |
---|
149 | default: |
---|
150 | assert (0); |
---|
151 | break; |
---|
152 | } |
---|
153 | |
---|
154 | if (bFlag) //NOTE: this "bFlag" is never true |
---|
155 | { |
---|
156 | // Intra8x8, Intra4x4 Block only... |
---|
157 | if (m_costMode != COST_STANDARD_LOSSY) |
---|
158 | { |
---|
159 | dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. |
---|
160 | } |
---|
161 | else |
---|
162 | { |
---|
163 | dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda)); |
---|
164 | } |
---|
165 | } |
---|
166 | else |
---|
167 | { |
---|
168 | if (eDFunc == DF_SAD) |
---|
169 | { |
---|
170 | if (m_costMode != COST_STANDARD_LOSSY) |
---|
171 | { |
---|
172 | dRdCost = ((Double(uiDistortion) * 65536) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. |
---|
173 | } |
---|
174 | else |
---|
175 | { |
---|
176 | dRdCost = floor(Double(uiDistortion) + (floor((Double(uiBits) * dLambda) + 0.5) / 65536.0)); |
---|
177 | } |
---|
178 | } |
---|
179 | else |
---|
180 | { |
---|
181 | if (m_costMode != COST_STANDARD_LOSSY) |
---|
182 | { |
---|
183 | dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. |
---|
184 | } |
---|
185 | else |
---|
186 | { |
---|
187 | dRdCost = floor(Double(uiDistortion) + (Double(uiBits) * dLambda) + 0.5); |
---|
188 | } |
---|
189 | } |
---|
190 | } |
---|
191 | |
---|
192 | return dRdCost; |
---|
193 | } |
---|
194 | |
---|
195 | Void TComRdCost::setLambda( Double dLambda, const BitDepths &bitDepths ) |
---|
196 | { |
---|
197 | m_dLambda = dLambda; |
---|
198 | m_sqrtLambda = sqrt(m_dLambda); |
---|
199 | #if RExt__HIGH_BIT_DEPTH_SUPPORT |
---|
200 | m_dLambdaMotionSAD[0] = 65536.0 * m_sqrtLambda; |
---|
201 | m_dLambdaMotionSSE[0] = 65536.0 * m_dLambda; |
---|
202 | #if FULL_NBIT |
---|
203 | dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0)); |
---|
204 | #else |
---|
205 | 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)); |
---|
206 | #endif |
---|
207 | m_dLambdaMotionSAD[1] = 65536.0 * sqrt(dLambda); |
---|
208 | m_dLambdaMotionSSE[1] = 65536.0 * dLambda; |
---|
209 | #else |
---|
210 | m_uiLambdaMotionSAD[0] = (UInt)floor(65536.0 * m_sqrtLambda); |
---|
211 | m_uiLambdaMotionSSE[0] = (UInt)floor(65536.0 * m_dLambda ); |
---|
212 | #if FULL_NBIT |
---|
213 | dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0)); |
---|
214 | #else |
---|
215 | 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)); |
---|
216 | #endif |
---|
217 | m_uiLambdaMotionSAD[1] = (UInt)floor(65536.0 * sqrt(dLambda)); |
---|
218 | m_uiLambdaMotionSSE[1] = (UInt)floor(65536.0 * dLambda ); |
---|
219 | #endif |
---|
220 | } |
---|
221 | |
---|
222 | |
---|
223 | // Initalize Function Pointer by [eDFunc] |
---|
224 | Void TComRdCost::init() |
---|
225 | { |
---|
226 | m_afpDistortFunc[DF_DEFAULT] = NULL; // for DF_DEFAULT |
---|
227 | |
---|
228 | m_afpDistortFunc[DF_SSE ] = TComRdCost::xGetSSE; |
---|
229 | m_afpDistortFunc[DF_SSE4 ] = TComRdCost::xGetSSE4; |
---|
230 | m_afpDistortFunc[DF_SSE8 ] = TComRdCost::xGetSSE8; |
---|
231 | m_afpDistortFunc[DF_SSE16 ] = TComRdCost::xGetSSE16; |
---|
232 | m_afpDistortFunc[DF_SSE32 ] = TComRdCost::xGetSSE32; |
---|
233 | m_afpDistortFunc[DF_SSE64 ] = TComRdCost::xGetSSE64; |
---|
234 | m_afpDistortFunc[DF_SSE16N ] = TComRdCost::xGetSSE16N; |
---|
235 | |
---|
236 | m_afpDistortFunc[DF_SAD ] = TComRdCost::xGetSAD; |
---|
237 | m_afpDistortFunc[DF_SAD4 ] = TComRdCost::xGetSAD4; |
---|
238 | m_afpDistortFunc[DF_SAD8 ] = TComRdCost::xGetSAD8; |
---|
239 | m_afpDistortFunc[DF_SAD16 ] = TComRdCost::xGetSAD16; |
---|
240 | m_afpDistortFunc[DF_SAD32 ] = TComRdCost::xGetSAD32; |
---|
241 | m_afpDistortFunc[DF_SAD64 ] = TComRdCost::xGetSAD64; |
---|
242 | m_afpDistortFunc[DF_SAD16N ] = TComRdCost::xGetSAD16N; |
---|
243 | |
---|
244 | m_afpDistortFunc[DF_SADS ] = TComRdCost::xGetSAD; |
---|
245 | m_afpDistortFunc[DF_SADS4 ] = TComRdCost::xGetSAD4; |
---|
246 | m_afpDistortFunc[DF_SADS8 ] = TComRdCost::xGetSAD8; |
---|
247 | m_afpDistortFunc[DF_SADS16 ] = TComRdCost::xGetSAD16; |
---|
248 | m_afpDistortFunc[DF_SADS32 ] = TComRdCost::xGetSAD32; |
---|
249 | m_afpDistortFunc[DF_SADS64 ] = TComRdCost::xGetSAD64; |
---|
250 | m_afpDistortFunc[DF_SADS16N] = TComRdCost::xGetSAD16N; |
---|
251 | |
---|
252 | #if AMP_SAD |
---|
253 | m_afpDistortFunc[DF_SAD12 ] = TComRdCost::xGetSAD12; |
---|
254 | m_afpDistortFunc[DF_SAD24 ] = TComRdCost::xGetSAD24; |
---|
255 | m_afpDistortFunc[DF_SAD48 ] = TComRdCost::xGetSAD48; |
---|
256 | |
---|
257 | m_afpDistortFunc[DF_SADS12 ] = TComRdCost::xGetSAD12; |
---|
258 | m_afpDistortFunc[DF_SADS24 ] = TComRdCost::xGetSAD24; |
---|
259 | m_afpDistortFunc[DF_SADS48 ] = TComRdCost::xGetSAD48; |
---|
260 | #endif |
---|
261 | m_afpDistortFunc[DF_HADS ] = TComRdCost::xGetHADs; |
---|
262 | m_afpDistortFunc[DF_HADS4 ] = TComRdCost::xGetHADs; |
---|
263 | m_afpDistortFunc[DF_HADS8 ] = TComRdCost::xGetHADs; |
---|
264 | m_afpDistortFunc[DF_HADS16 ] = TComRdCost::xGetHADs; |
---|
265 | m_afpDistortFunc[DF_HADS32 ] = TComRdCost::xGetHADs; |
---|
266 | m_afpDistortFunc[DF_HADS64 ] = TComRdCost::xGetHADs; |
---|
267 | m_afpDistortFunc[DF_HADS16N] = TComRdCost::xGetHADs; |
---|
268 | |
---|
269 | m_costMode = COST_STANDARD_LOSSY; |
---|
270 | |
---|
271 | #if RExt__HIGH_BIT_DEPTH_SUPPORT |
---|
272 | m_dCost = 0; |
---|
273 | #else |
---|
274 | m_uiCost = 0; |
---|
275 | #endif |
---|
276 | m_iCostScale = 0; |
---|
277 | } |
---|
278 | |
---|
279 | // Static member function |
---|
280 | UInt TComRdCost::xGetExpGolombNumberOfBits( Int iVal ) |
---|
281 | { |
---|
282 | assert(iVal != std::numeric_limits<Int>::min()); |
---|
283 | UInt uiLength = 1; |
---|
284 | UInt uiTemp = ( iVal <= 0) ? (UInt(-iVal)<<1)+1: UInt(iVal<<1); |
---|
285 | |
---|
286 | while ( 1 != uiTemp ) |
---|
287 | { |
---|
288 | uiTemp >>= 1; |
---|
289 | uiLength += 2; |
---|
290 | } |
---|
291 | |
---|
292 | return uiLength; |
---|
293 | } |
---|
294 | |
---|
295 | Void TComRdCost::setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam ) |
---|
296 | { |
---|
297 | // set Block Width / Height |
---|
298 | rcDistParam.iCols = uiBlkWidth; |
---|
299 | rcDistParam.iRows = uiBlkHeight; |
---|
300 | rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
301 | |
---|
302 | // initialize |
---|
303 | rcDistParam.iSubShift = 0; |
---|
304 | } |
---|
305 | |
---|
306 | // Setting the Distortion Parameter for Inter (ME) |
---|
307 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam ) |
---|
308 | { |
---|
309 | // set Original & Curr Pointer / Stride |
---|
310 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
311 | rcDistParam.pCur = piRefY; |
---|
312 | |
---|
313 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
314 | rcDistParam.iStrideCur = iRefStride; |
---|
315 | |
---|
316 | // set Block Width / Height |
---|
317 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
318 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
319 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
320 | |
---|
321 | #if AMP_SAD |
---|
322 | if (rcDistParam.iCols == 12) |
---|
323 | { |
---|
324 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD12]; |
---|
325 | } |
---|
326 | else if (rcDistParam.iCols == 24) |
---|
327 | { |
---|
328 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD24]; |
---|
329 | } |
---|
330 | else if (rcDistParam.iCols == 48) |
---|
331 | { |
---|
332 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SAD48]; |
---|
333 | } |
---|
334 | #endif |
---|
335 | |
---|
336 | // initialize |
---|
337 | rcDistParam.iSubShift = 0; |
---|
338 | } |
---|
339 | |
---|
340 | // Setting the Distortion Parameter for Inter (subpel ME with step) |
---|
341 | Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME ) |
---|
342 | { |
---|
343 | // set Original & Curr Pointer / Stride |
---|
344 | rcDistParam.pOrg = pcPatternKey->getROIY(); |
---|
345 | rcDistParam.pCur = piRefY; |
---|
346 | |
---|
347 | rcDistParam.iStrideOrg = pcPatternKey->getPatternLStride(); |
---|
348 | rcDistParam.iStrideCur = iRefStride * iStep; |
---|
349 | |
---|
350 | // set Step for interpolated buffer |
---|
351 | rcDistParam.iStep = iStep; |
---|
352 | |
---|
353 | // set Block Width / Height |
---|
354 | rcDistParam.iCols = pcPatternKey->getROIYWidth(); |
---|
355 | rcDistParam.iRows = pcPatternKey->getROIYHeight(); |
---|
356 | |
---|
357 | // set distortion function |
---|
358 | if ( !bHADME ) |
---|
359 | { |
---|
360 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
361 | #if AMP_SAD |
---|
362 | if (rcDistParam.iCols == 12) |
---|
363 | { |
---|
364 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS12]; |
---|
365 | } |
---|
366 | else if (rcDistParam.iCols == 24) |
---|
367 | { |
---|
368 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS24]; |
---|
369 | } |
---|
370 | else if (rcDistParam.iCols == 48) |
---|
371 | { |
---|
372 | rcDistParam.DistFunc = m_afpDistortFunc[DF_SADS48]; |
---|
373 | } |
---|
374 | #endif |
---|
375 | } |
---|
376 | else |
---|
377 | { |
---|
378 | rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ]; |
---|
379 | } |
---|
380 | |
---|
381 | // initialize |
---|
382 | rcDistParam.iSubShift = 0; |
---|
383 | } |
---|
384 | |
---|
385 | Void TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard ) |
---|
386 | { |
---|
387 | rcDP.pOrg = p1; |
---|
388 | rcDP.pCur = p2; |
---|
389 | rcDP.iStrideOrg = iStride1; |
---|
390 | rcDP.iStrideCur = iStride2; |
---|
391 | rcDP.iCols = iWidth; |
---|
392 | rcDP.iRows = iHeight; |
---|
393 | rcDP.iStep = 1; |
---|
394 | rcDP.iSubShift = 0; |
---|
395 | rcDP.bitDepth = bitDepth; |
---|
396 | rcDP.DistFunc = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ]; |
---|
397 | } |
---|
398 | |
---|
399 | Distortion TComRdCost::calcHAD( Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight ) |
---|
400 | { |
---|
401 | Distortion uiSum = 0; |
---|
402 | Int x, y; |
---|
403 | |
---|
404 | if ( ( (iWidth % 8) == 0 ) && ( (iHeight % 8) == 0 ) ) |
---|
405 | { |
---|
406 | for ( y=0; y<iHeight; y+= 8 ) |
---|
407 | { |
---|
408 | for ( x=0; x<iWidth; x+= 8 ) |
---|
409 | { |
---|
410 | uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
411 | } |
---|
412 | pi0 += iStride0*8; |
---|
413 | pi1 += iStride1*8; |
---|
414 | } |
---|
415 | } |
---|
416 | else |
---|
417 | { |
---|
418 | assert ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) ); |
---|
419 | |
---|
420 | for ( y=0; y<iHeight; y+= 4 ) |
---|
421 | { |
---|
422 | for ( x=0; x<iWidth; x+= 4 ) |
---|
423 | { |
---|
424 | uiSum += xCalcHADs4x4( &pi0[x], &pi1[x], iStride0, iStride1, 1 ); |
---|
425 | } |
---|
426 | pi0 += iStride0*4; |
---|
427 | pi1 += iStride1*4; |
---|
428 | } |
---|
429 | } |
---|
430 | |
---|
431 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8) ); |
---|
432 | } |
---|
433 | |
---|
434 | Distortion TComRdCost::getDistPart( Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc ) |
---|
435 | { |
---|
436 | DistParam cDtParam; |
---|
437 | setDistParam( uiBlkWidth, uiBlkHeight, eDFunc, cDtParam ); |
---|
438 | cDtParam.pOrg = piOrg; |
---|
439 | cDtParam.pCur = piCur; |
---|
440 | cDtParam.iStrideOrg = iOrgStride; |
---|
441 | cDtParam.iStrideCur = iCurStride; |
---|
442 | cDtParam.iStep = 1; |
---|
443 | |
---|
444 | cDtParam.bApplyWeight = false; |
---|
445 | cDtParam.compIdx = MAX_NUM_COMPONENT; // just for assert: to be sure it was set before use |
---|
446 | cDtParam.bitDepth = bitDepth; |
---|
447 | |
---|
448 | if (isChroma(compID)) |
---|
449 | { |
---|
450 | return ((Distortion) (m_distortionWeight[compID] * cDtParam.DistFunc( &cDtParam ))); |
---|
451 | } |
---|
452 | else |
---|
453 | { |
---|
454 | return cDtParam.DistFunc( &cDtParam ); |
---|
455 | } |
---|
456 | } |
---|
457 | |
---|
458 | // ==================================================================================================================== |
---|
459 | // Distortion functions |
---|
460 | // ==================================================================================================================== |
---|
461 | |
---|
462 | // -------------------------------------------------------------------------------------------------------------------- |
---|
463 | // SAD |
---|
464 | // -------------------------------------------------------------------------------------------------------------------- |
---|
465 | |
---|
466 | Distortion TComRdCost::xGetSAD( DistParam* pcDtParam ) |
---|
467 | { |
---|
468 | if ( pcDtParam->bApplyWeight ) |
---|
469 | { |
---|
470 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
471 | } |
---|
472 | const Pel* piOrg = pcDtParam->pOrg; |
---|
473 | const Pel* piCur = pcDtParam->pCur; |
---|
474 | Int iRows = pcDtParam->iRows; |
---|
475 | Int iCols = pcDtParam->iCols; |
---|
476 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
477 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
478 | |
---|
479 | Distortion uiSum = 0; |
---|
480 | |
---|
481 | for( ; iRows != 0; iRows-- ) |
---|
482 | { |
---|
483 | for (Int n = 0; n < iCols; n++ ) |
---|
484 | { |
---|
485 | uiSum += abs( piOrg[n] - piCur[n] ); |
---|
486 | } |
---|
487 | piOrg += iStrideOrg; |
---|
488 | piCur += iStrideCur; |
---|
489 | } |
---|
490 | |
---|
491 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
492 | } |
---|
493 | |
---|
494 | Distortion TComRdCost::xGetSAD4( DistParam* pcDtParam ) |
---|
495 | { |
---|
496 | if ( pcDtParam->bApplyWeight ) |
---|
497 | { |
---|
498 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
499 | } |
---|
500 | const Pel* piOrg = pcDtParam->pOrg; |
---|
501 | const Pel* piCur = pcDtParam->pCur; |
---|
502 | Int iRows = pcDtParam->iRows; |
---|
503 | Int iSubShift = pcDtParam->iSubShift; |
---|
504 | Int iSubStep = ( 1 << iSubShift ); |
---|
505 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
506 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
507 | |
---|
508 | Distortion uiSum = 0; |
---|
509 | |
---|
510 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
511 | { |
---|
512 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
513 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
514 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
515 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
516 | |
---|
517 | piOrg += iStrideOrg; |
---|
518 | piCur += iStrideCur; |
---|
519 | } |
---|
520 | |
---|
521 | uiSum <<= iSubShift; |
---|
522 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
523 | } |
---|
524 | |
---|
525 | Distortion TComRdCost::xGetSAD8( DistParam* pcDtParam ) |
---|
526 | { |
---|
527 | if ( pcDtParam->bApplyWeight ) |
---|
528 | { |
---|
529 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
530 | } |
---|
531 | const Pel* piOrg = pcDtParam->pOrg; |
---|
532 | const Pel* piCur = pcDtParam->pCur; |
---|
533 | Int iRows = pcDtParam->iRows; |
---|
534 | Int iSubShift = pcDtParam->iSubShift; |
---|
535 | Int iSubStep = ( 1 << iSubShift ); |
---|
536 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
537 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
538 | |
---|
539 | Distortion uiSum = 0; |
---|
540 | |
---|
541 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
542 | { |
---|
543 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
544 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
545 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
546 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
547 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
548 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
549 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
550 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
551 | |
---|
552 | piOrg += iStrideOrg; |
---|
553 | piCur += iStrideCur; |
---|
554 | } |
---|
555 | |
---|
556 | uiSum <<= iSubShift; |
---|
557 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
558 | } |
---|
559 | |
---|
560 | Distortion TComRdCost::xGetSAD16( DistParam* pcDtParam ) |
---|
561 | { |
---|
562 | if ( pcDtParam->bApplyWeight ) |
---|
563 | { |
---|
564 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
565 | } |
---|
566 | const Pel* piOrg = pcDtParam->pOrg; |
---|
567 | const Pel* piCur = pcDtParam->pCur; |
---|
568 | Int iRows = pcDtParam->iRows; |
---|
569 | Int iSubShift = pcDtParam->iSubShift; |
---|
570 | Int iSubStep = ( 1 << iSubShift ); |
---|
571 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
572 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
573 | |
---|
574 | Distortion uiSum = 0; |
---|
575 | |
---|
576 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
577 | { |
---|
578 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
579 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
580 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
581 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
582 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
583 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
584 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
585 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
586 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
587 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
588 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
589 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
590 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
591 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
592 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
593 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
594 | |
---|
595 | piOrg += iStrideOrg; |
---|
596 | piCur += iStrideCur; |
---|
597 | } |
---|
598 | |
---|
599 | uiSum <<= iSubShift; |
---|
600 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
601 | } |
---|
602 | |
---|
603 | #if AMP_SAD |
---|
604 | Distortion TComRdCost::xGetSAD12( DistParam* pcDtParam ) |
---|
605 | { |
---|
606 | if ( pcDtParam->bApplyWeight ) |
---|
607 | { |
---|
608 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
609 | } |
---|
610 | const Pel* piOrg = pcDtParam->pOrg; |
---|
611 | const Pel* piCur = pcDtParam->pCur; |
---|
612 | Int iRows = pcDtParam->iRows; |
---|
613 | Int iSubShift = pcDtParam->iSubShift; |
---|
614 | Int iSubStep = ( 1 << iSubShift ); |
---|
615 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
616 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
617 | |
---|
618 | Distortion uiSum = 0; |
---|
619 | |
---|
620 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
621 | { |
---|
622 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
623 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
624 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
625 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
626 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
627 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
628 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
629 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
630 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
631 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
632 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
633 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
634 | |
---|
635 | piOrg += iStrideOrg; |
---|
636 | piCur += iStrideCur; |
---|
637 | } |
---|
638 | |
---|
639 | uiSum <<= iSubShift; |
---|
640 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
641 | } |
---|
642 | #endif |
---|
643 | |
---|
644 | Distortion TComRdCost::xGetSAD16N( DistParam* pcDtParam ) |
---|
645 | { |
---|
646 | const Pel* piOrg = pcDtParam->pOrg; |
---|
647 | const Pel* piCur = pcDtParam->pCur; |
---|
648 | Int iRows = pcDtParam->iRows; |
---|
649 | Int iCols = pcDtParam->iCols; |
---|
650 | Int iSubShift = pcDtParam->iSubShift; |
---|
651 | Int iSubStep = ( 1 << iSubShift ); |
---|
652 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
653 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
654 | |
---|
655 | Distortion uiSum = 0; |
---|
656 | |
---|
657 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
658 | { |
---|
659 | for (Int n = 0; n < iCols; n+=16 ) |
---|
660 | { |
---|
661 | uiSum += abs( piOrg[n+ 0] - piCur[n+ 0] ); |
---|
662 | uiSum += abs( piOrg[n+ 1] - piCur[n+ 1] ); |
---|
663 | uiSum += abs( piOrg[n+ 2] - piCur[n+ 2] ); |
---|
664 | uiSum += abs( piOrg[n+ 3] - piCur[n+ 3] ); |
---|
665 | uiSum += abs( piOrg[n+ 4] - piCur[n+ 4] ); |
---|
666 | uiSum += abs( piOrg[n+ 5] - piCur[n+ 5] ); |
---|
667 | uiSum += abs( piOrg[n+ 6] - piCur[n+ 6] ); |
---|
668 | uiSum += abs( piOrg[n+ 7] - piCur[n+ 7] ); |
---|
669 | uiSum += abs( piOrg[n+ 8] - piCur[n+ 8] ); |
---|
670 | uiSum += abs( piOrg[n+ 9] - piCur[n+ 9] ); |
---|
671 | uiSum += abs( piOrg[n+10] - piCur[n+10] ); |
---|
672 | uiSum += abs( piOrg[n+11] - piCur[n+11] ); |
---|
673 | uiSum += abs( piOrg[n+12] - piCur[n+12] ); |
---|
674 | uiSum += abs( piOrg[n+13] - piCur[n+13] ); |
---|
675 | uiSum += abs( piOrg[n+14] - piCur[n+14] ); |
---|
676 | uiSum += abs( piOrg[n+15] - piCur[n+15] ); |
---|
677 | } |
---|
678 | piOrg += iStrideOrg; |
---|
679 | piCur += iStrideCur; |
---|
680 | } |
---|
681 | |
---|
682 | uiSum <<= iSubShift; |
---|
683 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
684 | } |
---|
685 | |
---|
686 | Distortion TComRdCost::xGetSAD32( DistParam* pcDtParam ) |
---|
687 | { |
---|
688 | if ( pcDtParam->bApplyWeight ) |
---|
689 | { |
---|
690 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
691 | } |
---|
692 | const Pel* piOrg = pcDtParam->pOrg; |
---|
693 | const Pel* piCur = pcDtParam->pCur; |
---|
694 | Int iRows = pcDtParam->iRows; |
---|
695 | Int iSubShift = pcDtParam->iSubShift; |
---|
696 | Int iSubStep = ( 1 << iSubShift ); |
---|
697 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
698 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
699 | |
---|
700 | Distortion uiSum = 0; |
---|
701 | |
---|
702 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
703 | { |
---|
704 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
705 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
706 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
707 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
708 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
709 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
710 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
711 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
712 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
713 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
714 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
715 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
716 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
717 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
718 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
719 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
720 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
721 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
722 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
723 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
724 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
725 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
726 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
727 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
728 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
729 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
730 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
731 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
732 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
733 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
734 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
735 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
736 | |
---|
737 | piOrg += iStrideOrg; |
---|
738 | piCur += iStrideCur; |
---|
739 | } |
---|
740 | |
---|
741 | uiSum <<= iSubShift; |
---|
742 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
743 | } |
---|
744 | |
---|
745 | #if AMP_SAD |
---|
746 | Distortion TComRdCost::xGetSAD24( DistParam* pcDtParam ) |
---|
747 | { |
---|
748 | if ( pcDtParam->bApplyWeight ) |
---|
749 | { |
---|
750 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
751 | } |
---|
752 | const Pel* piOrg = pcDtParam->pOrg; |
---|
753 | const Pel* piCur = pcDtParam->pCur; |
---|
754 | Int iRows = pcDtParam->iRows; |
---|
755 | Int iSubShift = pcDtParam->iSubShift; |
---|
756 | Int iSubStep = ( 1 << iSubShift ); |
---|
757 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
758 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
759 | |
---|
760 | Distortion uiSum = 0; |
---|
761 | |
---|
762 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
763 | { |
---|
764 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
765 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
766 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
767 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
768 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
769 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
770 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
771 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
772 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
773 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
774 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
775 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
776 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
777 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
778 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
779 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
780 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
781 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
782 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
783 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
784 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
785 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
786 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
787 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
788 | |
---|
789 | piOrg += iStrideOrg; |
---|
790 | piCur += iStrideCur; |
---|
791 | } |
---|
792 | |
---|
793 | uiSum <<= iSubShift; |
---|
794 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
795 | } |
---|
796 | |
---|
797 | #endif |
---|
798 | |
---|
799 | Distortion TComRdCost::xGetSAD64( DistParam* pcDtParam ) |
---|
800 | { |
---|
801 | if ( pcDtParam->bApplyWeight ) |
---|
802 | { |
---|
803 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
804 | } |
---|
805 | const Pel* piOrg = pcDtParam->pOrg; |
---|
806 | const Pel* piCur = pcDtParam->pCur; |
---|
807 | Int iRows = pcDtParam->iRows; |
---|
808 | Int iSubShift = pcDtParam->iSubShift; |
---|
809 | Int iSubStep = ( 1 << iSubShift ); |
---|
810 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
811 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
812 | |
---|
813 | Distortion uiSum = 0; |
---|
814 | |
---|
815 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
816 | { |
---|
817 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
818 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
819 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
820 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
821 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
822 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
823 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
824 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
825 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
826 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
827 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
828 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
829 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
830 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
831 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
832 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
833 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
834 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
835 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
836 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
837 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
838 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
839 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
840 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
841 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
842 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
843 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
844 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
845 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
846 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
847 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
848 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
849 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
850 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
851 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
852 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
853 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
854 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
855 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
856 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
857 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
858 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
859 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
860 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
861 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
862 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
863 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
864 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
865 | uiSum += abs( piOrg[48] - piCur[48] ); |
---|
866 | uiSum += abs( piOrg[49] - piCur[49] ); |
---|
867 | uiSum += abs( piOrg[50] - piCur[50] ); |
---|
868 | uiSum += abs( piOrg[51] - piCur[51] ); |
---|
869 | uiSum += abs( piOrg[52] - piCur[52] ); |
---|
870 | uiSum += abs( piOrg[53] - piCur[53] ); |
---|
871 | uiSum += abs( piOrg[54] - piCur[54] ); |
---|
872 | uiSum += abs( piOrg[55] - piCur[55] ); |
---|
873 | uiSum += abs( piOrg[56] - piCur[56] ); |
---|
874 | uiSum += abs( piOrg[57] - piCur[57] ); |
---|
875 | uiSum += abs( piOrg[58] - piCur[58] ); |
---|
876 | uiSum += abs( piOrg[59] - piCur[59] ); |
---|
877 | uiSum += abs( piOrg[60] - piCur[60] ); |
---|
878 | uiSum += abs( piOrg[61] - piCur[61] ); |
---|
879 | uiSum += abs( piOrg[62] - piCur[62] ); |
---|
880 | uiSum += abs( piOrg[63] - piCur[63] ); |
---|
881 | |
---|
882 | piOrg += iStrideOrg; |
---|
883 | piCur += iStrideCur; |
---|
884 | } |
---|
885 | |
---|
886 | uiSum <<= iSubShift; |
---|
887 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
888 | } |
---|
889 | |
---|
890 | #if AMP_SAD |
---|
891 | Distortion TComRdCost::xGetSAD48( DistParam* pcDtParam ) |
---|
892 | { |
---|
893 | if ( pcDtParam->bApplyWeight ) |
---|
894 | { |
---|
895 | return TComRdCostWeightPrediction::xGetSADw( pcDtParam ); |
---|
896 | } |
---|
897 | const Pel* piOrg = pcDtParam->pOrg; |
---|
898 | const Pel* piCur = pcDtParam->pCur; |
---|
899 | Int iRows = pcDtParam->iRows; |
---|
900 | Int iSubShift = pcDtParam->iSubShift; |
---|
901 | Int iSubStep = ( 1 << iSubShift ); |
---|
902 | Int iStrideCur = pcDtParam->iStrideCur*iSubStep; |
---|
903 | Int iStrideOrg = pcDtParam->iStrideOrg*iSubStep; |
---|
904 | |
---|
905 | Distortion uiSum = 0; |
---|
906 | |
---|
907 | for( ; iRows != 0; iRows-=iSubStep ) |
---|
908 | { |
---|
909 | uiSum += abs( piOrg[0] - piCur[0] ); |
---|
910 | uiSum += abs( piOrg[1] - piCur[1] ); |
---|
911 | uiSum += abs( piOrg[2] - piCur[2] ); |
---|
912 | uiSum += abs( piOrg[3] - piCur[3] ); |
---|
913 | uiSum += abs( piOrg[4] - piCur[4] ); |
---|
914 | uiSum += abs( piOrg[5] - piCur[5] ); |
---|
915 | uiSum += abs( piOrg[6] - piCur[6] ); |
---|
916 | uiSum += abs( piOrg[7] - piCur[7] ); |
---|
917 | uiSum += abs( piOrg[8] - piCur[8] ); |
---|
918 | uiSum += abs( piOrg[9] - piCur[9] ); |
---|
919 | uiSum += abs( piOrg[10] - piCur[10] ); |
---|
920 | uiSum += abs( piOrg[11] - piCur[11] ); |
---|
921 | uiSum += abs( piOrg[12] - piCur[12] ); |
---|
922 | uiSum += abs( piOrg[13] - piCur[13] ); |
---|
923 | uiSum += abs( piOrg[14] - piCur[14] ); |
---|
924 | uiSum += abs( piOrg[15] - piCur[15] ); |
---|
925 | uiSum += abs( piOrg[16] - piCur[16] ); |
---|
926 | uiSum += abs( piOrg[17] - piCur[17] ); |
---|
927 | uiSum += abs( piOrg[18] - piCur[18] ); |
---|
928 | uiSum += abs( piOrg[19] - piCur[19] ); |
---|
929 | uiSum += abs( piOrg[20] - piCur[20] ); |
---|
930 | uiSum += abs( piOrg[21] - piCur[21] ); |
---|
931 | uiSum += abs( piOrg[22] - piCur[22] ); |
---|
932 | uiSum += abs( piOrg[23] - piCur[23] ); |
---|
933 | uiSum += abs( piOrg[24] - piCur[24] ); |
---|
934 | uiSum += abs( piOrg[25] - piCur[25] ); |
---|
935 | uiSum += abs( piOrg[26] - piCur[26] ); |
---|
936 | uiSum += abs( piOrg[27] - piCur[27] ); |
---|
937 | uiSum += abs( piOrg[28] - piCur[28] ); |
---|
938 | uiSum += abs( piOrg[29] - piCur[29] ); |
---|
939 | uiSum += abs( piOrg[30] - piCur[30] ); |
---|
940 | uiSum += abs( piOrg[31] - piCur[31] ); |
---|
941 | uiSum += abs( piOrg[32] - piCur[32] ); |
---|
942 | uiSum += abs( piOrg[33] - piCur[33] ); |
---|
943 | uiSum += abs( piOrg[34] - piCur[34] ); |
---|
944 | uiSum += abs( piOrg[35] - piCur[35] ); |
---|
945 | uiSum += abs( piOrg[36] - piCur[36] ); |
---|
946 | uiSum += abs( piOrg[37] - piCur[37] ); |
---|
947 | uiSum += abs( piOrg[38] - piCur[38] ); |
---|
948 | uiSum += abs( piOrg[39] - piCur[39] ); |
---|
949 | uiSum += abs( piOrg[40] - piCur[40] ); |
---|
950 | uiSum += abs( piOrg[41] - piCur[41] ); |
---|
951 | uiSum += abs( piOrg[42] - piCur[42] ); |
---|
952 | uiSum += abs( piOrg[43] - piCur[43] ); |
---|
953 | uiSum += abs( piOrg[44] - piCur[44] ); |
---|
954 | uiSum += abs( piOrg[45] - piCur[45] ); |
---|
955 | uiSum += abs( piOrg[46] - piCur[46] ); |
---|
956 | uiSum += abs( piOrg[47] - piCur[47] ); |
---|
957 | |
---|
958 | piOrg += iStrideOrg; |
---|
959 | piCur += iStrideCur; |
---|
960 | } |
---|
961 | |
---|
962 | uiSum <<= iSubShift; |
---|
963 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
964 | } |
---|
965 | #endif |
---|
966 | |
---|
967 | // -------------------------------------------------------------------------------------------------------------------- |
---|
968 | // SSE |
---|
969 | // -------------------------------------------------------------------------------------------------------------------- |
---|
970 | |
---|
971 | Distortion TComRdCost::xGetSSE( DistParam* pcDtParam ) |
---|
972 | { |
---|
973 | if ( pcDtParam->bApplyWeight ) |
---|
974 | { |
---|
975 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
976 | } |
---|
977 | const Pel* piOrg = pcDtParam->pOrg; |
---|
978 | const Pel* piCur = pcDtParam->pCur; |
---|
979 | Int iRows = pcDtParam->iRows; |
---|
980 | Int iCols = pcDtParam->iCols; |
---|
981 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
982 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
983 | |
---|
984 | Distortion uiSum = 0; |
---|
985 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
986 | |
---|
987 | Intermediate_Int iTemp; |
---|
988 | |
---|
989 | for( ; iRows != 0; iRows-- ) |
---|
990 | { |
---|
991 | for (Int n = 0; n < iCols; n++ ) |
---|
992 | { |
---|
993 | iTemp = piOrg[n ] - piCur[n ]; |
---|
994 | uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
995 | } |
---|
996 | piOrg += iStrideOrg; |
---|
997 | piCur += iStrideCur; |
---|
998 | } |
---|
999 | |
---|
1000 | return ( uiSum ); |
---|
1001 | } |
---|
1002 | |
---|
1003 | Distortion TComRdCost::xGetSSE4( DistParam* pcDtParam ) |
---|
1004 | { |
---|
1005 | if ( pcDtParam->bApplyWeight ) |
---|
1006 | { |
---|
1007 | assert( pcDtParam->iCols == 4 ); |
---|
1008 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
1009 | } |
---|
1010 | const Pel* piOrg = pcDtParam->pOrg; |
---|
1011 | const Pel* piCur = pcDtParam->pCur; |
---|
1012 | Int iRows = pcDtParam->iRows; |
---|
1013 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1014 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1015 | |
---|
1016 | Distortion uiSum = 0; |
---|
1017 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1018 | |
---|
1019 | Intermediate_Int iTemp; |
---|
1020 | |
---|
1021 | for( ; iRows != 0; iRows-- ) |
---|
1022 | { |
---|
1023 | |
---|
1024 | iTemp = piOrg[0] - piCur[0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1025 | iTemp = piOrg[1] - piCur[1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1026 | iTemp = piOrg[2] - piCur[2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1027 | iTemp = piOrg[3] - piCur[3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1028 | |
---|
1029 | piOrg += iStrideOrg; |
---|
1030 | piCur += iStrideCur; |
---|
1031 | } |
---|
1032 | |
---|
1033 | return ( uiSum ); |
---|
1034 | } |
---|
1035 | |
---|
1036 | Distortion TComRdCost::xGetSSE8( DistParam* pcDtParam ) |
---|
1037 | { |
---|
1038 | if ( pcDtParam->bApplyWeight ) |
---|
1039 | { |
---|
1040 | assert( pcDtParam->iCols == 8 ); |
---|
1041 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
1042 | } |
---|
1043 | const Pel* piOrg = pcDtParam->pOrg; |
---|
1044 | const Pel* piCur = pcDtParam->pCur; |
---|
1045 | Int iRows = pcDtParam->iRows; |
---|
1046 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1047 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1048 | |
---|
1049 | Distortion uiSum = 0; |
---|
1050 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1051 | |
---|
1052 | Intermediate_Int iTemp; |
---|
1053 | |
---|
1054 | for( ; iRows != 0; iRows-- ) |
---|
1055 | { |
---|
1056 | iTemp = piOrg[0] - piCur[0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1057 | iTemp = piOrg[1] - piCur[1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1058 | iTemp = piOrg[2] - piCur[2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1059 | iTemp = piOrg[3] - piCur[3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1060 | iTemp = piOrg[4] - piCur[4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1061 | iTemp = piOrg[5] - piCur[5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1062 | iTemp = piOrg[6] - piCur[6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1063 | iTemp = piOrg[7] - piCur[7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1064 | |
---|
1065 | piOrg += iStrideOrg; |
---|
1066 | piCur += iStrideCur; |
---|
1067 | } |
---|
1068 | |
---|
1069 | return ( uiSum ); |
---|
1070 | } |
---|
1071 | |
---|
1072 | Distortion TComRdCost::xGetSSE16( DistParam* pcDtParam ) |
---|
1073 | { |
---|
1074 | if ( pcDtParam->bApplyWeight ) |
---|
1075 | { |
---|
1076 | assert( pcDtParam->iCols == 16 ); |
---|
1077 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
1078 | } |
---|
1079 | const Pel* piOrg = pcDtParam->pOrg; |
---|
1080 | const Pel* piCur = pcDtParam->pCur; |
---|
1081 | Int iRows = pcDtParam->iRows; |
---|
1082 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1083 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1084 | |
---|
1085 | Distortion uiSum = 0; |
---|
1086 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1087 | |
---|
1088 | Intermediate_Int iTemp; |
---|
1089 | |
---|
1090 | for( ; iRows != 0; iRows-- ) |
---|
1091 | { |
---|
1092 | |
---|
1093 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1094 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1095 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1096 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1097 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1098 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1099 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1100 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1101 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1102 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1103 | iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1104 | iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1105 | iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1106 | iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1107 | iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1108 | iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1109 | |
---|
1110 | piOrg += iStrideOrg; |
---|
1111 | piCur += iStrideCur; |
---|
1112 | } |
---|
1113 | |
---|
1114 | return ( uiSum ); |
---|
1115 | } |
---|
1116 | |
---|
1117 | Distortion TComRdCost::xGetSSE16N( DistParam* pcDtParam ) |
---|
1118 | { |
---|
1119 | if ( pcDtParam->bApplyWeight ) |
---|
1120 | { |
---|
1121 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
1122 | } |
---|
1123 | const Pel* piOrg = pcDtParam->pOrg; |
---|
1124 | const Pel* piCur = pcDtParam->pCur; |
---|
1125 | Int iRows = pcDtParam->iRows; |
---|
1126 | Int iCols = pcDtParam->iCols; |
---|
1127 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1128 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1129 | |
---|
1130 | Distortion uiSum = 0; |
---|
1131 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1132 | |
---|
1133 | Intermediate_Int iTemp; |
---|
1134 | |
---|
1135 | for( ; iRows != 0; iRows-- ) |
---|
1136 | { |
---|
1137 | for (Int n = 0; n < iCols; n+=16 ) |
---|
1138 | { |
---|
1139 | |
---|
1140 | iTemp = piOrg[n+ 0] - piCur[n+ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1141 | iTemp = piOrg[n+ 1] - piCur[n+ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1142 | iTemp = piOrg[n+ 2] - piCur[n+ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1143 | iTemp = piOrg[n+ 3] - piCur[n+ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1144 | iTemp = piOrg[n+ 4] - piCur[n+ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1145 | iTemp = piOrg[n+ 5] - piCur[n+ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1146 | iTemp = piOrg[n+ 6] - piCur[n+ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1147 | iTemp = piOrg[n+ 7] - piCur[n+ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1148 | iTemp = piOrg[n+ 8] - piCur[n+ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1149 | iTemp = piOrg[n+ 9] - piCur[n+ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1150 | iTemp = piOrg[n+10] - piCur[n+10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1151 | iTemp = piOrg[n+11] - piCur[n+11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1152 | iTemp = piOrg[n+12] - piCur[n+12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1153 | iTemp = piOrg[n+13] - piCur[n+13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1154 | iTemp = piOrg[n+14] - piCur[n+14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1155 | iTemp = piOrg[n+15] - piCur[n+15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1156 | |
---|
1157 | } |
---|
1158 | piOrg += iStrideOrg; |
---|
1159 | piCur += iStrideCur; |
---|
1160 | } |
---|
1161 | |
---|
1162 | return ( uiSum ); |
---|
1163 | } |
---|
1164 | |
---|
1165 | Distortion TComRdCost::xGetSSE32( DistParam* pcDtParam ) |
---|
1166 | { |
---|
1167 | if ( pcDtParam->bApplyWeight ) |
---|
1168 | { |
---|
1169 | assert( pcDtParam->iCols == 32 ); |
---|
1170 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
1171 | } |
---|
1172 | const Pel* piOrg = pcDtParam->pOrg; |
---|
1173 | const Pel* piCur = pcDtParam->pCur; |
---|
1174 | Int iRows = pcDtParam->iRows; |
---|
1175 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1176 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1177 | |
---|
1178 | Distortion uiSum = 0; |
---|
1179 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1180 | |
---|
1181 | Intermediate_Int iTemp; |
---|
1182 | |
---|
1183 | for( ; iRows != 0; iRows-- ) |
---|
1184 | { |
---|
1185 | |
---|
1186 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1187 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1188 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1189 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1190 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1191 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1192 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1193 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1194 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1195 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1196 | iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1197 | iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1198 | iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1199 | iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1200 | iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1201 | iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1202 | iTemp = piOrg[16] - piCur[16]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1203 | iTemp = piOrg[17] - piCur[17]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1204 | iTemp = piOrg[18] - piCur[18]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1205 | iTemp = piOrg[19] - piCur[19]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1206 | iTemp = piOrg[20] - piCur[20]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1207 | iTemp = piOrg[21] - piCur[21]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1208 | iTemp = piOrg[22] - piCur[22]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1209 | iTemp = piOrg[23] - piCur[23]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1210 | iTemp = piOrg[24] - piCur[24]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1211 | iTemp = piOrg[25] - piCur[25]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1212 | iTemp = piOrg[26] - piCur[26]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1213 | iTemp = piOrg[27] - piCur[27]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1214 | iTemp = piOrg[28] - piCur[28]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1215 | iTemp = piOrg[29] - piCur[29]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1216 | iTemp = piOrg[30] - piCur[30]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1217 | iTemp = piOrg[31] - piCur[31]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1218 | |
---|
1219 | piOrg += iStrideOrg; |
---|
1220 | piCur += iStrideCur; |
---|
1221 | } |
---|
1222 | |
---|
1223 | return ( uiSum ); |
---|
1224 | } |
---|
1225 | |
---|
1226 | Distortion TComRdCost::xGetSSE64( DistParam* pcDtParam ) |
---|
1227 | { |
---|
1228 | if ( pcDtParam->bApplyWeight ) |
---|
1229 | { |
---|
1230 | assert( pcDtParam->iCols == 64 ); |
---|
1231 | return TComRdCostWeightPrediction::xGetSSEw( pcDtParam ); |
---|
1232 | } |
---|
1233 | const Pel* piOrg = pcDtParam->pOrg; |
---|
1234 | const Pel* piCur = pcDtParam->pCur; |
---|
1235 | Int iRows = pcDtParam->iRows; |
---|
1236 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1237 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1238 | |
---|
1239 | Distortion uiSum = 0; |
---|
1240 | UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1); |
---|
1241 | |
---|
1242 | Intermediate_Int iTemp; |
---|
1243 | |
---|
1244 | for( ; iRows != 0; iRows-- ) |
---|
1245 | { |
---|
1246 | iTemp = piOrg[ 0] - piCur[ 0]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1247 | iTemp = piOrg[ 1] - piCur[ 1]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1248 | iTemp = piOrg[ 2] - piCur[ 2]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1249 | iTemp = piOrg[ 3] - piCur[ 3]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1250 | iTemp = piOrg[ 4] - piCur[ 4]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1251 | iTemp = piOrg[ 5] - piCur[ 5]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1252 | iTemp = piOrg[ 6] - piCur[ 6]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1253 | iTemp = piOrg[ 7] - piCur[ 7]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1254 | iTemp = piOrg[ 8] - piCur[ 8]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1255 | iTemp = piOrg[ 9] - piCur[ 9]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1256 | iTemp = piOrg[10] - piCur[10]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1257 | iTemp = piOrg[11] - piCur[11]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1258 | iTemp = piOrg[12] - piCur[12]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1259 | iTemp = piOrg[13] - piCur[13]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1260 | iTemp = piOrg[14] - piCur[14]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1261 | iTemp = piOrg[15] - piCur[15]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1262 | iTemp = piOrg[16] - piCur[16]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1263 | iTemp = piOrg[17] - piCur[17]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1264 | iTemp = piOrg[18] - piCur[18]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1265 | iTemp = piOrg[19] - piCur[19]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1266 | iTemp = piOrg[20] - piCur[20]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1267 | iTemp = piOrg[21] - piCur[21]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1268 | iTemp = piOrg[22] - piCur[22]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1269 | iTemp = piOrg[23] - piCur[23]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1270 | iTemp = piOrg[24] - piCur[24]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1271 | iTemp = piOrg[25] - piCur[25]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1272 | iTemp = piOrg[26] - piCur[26]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1273 | iTemp = piOrg[27] - piCur[27]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1274 | iTemp = piOrg[28] - piCur[28]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1275 | iTemp = piOrg[29] - piCur[29]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1276 | iTemp = piOrg[30] - piCur[30]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1277 | iTemp = piOrg[31] - piCur[31]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1278 | iTemp = piOrg[32] - piCur[32]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1279 | iTemp = piOrg[33] - piCur[33]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1280 | iTemp = piOrg[34] - piCur[34]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1281 | iTemp = piOrg[35] - piCur[35]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1282 | iTemp = piOrg[36] - piCur[36]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1283 | iTemp = piOrg[37] - piCur[37]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1284 | iTemp = piOrg[38] - piCur[38]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1285 | iTemp = piOrg[39] - piCur[39]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1286 | iTemp = piOrg[40] - piCur[40]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1287 | iTemp = piOrg[41] - piCur[41]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1288 | iTemp = piOrg[42] - piCur[42]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1289 | iTemp = piOrg[43] - piCur[43]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1290 | iTemp = piOrg[44] - piCur[44]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1291 | iTemp = piOrg[45] - piCur[45]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1292 | iTemp = piOrg[46] - piCur[46]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1293 | iTemp = piOrg[47] - piCur[47]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1294 | iTemp = piOrg[48] - piCur[48]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1295 | iTemp = piOrg[49] - piCur[49]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1296 | iTemp = piOrg[50] - piCur[50]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1297 | iTemp = piOrg[51] - piCur[51]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1298 | iTemp = piOrg[52] - piCur[52]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1299 | iTemp = piOrg[53] - piCur[53]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1300 | iTemp = piOrg[54] - piCur[54]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1301 | iTemp = piOrg[55] - piCur[55]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1302 | iTemp = piOrg[56] - piCur[56]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1303 | iTemp = piOrg[57] - piCur[57]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1304 | iTemp = piOrg[58] - piCur[58]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1305 | iTemp = piOrg[59] - piCur[59]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1306 | iTemp = piOrg[60] - piCur[60]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1307 | iTemp = piOrg[61] - piCur[61]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1308 | iTemp = piOrg[62] - piCur[62]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1309 | iTemp = piOrg[63] - piCur[63]; uiSum += Distortion(( iTemp * iTemp ) >> uiShift); |
---|
1310 | |
---|
1311 | piOrg += iStrideOrg; |
---|
1312 | piCur += iStrideCur; |
---|
1313 | } |
---|
1314 | |
---|
1315 | return ( uiSum ); |
---|
1316 | } |
---|
1317 | |
---|
1318 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1319 | // HADAMARD with step (used in fractional search) |
---|
1320 | // -------------------------------------------------------------------------------------------------------------------- |
---|
1321 | |
---|
1322 | Distortion TComRdCost::xCalcHADs2x2( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1323 | { |
---|
1324 | Distortion satd = 0; |
---|
1325 | TCoeff diff[4], m[4]; |
---|
1326 | assert( iStep == 1 ); |
---|
1327 | diff[0] = piOrg[0 ] - piCur[0]; |
---|
1328 | diff[1] = piOrg[1 ] - piCur[1]; |
---|
1329 | diff[2] = piOrg[iStrideOrg ] - piCur[0 + iStrideCur]; |
---|
1330 | diff[3] = piOrg[iStrideOrg + 1] - piCur[1 + iStrideCur]; |
---|
1331 | m[0] = diff[0] + diff[2]; |
---|
1332 | m[1] = diff[1] + diff[3]; |
---|
1333 | m[2] = diff[0] - diff[2]; |
---|
1334 | m[3] = diff[1] - diff[3]; |
---|
1335 | |
---|
1336 | satd += abs(m[0] + m[1]); |
---|
1337 | satd += abs(m[0] - m[1]); |
---|
1338 | satd += abs(m[2] + m[3]); |
---|
1339 | satd += abs(m[2] - m[3]); |
---|
1340 | |
---|
1341 | return satd; |
---|
1342 | } |
---|
1343 | |
---|
1344 | Distortion TComRdCost::xCalcHADs4x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1345 | { |
---|
1346 | Int k; |
---|
1347 | Distortion satd = 0; |
---|
1348 | TCoeff diff[16], m[16], d[16]; |
---|
1349 | |
---|
1350 | assert( iStep == 1 ); |
---|
1351 | for( k = 0; k < 16; k+=4 ) |
---|
1352 | { |
---|
1353 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1354 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1355 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1356 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1357 | |
---|
1358 | piCur += iStrideCur; |
---|
1359 | piOrg += iStrideOrg; |
---|
1360 | } |
---|
1361 | |
---|
1362 | /*===== hadamard transform =====*/ |
---|
1363 | m[ 0] = diff[ 0] + diff[12]; |
---|
1364 | m[ 1] = diff[ 1] + diff[13]; |
---|
1365 | m[ 2] = diff[ 2] + diff[14]; |
---|
1366 | m[ 3] = diff[ 3] + diff[15]; |
---|
1367 | m[ 4] = diff[ 4] + diff[ 8]; |
---|
1368 | m[ 5] = diff[ 5] + diff[ 9]; |
---|
1369 | m[ 6] = diff[ 6] + diff[10]; |
---|
1370 | m[ 7] = diff[ 7] + diff[11]; |
---|
1371 | m[ 8] = diff[ 4] - diff[ 8]; |
---|
1372 | m[ 9] = diff[ 5] - diff[ 9]; |
---|
1373 | m[10] = diff[ 6] - diff[10]; |
---|
1374 | m[11] = diff[ 7] - diff[11]; |
---|
1375 | m[12] = diff[ 0] - diff[12]; |
---|
1376 | m[13] = diff[ 1] - diff[13]; |
---|
1377 | m[14] = diff[ 2] - diff[14]; |
---|
1378 | m[15] = diff[ 3] - diff[15]; |
---|
1379 | |
---|
1380 | d[ 0] = m[ 0] + m[ 4]; |
---|
1381 | d[ 1] = m[ 1] + m[ 5]; |
---|
1382 | d[ 2] = m[ 2] + m[ 6]; |
---|
1383 | d[ 3] = m[ 3] + m[ 7]; |
---|
1384 | d[ 4] = m[ 8] + m[12]; |
---|
1385 | d[ 5] = m[ 9] + m[13]; |
---|
1386 | d[ 6] = m[10] + m[14]; |
---|
1387 | d[ 7] = m[11] + m[15]; |
---|
1388 | d[ 8] = m[ 0] - m[ 4]; |
---|
1389 | d[ 9] = m[ 1] - m[ 5]; |
---|
1390 | d[10] = m[ 2] - m[ 6]; |
---|
1391 | d[11] = m[ 3] - m[ 7]; |
---|
1392 | d[12] = m[12] - m[ 8]; |
---|
1393 | d[13] = m[13] - m[ 9]; |
---|
1394 | d[14] = m[14] - m[10]; |
---|
1395 | d[15] = m[15] - m[11]; |
---|
1396 | |
---|
1397 | m[ 0] = d[ 0] + d[ 3]; |
---|
1398 | m[ 1] = d[ 1] + d[ 2]; |
---|
1399 | m[ 2] = d[ 1] - d[ 2]; |
---|
1400 | m[ 3] = d[ 0] - d[ 3]; |
---|
1401 | m[ 4] = d[ 4] + d[ 7]; |
---|
1402 | m[ 5] = d[ 5] + d[ 6]; |
---|
1403 | m[ 6] = d[ 5] - d[ 6]; |
---|
1404 | m[ 7] = d[ 4] - d[ 7]; |
---|
1405 | m[ 8] = d[ 8] + d[11]; |
---|
1406 | m[ 9] = d[ 9] + d[10]; |
---|
1407 | m[10] = d[ 9] - d[10]; |
---|
1408 | m[11] = d[ 8] - d[11]; |
---|
1409 | m[12] = d[12] + d[15]; |
---|
1410 | m[13] = d[13] + d[14]; |
---|
1411 | m[14] = d[13] - d[14]; |
---|
1412 | m[15] = d[12] - d[15]; |
---|
1413 | |
---|
1414 | d[ 0] = m[ 0] + m[ 1]; |
---|
1415 | d[ 1] = m[ 0] - m[ 1]; |
---|
1416 | d[ 2] = m[ 2] + m[ 3]; |
---|
1417 | d[ 3] = m[ 3] - m[ 2]; |
---|
1418 | d[ 4] = m[ 4] + m[ 5]; |
---|
1419 | d[ 5] = m[ 4] - m[ 5]; |
---|
1420 | d[ 6] = m[ 6] + m[ 7]; |
---|
1421 | d[ 7] = m[ 7] - m[ 6]; |
---|
1422 | d[ 8] = m[ 8] + m[ 9]; |
---|
1423 | d[ 9] = m[ 8] - m[ 9]; |
---|
1424 | d[10] = m[10] + m[11]; |
---|
1425 | d[11] = m[11] - m[10]; |
---|
1426 | d[12] = m[12] + m[13]; |
---|
1427 | d[13] = m[12] - m[13]; |
---|
1428 | d[14] = m[14] + m[15]; |
---|
1429 | d[15] = m[15] - m[14]; |
---|
1430 | |
---|
1431 | for (k=0; k<16; ++k) |
---|
1432 | { |
---|
1433 | satd += abs(d[k]); |
---|
1434 | } |
---|
1435 | satd = ((satd+1)>>1); |
---|
1436 | |
---|
1437 | return satd; |
---|
1438 | } |
---|
1439 | |
---|
1440 | Distortion TComRdCost::xCalcHADs8x8( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep ) |
---|
1441 | { |
---|
1442 | Int k, i, j, jj; |
---|
1443 | Distortion sad = 0; |
---|
1444 | TCoeff diff[64], m1[8][8], m2[8][8], m3[8][8]; |
---|
1445 | assert( iStep == 1 ); |
---|
1446 | for( k = 0; k < 64; k += 8 ) |
---|
1447 | { |
---|
1448 | diff[k+0] = piOrg[0] - piCur[0]; |
---|
1449 | diff[k+1] = piOrg[1] - piCur[1]; |
---|
1450 | diff[k+2] = piOrg[2] - piCur[2]; |
---|
1451 | diff[k+3] = piOrg[3] - piCur[3]; |
---|
1452 | diff[k+4] = piOrg[4] - piCur[4]; |
---|
1453 | diff[k+5] = piOrg[5] - piCur[5]; |
---|
1454 | diff[k+6] = piOrg[6] - piCur[6]; |
---|
1455 | diff[k+7] = piOrg[7] - piCur[7]; |
---|
1456 | |
---|
1457 | piCur += iStrideCur; |
---|
1458 | piOrg += iStrideOrg; |
---|
1459 | } |
---|
1460 | |
---|
1461 | //horizontal |
---|
1462 | for (j=0; j < 8; j++) |
---|
1463 | { |
---|
1464 | jj = j << 3; |
---|
1465 | m2[j][0] = diff[jj ] + diff[jj+4]; |
---|
1466 | m2[j][1] = diff[jj+1] + diff[jj+5]; |
---|
1467 | m2[j][2] = diff[jj+2] + diff[jj+6]; |
---|
1468 | m2[j][3] = diff[jj+3] + diff[jj+7]; |
---|
1469 | m2[j][4] = diff[jj ] - diff[jj+4]; |
---|
1470 | m2[j][5] = diff[jj+1] - diff[jj+5]; |
---|
1471 | m2[j][6] = diff[jj+2] - diff[jj+6]; |
---|
1472 | m2[j][7] = diff[jj+3] - diff[jj+7]; |
---|
1473 | |
---|
1474 | m1[j][0] = m2[j][0] + m2[j][2]; |
---|
1475 | m1[j][1] = m2[j][1] + m2[j][3]; |
---|
1476 | m1[j][2] = m2[j][0] - m2[j][2]; |
---|
1477 | m1[j][3] = m2[j][1] - m2[j][3]; |
---|
1478 | m1[j][4] = m2[j][4] + m2[j][6]; |
---|
1479 | m1[j][5] = m2[j][5] + m2[j][7]; |
---|
1480 | m1[j][6] = m2[j][4] - m2[j][6]; |
---|
1481 | m1[j][7] = m2[j][5] - m2[j][7]; |
---|
1482 | |
---|
1483 | m2[j][0] = m1[j][0] + m1[j][1]; |
---|
1484 | m2[j][1] = m1[j][0] - m1[j][1]; |
---|
1485 | m2[j][2] = m1[j][2] + m1[j][3]; |
---|
1486 | m2[j][3] = m1[j][2] - m1[j][3]; |
---|
1487 | m2[j][4] = m1[j][4] + m1[j][5]; |
---|
1488 | m2[j][5] = m1[j][4] - m1[j][5]; |
---|
1489 | m2[j][6] = m1[j][6] + m1[j][7]; |
---|
1490 | m2[j][7] = m1[j][6] - m1[j][7]; |
---|
1491 | } |
---|
1492 | |
---|
1493 | //vertical |
---|
1494 | for (i=0; i < 8; i++) |
---|
1495 | { |
---|
1496 | m3[0][i] = m2[0][i] + m2[4][i]; |
---|
1497 | m3[1][i] = m2[1][i] + m2[5][i]; |
---|
1498 | m3[2][i] = m2[2][i] + m2[6][i]; |
---|
1499 | m3[3][i] = m2[3][i] + m2[7][i]; |
---|
1500 | m3[4][i] = m2[0][i] - m2[4][i]; |
---|
1501 | m3[5][i] = m2[1][i] - m2[5][i]; |
---|
1502 | m3[6][i] = m2[2][i] - m2[6][i]; |
---|
1503 | m3[7][i] = m2[3][i] - m2[7][i]; |
---|
1504 | |
---|
1505 | m1[0][i] = m3[0][i] + m3[2][i]; |
---|
1506 | m1[1][i] = m3[1][i] + m3[3][i]; |
---|
1507 | m1[2][i] = m3[0][i] - m3[2][i]; |
---|
1508 | m1[3][i] = m3[1][i] - m3[3][i]; |
---|
1509 | m1[4][i] = m3[4][i] + m3[6][i]; |
---|
1510 | m1[5][i] = m3[5][i] + m3[7][i]; |
---|
1511 | m1[6][i] = m3[4][i] - m3[6][i]; |
---|
1512 | m1[7][i] = m3[5][i] - m3[7][i]; |
---|
1513 | |
---|
1514 | m2[0][i] = m1[0][i] + m1[1][i]; |
---|
1515 | m2[1][i] = m1[0][i] - m1[1][i]; |
---|
1516 | m2[2][i] = m1[2][i] + m1[3][i]; |
---|
1517 | m2[3][i] = m1[2][i] - m1[3][i]; |
---|
1518 | m2[4][i] = m1[4][i] + m1[5][i]; |
---|
1519 | m2[5][i] = m1[4][i] - m1[5][i]; |
---|
1520 | m2[6][i] = m1[6][i] + m1[7][i]; |
---|
1521 | m2[7][i] = m1[6][i] - m1[7][i]; |
---|
1522 | } |
---|
1523 | |
---|
1524 | for (i = 0; i < 8; i++) |
---|
1525 | { |
---|
1526 | for (j = 0; j < 8; j++) |
---|
1527 | { |
---|
1528 | sad += abs(m2[i][j]); |
---|
1529 | } |
---|
1530 | } |
---|
1531 | |
---|
1532 | sad=((sad+2)>>2); |
---|
1533 | |
---|
1534 | return sad; |
---|
1535 | } |
---|
1536 | |
---|
1537 | |
---|
1538 | Distortion TComRdCost::xGetHADs( DistParam* pcDtParam ) |
---|
1539 | { |
---|
1540 | if ( pcDtParam->bApplyWeight ) |
---|
1541 | { |
---|
1542 | return TComRdCostWeightPrediction::xGetHADsw( pcDtParam ); |
---|
1543 | } |
---|
1544 | Pel* piOrg = pcDtParam->pOrg; |
---|
1545 | Pel* piCur = pcDtParam->pCur; |
---|
1546 | Int iRows = pcDtParam->iRows; |
---|
1547 | Int iCols = pcDtParam->iCols; |
---|
1548 | Int iStrideCur = pcDtParam->iStrideCur; |
---|
1549 | Int iStrideOrg = pcDtParam->iStrideOrg; |
---|
1550 | Int iStep = pcDtParam->iStep; |
---|
1551 | |
---|
1552 | Int x, y; |
---|
1553 | |
---|
1554 | Distortion uiSum = 0; |
---|
1555 | |
---|
1556 | if( ( iRows % 8 == 0) && (iCols % 8 == 0) ) |
---|
1557 | { |
---|
1558 | Int iOffsetOrg = iStrideOrg<<3; |
---|
1559 | Int iOffsetCur = iStrideCur<<3; |
---|
1560 | for ( y=0; y<iRows; y+= 8 ) |
---|
1561 | { |
---|
1562 | for ( x=0; x<iCols; x+= 8 ) |
---|
1563 | { |
---|
1564 | uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
1565 | } |
---|
1566 | piOrg += iOffsetOrg; |
---|
1567 | piCur += iOffsetCur; |
---|
1568 | } |
---|
1569 | } |
---|
1570 | else if( ( iRows % 4 == 0) && (iCols % 4 == 0) ) |
---|
1571 | { |
---|
1572 | Int iOffsetOrg = iStrideOrg<<2; |
---|
1573 | Int iOffsetCur = iStrideCur<<2; |
---|
1574 | |
---|
1575 | for ( y=0; y<iRows; y+= 4 ) |
---|
1576 | { |
---|
1577 | for ( x=0; x<iCols; x+= 4 ) |
---|
1578 | { |
---|
1579 | uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
1580 | } |
---|
1581 | piOrg += iOffsetOrg; |
---|
1582 | piCur += iOffsetCur; |
---|
1583 | } |
---|
1584 | } |
---|
1585 | else if( ( iRows % 2 == 0) && (iCols % 2 == 0) ) |
---|
1586 | { |
---|
1587 | Int iOffsetOrg = iStrideOrg<<1; |
---|
1588 | Int iOffsetCur = iStrideCur<<1; |
---|
1589 | for ( y=0; y<iRows; y+=2 ) |
---|
1590 | { |
---|
1591 | for ( x=0; x<iCols; x+=2 ) |
---|
1592 | { |
---|
1593 | uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep ); |
---|
1594 | } |
---|
1595 | piOrg += iOffsetOrg; |
---|
1596 | piCur += iOffsetCur; |
---|
1597 | } |
---|
1598 | } |
---|
1599 | else |
---|
1600 | { |
---|
1601 | assert(false); |
---|
1602 | } |
---|
1603 | |
---|
1604 | return ( uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8) ); |
---|
1605 | } |
---|
1606 | |
---|
1607 | //! \} |
---|