blob: e25b4504af84445dd3d2fb55ca35041c71f0deeb [file] [log] [blame]
Yaowu Xu75385012016-02-17 08:42:56 -08001/*
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
15#include "vpx_scale/yv12config.h"
16
17#define MAX_PSNR 100.0
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23typedef struct {
24 double psnr[4]; // total/y/u/v
25 uint64_t sse[4]; // total/y/u/v
26 uint32_t samples[4]; // total/y/u/v
27} PSNR_STATS;
28
29// TODO(dkovalev) change vpx_sse_to_psnr signature: double -> int64_t
30
31/*!\brief Converts SSE to PSNR
32*
33* Converts sum of squared errros (SSE) to peak signal-to-noise ratio (PNSR).
34*
35* \param[in] samples Number of samples
36* \param[in] peak Max sample value
37* \param[in] sse Sum of squared errors
38*/
39double vpx_sse_to_psnr(double samples, double peak, double sse);
40int64_t vpx_get_y_sse(const YV12_BUFFER_CONFIG *a,
41 const YV12_BUFFER_CONFIG *b);
42#if CONFIG_VP9_HIGHBITDEPTH
43int64_t vpx_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a,
44 const YV12_BUFFER_CONFIG *b);
Yaowu Xu38cfc452016-02-22 15:24:25 -080045void vpx_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
Yaowu Xu75385012016-02-17 08:42:56 -080046 const YV12_BUFFER_CONFIG *b,
47 PSNR_STATS *psnr,
48 unsigned int bit_depth,
49 unsigned int in_bit_depth);
Yaowu Xu9fb593d2016-02-17 12:38:54 -080050#endif
Yaowu Xu38cfc452016-02-22 15:24:25 -080051void vpx_calc_psnr(const YV12_BUFFER_CONFIG *a,
Yaowu Xu75385012016-02-17 08:42:56 -080052 const YV12_BUFFER_CONFIG *b,
53 PSNR_STATS *psnr);
Yaowu Xu9fb593d2016-02-17 12:38:54 -080054
Yaowu Xu6e695da2016-02-21 18:49:01 -080055double vpx_psnrhvs(const YV12_BUFFER_CONFIG *source,
56 const YV12_BUFFER_CONFIG *dest,
57 double *phvs_y, double *phvs_u,
58 double *phvs_v, uint32_t bd, uint32_t in_bd);
59
Yaowu Xu75385012016-02-17 08:42:56 -080060#ifdef __cplusplus
61} // extern "C"
62#endif
63#endif // VPX_DSP_PSNR_H_