Adding sse_to_psnr function to tools_common.{h, c}.

Change-Id: Id5f974172416499ff55b0929e315b12d16ff1b1b
This commit is contained in:
Dmitry Kovalev
2014-02-27 14:00:41 -08:00
parent c57fc4f38c
commit 2dad0e1238
6 changed files with 22 additions and 37 deletions

View File

@@ -8,13 +8,14 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "tools_common.h"
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "./tools_common.h"
#if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER
#include "vpx/vp8cx.h"
#endif
@@ -273,3 +274,14 @@ int vpx_img_read(vpx_image_t *img, FILE *file) {
return 1;
}
// TODO(dkovalev) change sse_to_psnr signature: double -> int64_t
double sse_to_psnr(double samples, double peak, double sse) {
static const double kMaxPSNR = 100.0;
if (sse > 0.0) {
const double psnr = 10.0 * log10(samples * peak * peak / sse);
return psnr > kMaxPSNR ? kMaxPSNR : psnr;
} else {
return kMaxPSNR;
}
}