Yaowu Xu | 7538501 | 2016-02-17 08:42:56 -0800 | [diff] [blame] | 1 | /* |
| 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 |
| 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 | |
| 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 | */ |
| 39 | double vpx_sse_to_psnr(double samples, double peak, double sse); |
| 40 | int64_t vpx_get_y_sse(const YV12_BUFFER_CONFIG *a, |
| 41 | const YV12_BUFFER_CONFIG *b); |
| 42 | #if CONFIG_VP9_HIGHBITDEPTH |
| 43 | int64_t vpx_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a, |
| 44 | const YV12_BUFFER_CONFIG *b); |
Yaowu Xu | 38cfc45 | 2016-02-22 15:24:25 -0800 | [diff] [blame] | 45 | void vpx_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a, |
Yaowu Xu | 7538501 | 2016-02-17 08:42:56 -0800 | [diff] [blame] | 46 | const YV12_BUFFER_CONFIG *b, |
| 47 | PSNR_STATS *psnr, |
| 48 | unsigned int bit_depth, |
| 49 | unsigned int in_bit_depth); |
Yaowu Xu | 9fb593d | 2016-02-17 12:38:54 -0800 | [diff] [blame] | 50 | #endif |
Yaowu Xu | 38cfc45 | 2016-02-22 15:24:25 -0800 | [diff] [blame] | 51 | void vpx_calc_psnr(const YV12_BUFFER_CONFIG *a, |
Yaowu Xu | 7538501 | 2016-02-17 08:42:56 -0800 | [diff] [blame] | 52 | const YV12_BUFFER_CONFIG *b, |
| 53 | PSNR_STATS *psnr); |
Yaowu Xu | 9fb593d | 2016-02-17 12:38:54 -0800 | [diff] [blame] | 54 | |
Yaowu Xu | 6e695da | 2016-02-21 18:49:01 -0800 | [diff] [blame] | 55 | double 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 Xu | 7538501 | 2016-02-17 08:42:56 -0800 | [diff] [blame] | 60 | #ifdef __cplusplus |
| 61 | } // extern "C" |
| 62 | #endif |
| 63 | #endif // VPX_DSP_PSNR_H_ |