00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "contributors.h"
00016
00017 #include <math.h>
00018
00019 #include "enc_statistics.h"
00020 #include "global.h"
00021 #include "img_distortion.h"
00022 #include "md_distortion.h"
00023
00024
00025
00026
00027
00028
00029
00030 void find_snr(ImageParameters *p_Img, InputParameters *p_Inp, ImageStructure *imgREF, ImageStructure *imgSRC, DistMetric *metricSSE, DistMetric *metricPSNR)
00031 {
00032 DistortionParams *p_Dist = p_Img->p_Dist;
00033 FrameFormat *format = &imgREF->format;
00034
00035 metricSSE ->value[0] = (float) compute_SSE(imgREF->data[0], imgSRC->data[0], 0, 0, format->height, format->width);
00036 metricPSNR->value[0] = psnr(format->max_value_sq[0], format->size_cmp[0], metricSSE->value[0]);
00037
00038
00039 if (format->yuv_format != YUV400)
00040 {
00041 metricSSE ->value[1] = (float) compute_SSE(imgREF->data[1], imgSRC->data[1], 0, 0, format->height_cr, format->width_cr);
00042 metricPSNR->value[1] = psnr(format->max_value_sq[1], format->size_cmp[1], metricSSE->value[1]);
00043 metricSSE ->value[2] = (float) compute_SSE(imgREF->data[2], imgSRC->data[2], 0, 0, format->height_cr, format->width_cr);
00044 metricPSNR->value[2] = psnr(format->max_value_sq[2], format->size_cmp[2], metricSSE->value[2]);
00045 }
00046
00047 {
00048 accumulate_average(metricSSE, p_Dist->frame_ctr);
00049 accumulate_average(metricPSNR, p_Dist->frame_ctr);
00050
00051 accumulate_avslice(metricSSE, p_Img->type, p_Img->p_Stats->frame_ctr[p_Img->type]);
00052 accumulate_avslice(metricPSNR, p_Img->type, p_Img->p_Stats->frame_ctr[p_Img->type]);
00053 }
00054 }