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 "global.h"
00020 #include "img_distortion.h"
00021 #include "enc_statistics.h"
00022
00023
00024
00025
00026
00027
00028
00029 void find_snr(ImageStructure *imgREF, ImageStructure *imgSRC, DistMetric *metricSSE, DistMetric *metricPSNR)
00030 {
00031 FrameFormat *format = &imgREF->format;
00032
00033 metricSSE ->value[0] = (float) compute_SSE(imgREF->data[0], imgSRC->data[0], 0, 0, format->height, format->width);
00034 metricPSNR->value[0] = psnr(format->max_value_sq[0], format->size_cmp[0], metricSSE->value[0]);
00035
00036
00037 if (format->yuv_format != YUV400)
00038 {
00039 metricSSE ->value[1] = (float) compute_SSE(imgREF->data[1], imgSRC->data[1], 0, 0, format->height_cr, format->width_cr);
00040 metricPSNR->value[1] = psnr(format->max_value_sq[1], format->size_cmp[1], metricSSE->value[1]);
00041 metricSSE ->value[2] = (float) compute_SSE(imgREF->data[2], imgSRC->data[2], 0, 0, format->height_cr, format->width_cr);
00042 metricPSNR->value[2] = psnr(format->max_value_sq[2], format->size_cmp[2], metricSSE->value[2]);
00043 }
00044
00045 {
00046 accumulate_average(metricSSE, dist->frame_ctr);
00047 accumulate_average(metricPSNR, dist->frame_ctr);
00048
00049 accumulate_avslice(metricSSE, img->type, stats->frame_ctr[img->type]);
00050 accumulate_avslice(metricPSNR, img->type, stats->frame_ctr[img->type]);
00051 }
00052 }