1/*
2*  Copyright (c) 2016 The WebM project authors. All Rights Reserved.
3*
4*  Use of this source code is governed by a BSD-style license
5*  that can be found in the LICENSE file in the root of the source
6*  tree. An additional intellectual property rights grant can be found
7*  in the file PATENTS.  All contributing project authors may
8*  be found in the AUTHORS file in the root of the source tree.
9*/
10
11#ifndef VPX_DSP_PSNR_H_
12#define VPX_DSP_PSNR_H_
13
14#include "vpx_scale/yv12config.h"
15
16#define MAX_PSNR 100.0
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22typedef struct {
23  double psnr[4];       // total/y/u/v
24  uint64_t sse[4];      // total/y/u/v
25  uint32_t samples[4];  // total/y/u/v
26} PSNR_STATS;
27
28// TODO(dkovalev) change vpx_sse_to_psnr signature: double -> int64_t
29
30/*!\brief Converts SSE to PSNR
31*
32* Converts sum of squared errros (SSE) to peak signal-to-noise ratio (PNSR).
33*
34* \param[in]    samples       Number of samples
35* \param[in]    peak          Max sample value
36* \param[in]    sse           Sum of squared errors
37*/
38double vpx_sse_to_psnr(double samples, double peak, double sse);
39int64_t vpx_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
40#if CONFIG_VP9_HIGHBITDEPTH
41int64_t vpx_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a,
42                             const YV12_BUFFER_CONFIG *b);
43void vpx_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
44                          const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr,
45                          unsigned int bit_depth, unsigned int in_bit_depth);
46#endif
47void vpx_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
48                   PSNR_STATS *psnr);
49
50double vpx_psnrhvs(const YV12_BUFFER_CONFIG *source,
51                   const YV12_BUFFER_CONFIG *dest, double *phvs_y,
52                   double *phvs_u, double *phvs_v, uint32_t bd, uint32_t in_bd);
53
54#ifdef __cplusplus
55}  // extern "C"
56#endif
57#endif  // VPX_DSP_PSNR_H_
58