michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: michael@0: #include "vpx_scale/yv12config.h" michael@0: #include "math.h" michael@0: #include "vp8/common/systemdependent.h" /* for vp8_clear_system_state() */ michael@0: michael@0: #define MAX_PSNR 100 michael@0: michael@0: double vp8_mse2psnr(double Samples, double Peak, double Mse) michael@0: { michael@0: double psnr; michael@0: michael@0: if ((double)Mse > 0.0) michael@0: psnr = 10.0 * log10(Peak * Peak * Samples / Mse); michael@0: else michael@0: psnr = MAX_PSNR; /* Limit to prevent / 0 */ michael@0: michael@0: if (psnr > MAX_PSNR) michael@0: psnr = MAX_PSNR; michael@0: michael@0: return psnr; michael@0: }