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