blob: 71432fe09d34d16be193d91a7af4f5164d5d5fb0 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
Yaowu Xuc27fc142016-08-22 16:08:15 -070011
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AOM_DSP_PSNR_H_
13#define AOM_DSP_PSNR_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
15#include "aom_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
Yaowu Xuc27fc142016-08-22 16:08:15 -070029/*!\brief Converts SSE to PSNR
30*
31* Converts sum of squared errros (SSE) to peak signal-to-noise ratio (PNSR).
32*
33* \param[in] samples Number of samples
34* \param[in] peak Max sample value
35* \param[in] sse Sum of squared errors
36*/
Yaowu Xuf883b422016-08-30 14:01:10 -070037double aom_sse_to_psnr(double samples, double peak, double sse);
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -070038int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
clang-formatbda8d612016-09-19 15:55:46 -070039 const YV12_BUFFER_CONFIG *b, int hstart, int width,
40 int vstart, int height);
Yaowu Xuf883b422016-08-30 14:01:10 -070041int64_t aom_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
Debargha Mukherjee874d36d2016-12-14 16:53:17 -080042int64_t aom_get_u_sse_part(const YV12_BUFFER_CONFIG *a,
43 const YV12_BUFFER_CONFIG *b, int hstart, int width,
44 int vstart, int height);
Yaowu Xuf883b422016-08-30 14:01:10 -070045int64_t aom_get_u_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
Debargha Mukherjee874d36d2016-12-14 16:53:17 -080046int64_t aom_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
47 const YV12_BUFFER_CONFIG *b, int hstart, int width,
48 int vstart, int height);
Yaowu Xuf883b422016-08-30 14:01:10 -070049int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
50#if CONFIG_AOM_HIGHBITDEPTH
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -070051int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
clang-formatbda8d612016-09-19 15:55:46 -070052 const YV12_BUFFER_CONFIG *b, int hstart,
53 int width, int vstart, int height);
Yaowu Xuf883b422016-08-30 14:01:10 -070054int64_t aom_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a,
Yaowu Xuc27fc142016-08-22 16:08:15 -070055 const YV12_BUFFER_CONFIG *b);
Debargha Mukherjee874d36d2016-12-14 16:53:17 -080056int64_t aom_highbd_get_u_sse_part(const YV12_BUFFER_CONFIG *a,
57 const YV12_BUFFER_CONFIG *b, int hstart,
58 int width, int vstart, int height);
Yaowu Xu9c01aa12016-09-01 14:32:49 -070059int64_t aom_highbd_get_u_sse(const YV12_BUFFER_CONFIG *a,
60 const YV12_BUFFER_CONFIG *b);
Debargha Mukherjee874d36d2016-12-14 16:53:17 -080061int64_t aom_highbd_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
62 const YV12_BUFFER_CONFIG *b, int hstart,
63 int width, int vstart, int height);
Yaowu Xuf883b422016-08-30 14:01:10 -070064int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a,
Yaowu Xuc27fc142016-08-22 16:08:15 -070065 const YV12_BUFFER_CONFIG *b);
Yaowu Xuf883b422016-08-30 14:01:10 -070066void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
Yaowu Xuc27fc142016-08-22 16:08:15 -070067 const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr,
68 unsigned int bit_depth, unsigned int in_bit_depth);
69#endif
Yaowu Xuf883b422016-08-30 14:01:10 -070070void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
Yaowu Xuc27fc142016-08-22 16:08:15 -070071 PSNR_STATS *psnr);
72
Yaowu Xuf883b422016-08-30 14:01:10 -070073double aom_psnrhvs(const YV12_BUFFER_CONFIG *source,
Yaowu Xuc27fc142016-08-22 16:08:15 -070074 const YV12_BUFFER_CONFIG *dest, double *phvs_y,
75 double *phvs_u, double *phvs_v, uint32_t bd, uint32_t in_bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -070076#ifdef __cplusplus
77} // extern "C"
78#endif
Yaowu Xuf883b422016-08-30 14:01:10 -070079#endif // AOM_DSP_PSNR_H_