diff options
author | Dmitry Kovalev <dkovalev@google.com> | 2014-02-27 16:33:54 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@gerrit.golo.chromium.org> | 2014-02-27 16:33:54 -0800 |
commit | 3bb2ae5cccc64d80c9e3a9a5ecc6199aa618c3fe (patch) | |
tree | 657acb6a58726d15cb4ec0428ae505dbcd0f3878 /tools_common.c | |
parent | acefe86ef81329ecacd6c5a11ffb43c51e82c910 (diff) | |
parent | 2dad0e1238b67b97c2dab81fe181d5e19cd963be (diff) | |
download | libvpx-3bb2ae5cccc64d80c9e3a9a5ecc6199aa618c3fe.tar libvpx-3bb2ae5cccc64d80c9e3a9a5ecc6199aa618c3fe.tar.gz libvpx-3bb2ae5cccc64d80c9e3a9a5ecc6199aa618c3fe.tar.bz2 libvpx-3bb2ae5cccc64d80c9e3a9a5ecc6199aa618c3fe.zip |
Merge "Adding sse_to_psnr function to tools_common.{h, c}."
Diffstat (limited to 'tools_common.c')
-rw-r--r-- | tools_common.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tools_common.c b/tools_common.c index 667432027..4f2ac7401 100644 --- a/tools_common.c +++ b/tools_common.c @@ -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 @@ -253,3 +254,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; + } +} |