Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * 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 Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 11 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_AOM_DSP_PSNR_H_ |
| 13 | #define AOM_AOM_DSP_PSNR_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
| 15 | #include "aom_scale/yv12config.h" |
| 16 | |
| 17 | #define MAX_PSNR 100.0 |
| 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | typedef struct { |
Urvang Joshi | 9ee9eb7 | 2024-01-05 21:57:25 +0000 | [diff] [blame^] | 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 | 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 Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 30 | } PSNR_STATS; |
| 31 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 32 | /*!\brief Converts SSE to PSNR |
Johann | 123e8a6 | 2017-12-28 14:40:49 -0800 | [diff] [blame] | 33 | * |
| 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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 40 | double aom_sse_to_psnr(double samples, double peak, double sse); |
Nithya V S | 512ee2c | 2020-01-07 12:05:26 +0530 | [diff] [blame] | 41 | uint64_t aom_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart, int width, |
| 42 | int vstart, int height); |
| 43 | uint64_t aom_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart, int width, |
| 44 | int vstart, int height); |
| 45 | uint64_t aom_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart, int width, |
| 46 | int vstart, int height); |
Debargha Mukherjee | 5cd2ab9 | 2016-09-08 15:15:17 -0700 | [diff] [blame] | 47 | int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a, |
clang-format | bda8d61 | 2016-09-19 15:55:46 -0700 | [diff] [blame] | 48 | const YV12_BUFFER_CONFIG *b, int hstart, int width, |
| 49 | int vstart, int height); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 50 | int64_t aom_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); |
Debargha Mukherjee | 874d36d | 2016-12-14 16:53:17 -0800 | [diff] [blame] | 51 | int64_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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 54 | int64_t aom_get_u_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); |
Debargha Mukherjee | 874d36d | 2016-12-14 16:53:17 -0800 | [diff] [blame] | 55 | int64_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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 58 | int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); |
Cheng Chen | 9efbaf9 | 2017-07-27 14:09:59 -0700 | [diff] [blame] | 59 | int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a, |
| 60 | const YV12_BUFFER_CONFIG *b, int plane, int highbd); |
Nithya V S | 512ee2c | 2020-01-07 12:05:26 +0530 | [diff] [blame] | 61 | uint64_t aom_highbd_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart, |
| 62 | int width, int vstart, int height); |
| 63 | uint64_t aom_highbd_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart, |
| 64 | int width, int vstart, int height); |
| 65 | uint64_t aom_highbd_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart, |
| 66 | int width, int vstart, int height); |
Debargha Mukherjee | 5cd2ab9 | 2016-09-08 15:15:17 -0700 | [diff] [blame] | 67 | int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a, |
clang-format | bda8d61 | 2016-09-19 15:55:46 -0700 | [diff] [blame] | 68 | const YV12_BUFFER_CONFIG *b, int hstart, |
| 69 | int width, int vstart, int height); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 70 | int64_t aom_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 71 | const YV12_BUFFER_CONFIG *b); |
Debargha Mukherjee | 874d36d | 2016-12-14 16:53:17 -0800 | [diff] [blame] | 72 | int64_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 Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 75 | int64_t aom_highbd_get_u_sse(const YV12_BUFFER_CONFIG *a, |
| 76 | const YV12_BUFFER_CONFIG *b); |
Debargha Mukherjee | 874d36d | 2016-12-14 16:53:17 -0800 | [diff] [blame] | 77 | int64_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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 80 | int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 81 | const YV12_BUFFER_CONFIG *b); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 82 | void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 83 | const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr, |
| 84 | unsigned int bit_depth, unsigned int in_bit_depth); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 85 | void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 86 | PSNR_STATS *psnr); |
| 87 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 88 | double aom_psnrhvs(const YV12_BUFFER_CONFIG *source, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 89 | const YV12_BUFFER_CONFIG *dest, double *phvs_y, |
| 90 | double *phvs_u, double *phvs_v, uint32_t bd, uint32_t in_bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 91 | #ifdef __cplusplus |
| 92 | } // extern "C" |
| 93 | #endif |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 94 | #endif // AOM_AOM_DSP_PSNR_H_ |