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 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 12 | #ifndef AOM_DSP_PSNR_H_ |
| 13 | #define 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 { |
| 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 Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 29 | /*!\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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 37 | double aom_sse_to_psnr(double samples, double peak, double sse); |
Debargha Mukherjee | 5cd2ab9 | 2016-09-08 15:15:17 -0700 | [diff] [blame] | 38 | int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a, |
clang-format | bda8d61 | 2016-09-19 15:55:46 -0700 | [diff] [blame] | 39 | const YV12_BUFFER_CONFIG *b, int hstart, int width, |
| 40 | int vstart, int height); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 41 | 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] | 42 | int64_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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 45 | 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] | 46 | int64_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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 49 | int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); |
| 50 | #if CONFIG_AOM_HIGHBITDEPTH |
Debargha Mukherjee | 5cd2ab9 | 2016-09-08 15:15:17 -0700 | [diff] [blame] | 51 | 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] | 52 | const YV12_BUFFER_CONFIG *b, int hstart, |
| 53 | int width, int vstart, int height); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 54 | int64_t aom_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 55 | const YV12_BUFFER_CONFIG *b); |
Debargha Mukherjee | 874d36d | 2016-12-14 16:53:17 -0800 | [diff] [blame] | 56 | int64_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 Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 59 | int64_t aom_highbd_get_u_sse(const YV12_BUFFER_CONFIG *a, |
| 60 | const YV12_BUFFER_CONFIG *b); |
Debargha Mukherjee | 874d36d | 2016-12-14 16:53:17 -0800 | [diff] [blame] | 61 | int64_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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 64 | int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 65 | const YV12_BUFFER_CONFIG *b); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 66 | void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 67 | const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr, |
| 68 | unsigned int bit_depth, unsigned int in_bit_depth); |
| 69 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 70 | 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] | 71 | PSNR_STATS *psnr); |
| 72 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 73 | double aom_psnrhvs(const YV12_BUFFER_CONFIG *source, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 74 | const YV12_BUFFER_CONFIG *dest, double *phvs_y, |
| 75 | 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] | 76 | #ifdef __cplusplus |
| 77 | } // extern "C" |
| 78 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 79 | #endif // AOM_DSP_PSNR_H_ |