1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vp8/encoder/psnr.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +/* 1.5 + * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 + 1.15 +#include "vpx_scale/yv12config.h" 1.16 +#include "math.h" 1.17 +#include "vp8/common/systemdependent.h" /* for vp8_clear_system_state() */ 1.18 + 1.19 +#define MAX_PSNR 100 1.20 + 1.21 +double vp8_mse2psnr(double Samples, double Peak, double Mse) 1.22 +{ 1.23 + double psnr; 1.24 + 1.25 + if ((double)Mse > 0.0) 1.26 + psnr = 10.0 * log10(Peak * Peak * Samples / Mse); 1.27 + else 1.28 + psnr = MAX_PSNR; /* Limit to prevent / 0 */ 1.29 + 1.30 + if (psnr > MAX_PSNR) 1.31 + psnr = MAX_PSNR; 1.32 + 1.33 + return psnr; 1.34 +}