blob: 77750ea7e1c89120a7eafe4632ea2b373ba54b74 [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
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_AOM_DSP_PSNR_H_
13#define AOM_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 {
Urvang Joshi9ee9eb72024-01-05 21:57:25 +000024 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 double psnr_hbd[4]; // total/y/u/v when input-bit-depth < bit-depth
28 uint64_t sse_hbd[4]; // total/y/u/v when input-bit-depth < bit-depth
29 uint32_t samples_hbd[4]; // total/y/u/v when input-bit-depth < bit-depth
Yaowu Xuc27fc142016-08-22 16:08:15 -070030} PSNR_STATS;
31
Yaowu Xuc27fc142016-08-22 16:08:15 -070032/*!\brief Converts SSE to PSNR
Johann123e8a62017-12-28 14:40:49 -080033 *
34 * Converts sum of squared errros (SSE) to peak signal-to-noise ratio (PNSR).
35 *
36 * \param[in] samples Number of samples
37 * \param[in] peak Max sample value
38 * \param[in] sse Sum of squared errors
39 */
Yaowu Xuf883b422016-08-30 14:01:10 -070040double aom_sse_to_psnr(double samples, double peak, double sse);
Nithya V S512ee2c2020-01-07 12:05:26 +053041uint64_t aom_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
42 int vstart, int height);
43uint64_t aom_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
44 int vstart, int height);
45uint64_t aom_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
46 int vstart, int height);
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -070047int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
clang-formatbda8d612016-09-19 15:55:46 -070048 const YV12_BUFFER_CONFIG *b, int hstart, int width,
49 int vstart, int height);
Yaowu Xuf883b422016-08-30 14:01:10 -070050int64_t aom_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
Debargha Mukherjee874d36d2016-12-14 16:53:17 -080051int64_t aom_get_u_sse_part(const YV12_BUFFER_CONFIG *a,
52 const YV12_BUFFER_CONFIG *b, int hstart, int width,
53 int vstart, int height);
Yaowu Xuf883b422016-08-30 14:01:10 -070054int64_t aom_get_u_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
Debargha Mukherjee874d36d2016-12-14 16:53:17 -080055int64_t aom_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
56 const YV12_BUFFER_CONFIG *b, int hstart, int width,
57 int vstart, int height);
Yaowu Xuf883b422016-08-30 14:01:10 -070058int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
Cheng Chen9efbaf92017-07-27 14:09:59 -070059int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
60 const YV12_BUFFER_CONFIG *b, int plane, int highbd);
Nithya V S512ee2c2020-01-07 12:05:26 +053061uint64_t aom_highbd_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart,
62 int width, int vstart, int height);
63uint64_t aom_highbd_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart,
64 int width, int vstart, int height);
65uint64_t aom_highbd_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart,
66 int width, int vstart, int height);
Debargha Mukherjee5cd2ab92016-09-08 15:15:17 -070067int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
clang-formatbda8d612016-09-19 15:55:46 -070068 const YV12_BUFFER_CONFIG *b, int hstart,
69 int width, int vstart, int height);
Yaowu Xuf883b422016-08-30 14:01:10 -070070int64_t aom_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a,
Yaowu Xuc27fc142016-08-22 16:08:15 -070071 const YV12_BUFFER_CONFIG *b);
Debargha Mukherjee874d36d2016-12-14 16:53:17 -080072int64_t aom_highbd_get_u_sse_part(const YV12_BUFFER_CONFIG *a,
73 const YV12_BUFFER_CONFIG *b, int hstart,
74 int width, int vstart, int height);
Yaowu Xu9c01aa12016-09-01 14:32:49 -070075int64_t aom_highbd_get_u_sse(const YV12_BUFFER_CONFIG *a,
76 const YV12_BUFFER_CONFIG *b);
Debargha Mukherjee874d36d2016-12-14 16:53:17 -080077int64_t aom_highbd_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
78 const YV12_BUFFER_CONFIG *b, int hstart,
79 int width, int vstart, int height);
Yaowu Xuf883b422016-08-30 14:01:10 -070080int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a,
Yaowu Xuc27fc142016-08-22 16:08:15 -070081 const YV12_BUFFER_CONFIG *b);
Yaowu Xuf883b422016-08-30 14:01:10 -070082void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
Yaowu Xuc27fc142016-08-22 16:08:15 -070083 const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr,
84 unsigned int bit_depth, unsigned int in_bit_depth);
Yaowu Xuf883b422016-08-30 14:01:10 -070085void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
Yaowu Xuc27fc142016-08-22 16:08:15 -070086 PSNR_STATS *psnr);
87
Yaowu Xuf883b422016-08-30 14:01:10 -070088double aom_psnrhvs(const YV12_BUFFER_CONFIG *source,
Yaowu Xuc27fc142016-08-22 16:08:15 -070089 const YV12_BUFFER_CONFIG *dest, double *phvs_y,
90 double *phvs_u, double *phvs_v, uint32_t bd, uint32_t in_bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -070091#ifdef __cplusplus
92} // extern "C"
93#endif
James Zerne1cbb132018-08-22 14:10:36 -070094#endif // AOM_AOM_DSP_PSNR_H_