57 const Pel *piOrg = pcDtParam->
pOrg;
58 const Pel *piCur = pcDtParam->
pCur;
68 const Int w0 = wpCur.
w;
82 for(
Int iRows = pcDtParam->
iRows; iRows != 0; iRows-- )
84 for (
Int n = 0; n < iCols; n++ )
86 uiSum += abs( piOrg[n] - piCur[n] );
90 return uiSum >> distortionShift;
103 for(
Int iRows = pcDtParam->
iRows; iRows != 0; iRows-- )
105 for (
Int n = 0; n < iCols; n++ )
107 uiSum += abs( piOrg[n] - (piCur[n] + offset) );
111 return uiSum >> distortionShift;
121 for(
Int iRows = pcDtParam->
iRows; iRows != 0; iRows-- )
123 for (
Int n = 0; n < iCols; n++ )
125 const Pel pred =
Clip3((
Pel) 0, iMaxValue, (
Pel) (piCur[n] + offset)) ;
127 uiSum += abs( piOrg[n] - pred );
131 return uiSum >> distortionShift;
146 for(
Int iRows = pcDtParam->
iRows; iRows != 0; iRows-- )
148 for (
Int n = 0; n < iCols; n++ )
150 const Pel pred = ( (w0*piCur[n] + round) >> shift ) + offset ;
151 uiSum += abs( piOrg[n] - pred );
155 return uiSum >> distortionShift;
168 for(
Int iRows = pcDtParam->
iRows; iRows != 0; iRows-- )
170 for (
Int n = 0; n < iCols; n++ )
172 const Pel pred =
Clip3((
Pel) 0, iMaxValue, (
Pel) (( (w0*piCur[n] + round) >> shift ))) ;
174 uiSum += abs( piOrg[n] - pred );
178 return uiSum >> distortionShift;
186 for(
Int iRows = pcDtParam->
iRows; iRows != 0; iRows-- )
188 for (
Int n = 0; n < iCols; n++ )
190 const Pel pred =
Clip3((
Pel) 0, iMaxValue, (
Pel) (( (w0*piCur[n] + round) >> shift ) + offset)) ;
192 uiSum += abs( piOrg[n] - pred );
196 return uiSum >> distortionShift;
206 return uiSum >> distortionShift;
219 const Pel *piOrg = pcDtParam->
pOrg;
220 const Pel *piCur = pcDtParam->
pCur;
230 const Int w0 = wpCur.
w;
240 for(
Int iRows = pcDtParam->
iRows ; iRows != 0; iRows-- )
242 for (
Int n = 0; n < iCols; n++ )
244 const Pel pred = ( (w0*piCur[n] + round) >> shift ) + offset ;
245 const Pel residual = piOrg[n] - pred;
256 for(
Int iRows = pcDtParam->
iRows ; iRows != 0; iRows-- )
258 for (
Int n = 0; n < iCols; n++ )
260 const Pel pred =
Clip3((
Pel) 0, iMaxValue, (
Pel) (( (w0*piCur[n] + round) >> shift ) + offset)) ;
261 const Pel residual = piOrg[n] - pred;
284 const Int w0 = wpCur.
w;
292 pred = ( (w0*piCur[0*iStep ] + round) >> shift ) + offset ;
293 diff[0] = piOrg[0 ] - pred;
294 pred = ( (w0*piCur[1*iStep ] + round) >> shift ) + offset ;
295 diff[1] = piOrg[1 ] - pred;
296 pred = ( (w0*piCur[0*iStep + iStrideCur] + round) >> shift ) + offset ;
297 diff[2] = piOrg[iStrideOrg ] - pred;
298 pred = ( (w0*piCur[1*iStep + iStrideCur] + round) >> shift ) + offset ;
299 diff[3] = piOrg[iStrideOrg + 1] - pred;
301 m[0] = diff[0] + diff[2];
302 m[1] = diff[1] + diff[3];
303 m[2] = diff[0] - diff[2];
304 m[3] = diff[1] - diff[3];
306 satd += abs(m[0] + m[1]);
307 satd += abs(m[0] - m[1]);
308 satd += abs(m[2] + m[3]);
309 satd += abs(m[2] - m[3]);
321 const Int w0 = wpCur.
w;
329 for(
Int k = 0; k < 16; k+=4 )
332 pred = ( (w0*piCur[0*iStep] + round) >> shift ) + offset ;
333 diff[k+0] = piOrg[0] - pred;
334 pred = ( (w0*piCur[1*iStep] + round) >> shift ) + offset ;
335 diff[k+1] = piOrg[1] - pred;
336 pred = ( (w0*piCur[2*iStep] + round) >> shift ) + offset ;
337 diff[k+2] = piOrg[2] - pred;
338 pred = ( (w0*piCur[3*iStep] + round) >> shift ) + offset ;
339 diff[k+3] = piOrg[3] - pred;
346 m[ 0] = diff[ 0] + diff[12];
347 m[ 1] = diff[ 1] + diff[13];
348 m[ 2] = diff[ 2] + diff[14];
349 m[ 3] = diff[ 3] + diff[15];
350 m[ 4] = diff[ 4] + diff[ 8];
351 m[ 5] = diff[ 5] + diff[ 9];
352 m[ 6] = diff[ 6] + diff[10];
353 m[ 7] = diff[ 7] + diff[11];
354 m[ 8] = diff[ 4] - diff[ 8];
355 m[ 9] = diff[ 5] - diff[ 9];
356 m[10] = diff[ 6] - diff[10];
357 m[11] = diff[ 7] - diff[11];
358 m[12] = diff[ 0] - diff[12];
359 m[13] = diff[ 1] - diff[13];
360 m[14] = diff[ 2] - diff[14];
361 m[15] = diff[ 3] - diff[15];
363 d[ 0] = m[ 0] + m[ 4];
364 d[ 1] = m[ 1] + m[ 5];
365 d[ 2] = m[ 2] + m[ 6];
366 d[ 3] = m[ 3] + m[ 7];
367 d[ 4] = m[ 8] + m[12];
368 d[ 5] = m[ 9] + m[13];
369 d[ 6] = m[10] + m[14];
370 d[ 7] = m[11] + m[15];
371 d[ 8] = m[ 0] - m[ 4];
372 d[ 9] = m[ 1] - m[ 5];
373 d[10] = m[ 2] - m[ 6];
374 d[11] = m[ 3] - m[ 7];
375 d[12] = m[12] - m[ 8];
376 d[13] = m[13] - m[ 9];
377 d[14] = m[14] - m[10];
378 d[15] = m[15] - m[11];
380 m[ 0] = d[ 0] + d[ 3];
381 m[ 1] = d[ 1] + d[ 2];
382 m[ 2] = d[ 1] - d[ 2];
383 m[ 3] = d[ 0] - d[ 3];
384 m[ 4] = d[ 4] + d[ 7];
385 m[ 5] = d[ 5] + d[ 6];
386 m[ 6] = d[ 5] - d[ 6];
387 m[ 7] = d[ 4] - d[ 7];
388 m[ 8] = d[ 8] + d[11];
389 m[ 9] = d[ 9] + d[10];
390 m[10] = d[ 9] - d[10];
391 m[11] = d[ 8] - d[11];
392 m[12] = d[12] + d[15];
393 m[13] = d[13] + d[14];
394 m[14] = d[13] - d[14];
395 m[15] = d[12] - d[15];
397 d[ 0] = m[ 0] + m[ 1];
398 d[ 1] = m[ 0] - m[ 1];
399 d[ 2] = m[ 2] + m[ 3];
400 d[ 3] = m[ 3] - m[ 2];
401 d[ 4] = m[ 4] + m[ 5];
402 d[ 5] = m[ 4] - m[ 5];
403 d[ 6] = m[ 6] + m[ 7];
404 d[ 7] = m[ 7] - m[ 6];
405 d[ 8] = m[ 8] + m[ 9];
406 d[ 9] = m[ 8] - m[ 9];
407 d[10] = m[10] + m[11];
408 d[11] = m[11] - m[10];
409 d[12] = m[12] + m[13];
410 d[13] = m[12] - m[13];
411 d[14] = m[14] + m[15];
412 d[15] = m[15] - m[14];
414 for (
Int k=0; k<16; ++k)
418 satd = ((satd+1)>>1);
428 TCoeff diff[64], m1[8][8], m2[8][8], m3[8][8];
429 Int iStep2 = iStep<<1;
430 Int iStep3 = iStep2 + iStep;
431 Int iStep4 = iStep3 + iStep;
432 Int iStep5 = iStep4 + iStep;
433 Int iStep6 = iStep5 + iStep;
434 Int iStep7 = iStep6 + iStep;
438 const Int w0 = wpCur.
w;
442 for(
Int k = 0; k < 64; k+=8 )
444 pred = ( (w0*piCur[ 0] + round) >> shift ) + offset ;
445 diff[k+0] = piOrg[0] - pred;
446 pred = ( (w0*piCur[iStep ] + round) >> shift ) + offset ;
447 diff[k+1] = piOrg[1] - pred;
448 pred = ( (w0*piCur[iStep2] + round) >> shift ) + offset ;
449 diff[k+2] = piOrg[2] - pred;
450 pred = ( (w0*piCur[iStep3] + round) >> shift ) + offset ;
451 diff[k+3] = piOrg[3] - pred;
452 pred = ( (w0*piCur[iStep4] + round) >> shift ) + offset ;
453 diff[k+4] = piOrg[4] - pred;
454 pred = ( (w0*piCur[iStep5] + round) >> shift ) + offset ;
455 diff[k+5] = piOrg[5] - pred;
456 pred = ( (w0*piCur[iStep6] + round) >> shift ) + offset ;
457 diff[k+6] = piOrg[6] - pred;
458 pred = ( (w0*piCur[iStep7] + round) >> shift ) + offset ;
459 diff[k+7] = piOrg[7] - pred;
466 for (
Int j=0; j < 8; j++)
468 const Int jj = j << 3;
469 m2[j][0] = diff[jj ] + diff[jj+4];
470 m2[j][1] = diff[jj+1] + diff[jj+5];
471 m2[j][2] = diff[jj+2] + diff[jj+6];
472 m2[j][3] = diff[jj+3] + diff[jj+7];
473 m2[j][4] = diff[jj ] - diff[jj+4];
474 m2[j][5] = diff[jj+1] - diff[jj+5];
475 m2[j][6] = diff[jj+2] - diff[jj+6];
476 m2[j][7] = diff[jj+3] - diff[jj+7];
478 m1[j][0] = m2[j][0] + m2[j][2];
479 m1[j][1] = m2[j][1] + m2[j][3];
480 m1[j][2] = m2[j][0] - m2[j][2];
481 m1[j][3] = m2[j][1] - m2[j][3];
482 m1[j][4] = m2[j][4] + m2[j][6];
483 m1[j][5] = m2[j][5] + m2[j][7];
484 m1[j][6] = m2[j][4] - m2[j][6];
485 m1[j][7] = m2[j][5] - m2[j][7];
487 m2[j][0] = m1[j][0] + m1[j][1];
488 m2[j][1] = m1[j][0] - m1[j][1];
489 m2[j][2] = m1[j][2] + m1[j][3];
490 m2[j][3] = m1[j][2] - m1[j][3];
491 m2[j][4] = m1[j][4] + m1[j][5];
492 m2[j][5] = m1[j][4] - m1[j][5];
493 m2[j][6] = m1[j][6] + m1[j][7];
494 m2[j][7] = m1[j][6] - m1[j][7];
498 for (
Int i=0; i < 8; i++)
500 m3[0][i] = m2[0][i] + m2[4][i];
501 m3[1][i] = m2[1][i] + m2[5][i];
502 m3[2][i] = m2[2][i] + m2[6][i];
503 m3[3][i] = m2[3][i] + m2[7][i];
504 m3[4][i] = m2[0][i] - m2[4][i];
505 m3[5][i] = m2[1][i] - m2[5][i];
506 m3[6][i] = m2[2][i] - m2[6][i];
507 m3[7][i] = m2[3][i] - m2[7][i];
509 m1[0][i] = m3[0][i] + m3[2][i];
510 m1[1][i] = m3[1][i] + m3[3][i];
511 m1[2][i] = m3[0][i] - m3[2][i];
512 m1[3][i] = m3[1][i] - m3[3][i];
513 m1[4][i] = m3[4][i] + m3[6][i];
514 m1[5][i] = m3[5][i] + m3[7][i];
515 m1[6][i] = m3[4][i] - m3[6][i];
516 m1[7][i] = m3[5][i] - m3[7][i];
518 m2[0][i] = m1[0][i] + m1[1][i];
519 m2[1][i] = m1[0][i] - m1[1][i];
520 m2[2][i] = m1[2][i] + m1[3][i];
521 m2[3][i] = m1[2][i] - m1[3][i];
522 m2[4][i] = m1[4][i] + m1[5][i];
523 m2[5][i] = m1[4][i] - m1[5][i];
524 m2[6][i] = m1[6][i] + m1[7][i];
525 m2[7][i] = m1[6][i] - m1[7][i];
528 for (
Int j=0; j < 8; j++)
530 for (
Int i=0; i < 8; i++)
532 sad += (abs(m2[j][i]));
545 const Pel *piOrg = pcDtParam->
pOrg;
546 const Pel *piCur = pcDtParam->
pCur;
558 if( ( iRows % 8 == 0) && (iCols % 8 == 0) )
560 const Int iOffsetOrg = iStrideOrg<<3;
561 const Int iOffsetCur = iStrideCur<<3;
562 for (
Int y=0; y<iRows; y+= 8 )
564 for (
Int x=0; x<iCols; x+= 8 )
566 uiSum +=
xCalcHADs8x8w( wpCur, &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
572 else if( ( iRows % 4 == 0) && (iCols % 4 == 0) )
574 const Int iOffsetOrg = iStrideOrg<<2;
575 const Int iOffsetCur = iStrideCur<<2;
577 for (
Int y=0; y<iRows; y+= 4 )
579 for (
Int x=0; x<iCols; x+= 4 )
581 uiSum +=
xCalcHADs4x4w( wpCur, &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
589 for (
Int y=0; y<iRows; y+=2 )
591 for (
Int x=0; x<iCols; x+=2 )
593 uiSum +=
xCalcHADs2x2w( wpCur, &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
UInt Distortion
distortion measurement
static Distortion xCalcHADs2x2w(const WPScalingParam &wpCur, const Pel *piOrg, const Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep)
get weighted Hadamard cost for 2x2 block
RD cost computation classes (header)
static Distortion xCalcHADs4x4w(const WPScalingParam &wpCur, const Pel *piOrg, const Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep)
get weighted Hadamard cost for 4x4 block
Distortion xGetHADsw(DistParam *pcDtParam)
get weighted Hadamard cost
Int iSubShift
During cost calculations, if distortion exceeds this value, cost calculations may early-terminate...
distortion parameter class
Distortion m_maximumDistortionForEarlyExit
T Clip3(const T minVal, const T maxVal, const T a)
general min/max clip
Int TCoeff
transform coefficient
static Distortion xCalcHADs8x8w(const WPScalingParam &wpCur, const Pel *piOrg, const Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep)
get weighted Hadamard cost for 8x8 block
RD cost computation namespace (header)
#define DISTORTION_PRECISION_ADJUSTMENT(x)
const WPScalingParam * wpCur
Distortion xGetSSEw(DistParam *pcDtParam)
Distortion xGetSADw(DistParam *pcDtParam)