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: #include michael@0: michael@0: #include "vpx_scale/yv12config.h" michael@0: michael@0: #define MAX_PSNR 100 michael@0: michael@0: double vp9_mse2psnr(double samples, double peak, double mse) { michael@0: double psnr; michael@0: michael@0: if (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: }