1*4e366538SXin Li /* 2*4e366538SXin Li * Copyright 2013 The LibYuv Project Authors. All rights reserved. 3*4e366538SXin Li * 4*4e366538SXin Li * Use of this source code is governed by a BSD-style license 5*4e366538SXin Li * that can be found in the LICENSE file in the root of the source 6*4e366538SXin Li * tree. An additional intellectual property rights grant can be found 7*4e366538SXin Li * in the file PATENTS. All contributing project authors may 8*4e366538SXin Li * be found in the AUTHORS file in the root of the source tree. 9*4e366538SXin Li */ 10*4e366538SXin Li 11*4e366538SXin Li // Get PSNR for video sequence. Assuming RAW 4:2:0 Y:Cb:Cr format 12*4e366538SXin Li 13*4e366538SXin Li #ifndef UTIL_PSNR_H_ // NOLINT 14*4e366538SXin Li #define UTIL_PSNR_H_ 15*4e366538SXin Li 16*4e366538SXin Li #include <math.h> // For log10() 17*4e366538SXin Li 18*4e366538SXin Li #ifdef __cplusplus 19*4e366538SXin Li extern "C" { 20*4e366538SXin Li #endif 21*4e366538SXin Li 22*4e366538SXin Li #if !defined(INT_TYPES_DEFINED) && !defined(UINT8_TYPE_DEFINED) 23*4e366538SXin Li typedef unsigned char uint8_t; 24*4e366538SXin Li #define UINT8_TYPE_DEFINED 25*4e366538SXin Li #endif 26*4e366538SXin Li 27*4e366538SXin Li static const double kMaxPSNR = 128.0; 28*4e366538SXin Li 29*4e366538SXin Li // libyuv provides this function when linking library for jpeg support. 30*4e366538SXin Li // TODO(fbarchard): make psnr lib compatible subset of libyuv. 31*4e366538SXin Li #if !defined(HAVE_JPEG) 32*4e366538SXin Li // Computer Sum of Squared Error (SSE). 33*4e366538SXin Li // Pass this to ComputePSNR for final result. 34*4e366538SXin Li double ComputeSumSquareError(const uint8_t* src_a, 35*4e366538SXin Li const uint8_t* src_b, 36*4e366538SXin Li int count); 37*4e366538SXin Li #endif 38*4e366538SXin Li 39*4e366538SXin Li // PSNR formula: psnr = 10 * log10 (Peak Signal^2 * size / sse) 40*4e366538SXin Li // Returns 128.0 (kMaxPSNR) if sse is 0 (perfect match). 41*4e366538SXin Li double ComputePSNR(double sse, double size); 42*4e366538SXin Li 43*4e366538SXin Li #ifdef __cplusplus 44*4e366538SXin Li } // extern "C" 45*4e366538SXin Li #endif 46*4e366538SXin Li 47*4e366538SXin Li #endif // UTIL_PSNR_H_ // NOLINT 48