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