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 } PSNR_STATS; 28 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 */ 37 double aom_sse_to_psnr(double samples, double peak, double sse); 38 uint64_t aom_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart, int width, 39 int vstart, int height); 40 uint64_t aom_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart, int width, 41 int vstart, int height); 42 uint64_t aom_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart, int width, 43 int vstart, int height); 44 int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a, 45 const YV12_BUFFER_CONFIG *b, int hstart, int width, 46 int vstart, int height); 47 int64_t aom_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); 48 int64_t aom_get_u_sse_part(const YV12_BUFFER_CONFIG *a, 49 const YV12_BUFFER_CONFIG *b, int hstart, int width, 50 int vstart, int height); 51 int64_t aom_get_u_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); 52 int64_t aom_get_v_sse_part(const YV12_BUFFER_CONFIG *a, 53 const YV12_BUFFER_CONFIG *b, int hstart, int width, 54 int vstart, int height); 55 int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); 56 int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a, 57 const YV12_BUFFER_CONFIG *b, int plane, int highbd); 58 #if CONFIG_AV1_HIGHBITDEPTH 59 uint64_t aom_highbd_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart, 60 int width, int vstart, int height); 61 uint64_t aom_highbd_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart, 62 int width, int vstart, int height); 63 uint64_t aom_highbd_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart, 64 int width, int vstart, int height); 65 int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a, 66 const YV12_BUFFER_CONFIG *b, int hstart, 67 int width, int vstart, int height); 68 int64_t aom_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a, 69 const YV12_BUFFER_CONFIG *b); 70 int64_t aom_highbd_get_u_sse_part(const YV12_BUFFER_CONFIG *a, 71 const YV12_BUFFER_CONFIG *b, int hstart, 72 int width, int vstart, int height); 73 int64_t aom_highbd_get_u_sse(const YV12_BUFFER_CONFIG *a, 74 const YV12_BUFFER_CONFIG *b); 75 int64_t aom_highbd_get_v_sse_part(const YV12_BUFFER_CONFIG *a, 76 const YV12_BUFFER_CONFIG *b, int hstart, 77 int width, int vstart, int height); 78 int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a, 79 const YV12_BUFFER_CONFIG *b); 80 void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a, 81 const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr, 82 unsigned int bit_depth, unsigned int in_bit_depth); 83 #endif 84 void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b, 85 PSNR_STATS *psnr); 86 87 double aom_psnrhvs(const YV12_BUFFER_CONFIG *source, 88 const YV12_BUFFER_CONFIG *dest, double *phvs_y, 89 double *phvs_u, double *phvs_v, uint32_t bd, uint32_t in_bd); 90 #ifdef __cplusplus 91 } // extern "C" 92 #endif 93 #endif // AOM_AOM_DSP_PSNR_H_ 94