00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <math.h>
00013 #include <limits.h>
00014 #include <float.h>
00015
00016 #include "global.h"
00017 #include "rdopt_coding_state.h"
00018 #include "mb_access.h"
00019 #include "intrarefresh.h"
00020 #include "image.h"
00021 #include "transform8x8.h"
00022 #include "ratectl.h"
00023 #include "mode_decision.h"
00024 #include "fmo.h"
00025 #include "me_umhex.h"
00026 #include "me_umhexsmp.h"
00027 #include "macroblock.h"
00028 #include "mv-search.h"
00029
00030
00031 int64 compute_SSE(imgpel **imgRef, imgpel **imgSrc, int xRef, int xSrc, int ySize, int xSize)
00032 {
00033 static int i, j;
00034 static imgpel *lineRef, *lineSrc;
00035 int64 distortion = 0;
00036
00037
00038 for (j = 0; j < ySize; j++)
00039 {
00040 lineRef = &imgRef[j][xRef];
00041 lineSrc = &imgSrc[j][xSrc];
00042
00043 for (i = 0; i < xSize; i++)
00044
00045 distortion += iabs2( *lineRef++ - *lineSrc++ );
00046 }
00047 return distortion;
00048 }
00049
00050
00051
00052
00053
00054
00055
00056 int64 distortionSSE(Macroblock *currMB)
00057 {
00058 int64 distortionY = 0;
00059 int64 distortionCr[2] = {0};
00060
00061
00062 distortionY = compute_SSE(&pCurImg[img->opix_y], &enc_picture->p_curr_img[img->pix_y], img->opix_x, img->pix_x, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
00063
00064
00065 if ((img->yuv_format != YUV400) && !IS_INDEPENDENT(params))
00066 {
00067
00068 distortionCr[0] = compute_SSE(&pImgOrg[1][img->opix_c_y], &enc_picture->imgUV[0][img->pix_c_y], img->opix_c_x, img->pix_c_x, img->mb_cr_size_y, img->mb_cr_size_x);
00069 distortionCr[1] = compute_SSE(&pImgOrg[2][img->opix_c_y], &enc_picture->imgUV[1][img->pix_c_y], img->opix_c_x, img->pix_c_x, img->mb_cr_size_y, img->mb_cr_size_x);
00070 }
00071
00072 return (int64)( distortionY * params->WeightY + distortionCr[0] * params->WeightCb + distortionCr[1] * params->WeightCr );
00073 }
00074
00075