/*! *********************************************************************** * \brief * Calculate SSE 4x4 *********************************************************************** */ distblk distortion4x4SSE(short* diff, distblk min_dist) { int distortion = 0, k; for (k = 0; k < 16; k++) { distortion += iabs2(*diff++); } return (dist_scale((distblk) distortion)); }
/*! *********************************************************************** * \brief * Calculate SSE for 8x8 *********************************************************************** */ distblk distortion8x8SSE(short* diff, distblk min_dist) { distblk distortion = 0; int k; for (k = 0; k < 64; k++) { distortion += iabs2(*diff++); } return (dist_scale(distortion)); }
/*! *********************************************************************** * \brief * compute 16x16 SSE *********************************************************************** */ int64 compute_SSE16x16(imgpel **imgRef, imgpel **imgSrc, int xRef, int xSrc) { int i, j; imgpel *lineRef, *lineSrc; int64 distortion = 0; for (j = 0; j < MB_BLOCK_SIZE; j++) { lineRef = &imgRef[j][xRef]; lineSrc = &imgSrc[j][xSrc]; for (i = 0; i < MB_BLOCK_SIZE; i++) distortion += iabs2( *lineRef++ - *lineSrc++ ); } return distortion; }
/*! *********************************************************************** * \brief * compute generic SSE *********************************************************************** */ int64 compute_SSE(imgpel **imgRef, imgpel **imgSrc, int xRef, int xSrc, int ySize, int xSize) { int i, j; imgpel *lineRef, *lineSrc; int64 distortion = 0; for (j = 0; j < ySize; j++) { lineRef = &imgRef[j][xRef]; lineSrc = &imgSrc[j][xSrc]; for (i = 0; i < xSize; i++) distortion += iabs2( *lineRef++ - *lineSrc++ ); } return distortion; }
/*! *********************************************************************** * \brief * compute 4x4 SSE *********************************************************************** */ distblk compute_SSE4x4(imgpel **imgRef, imgpel **imgSrc, int xRef, int xSrc) { int i, j; imgpel *lineRef, *lineSrc; distblk distortion = 0; for (j = 0; j < BLOCK_SIZE; j++) { lineRef = &imgRef[j][xRef]; lineSrc = &imgSrc[j][xSrc]; for (i = 0; i < BLOCK_SIZE; i++) distortion += iabs2( *lineRef++ - *lineSrc++ ); } return dist_scale(distortion); }
distblk compute_SSE16x16_thres(imgpel **imgRef, imgpel **imgSrc, int xRef, int xSrc, distblk min_cost) { int i, j; imgpel *lineRef, *lineSrc; distblk distortion = 0; int imin_cost = dist_down(min_cost); for (j = 0; j < MB_BLOCK_SIZE; j++) { lineRef = &imgRef[j][xRef]; lineSrc = &imgSrc[j][xSrc]; for (i = 0; i < MB_BLOCK_SIZE; i++) distortion += iabs2( *lineRef++ - *lineSrc++ ); if (distortion > imin_cost) return (min_cost); } return dist_scale(distortion); }
/*! ************************************************************************************* * \brief * SSE distortion for an 8x8 Intra block ************************************************************************************* */ distblk compute_sse8x8_cost(VideoParameters *p_Vid, imgpel **cur_img, imgpel **mpr8x8, int pic_opix_x, distblk min_cost) { int i, j; imgpel *cimg, *cmpr; int imin_cost = dist_down(min_cost); int distortion = 0; for (j=0; j<8; j++) { cimg = &cur_img[j][pic_opix_x]; cmpr = &mpr8x8[j][0]; for (i=0; i<8; i++) { distortion += iabs2(*cimg++ - *cmpr++); } if (distortion > imin_cost) { return min_cost; } } return dist_scale(distortion); }