1 /* 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 */ 11 12 #ifndef AOM_AOM_DSP_PSNR_H_ 13 #define AOM_AOM_DSP_PSNR_H_ 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 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 30 } PSNR_STATS; 31 32 /*!\brief Converts SSE to PSNR 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 */ 40 double aom_sse_to_psnr(double samples, double peak, double sse); 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); 47 int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a, 48 const YV12_BUFFER_CONFIG *b, int hstart, int width, 49 int vstart, int height); 50 int64_t aom_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); 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); 54 int64_t aom_get_u_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); 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); 58 int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); 59 int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a, 60 const YV12_BUFFER_CONFIG *b, int plane, int highbd); 61 #if CONFIG_AV1_HIGHBITDEPTH 62 uint64_t aom_highbd_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart, 63 int width, int vstart, int height); 64 uint64_t aom_highbd_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart, 65 int width, int vstart, int height); 66 uint64_t aom_highbd_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart, 67 int width, int vstart, int height); 68 int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a, 69 const YV12_BUFFER_CONFIG *b, int hstart, 70 int width, int vstart, int height); 71 int64_t aom_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a, 72 const YV12_BUFFER_CONFIG *b); 73 int64_t aom_highbd_get_u_sse_part(const YV12_BUFFER_CONFIG *a, 74 const YV12_BUFFER_CONFIG *b, int hstart, 75 int width, int vstart, int height); 76 int64_t aom_highbd_get_u_sse(const YV12_BUFFER_CONFIG *a, 77 const YV12_BUFFER_CONFIG *b); 78 int64_t aom_highbd_get_v_sse_part(const YV12_BUFFER_CONFIG *a, 79 const YV12_BUFFER_CONFIG *b, int hstart, 80 int width, int vstart, int height); 81 int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a, 82 const YV12_BUFFER_CONFIG *b); 83 void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a, 84 const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr, 85 unsigned int bit_depth, unsigned int in_bit_depth); 86 #endif 87 void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b, 88 PSNR_STATS *psnr); 89 90 double aom_psnrhvs(const YV12_BUFFER_CONFIG *source, 91 const YV12_BUFFER_CONFIG *dest, double *phvs_y, 92 double *phvs_u, double *phvs_v, uint32_t bd, uint32_t in_bd); 93 #ifdef __cplusplus 94 } // extern "C" 95 #endif 96 #endif // AOM_AOM_DSP_PSNR_H_ 97