• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
39                            const YV12_BUFFER_CONFIG *b, int hstart, int width,
40                            int vstart, int height);
41 int64_t aom_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
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);
45 int64_t aom_get_u_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
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);
49 int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
50 int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
51                           const YV12_BUFFER_CONFIG *b, int plane, int highbd);
52 int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
53                                   const YV12_BUFFER_CONFIG *b, int hstart,
54                                   int width, int vstart, int height);
55 int64_t aom_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a,
56                              const YV12_BUFFER_CONFIG *b);
57 int64_t aom_highbd_get_u_sse_part(const YV12_BUFFER_CONFIG *a,
58                                   const YV12_BUFFER_CONFIG *b, int hstart,
59                                   int width, int vstart, int height);
60 int64_t aom_highbd_get_u_sse(const YV12_BUFFER_CONFIG *a,
61                              const YV12_BUFFER_CONFIG *b);
62 int64_t aom_highbd_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
63                                   const YV12_BUFFER_CONFIG *b, int hstart,
64                                   int width, int vstart, int height);
65 int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a,
66                              const YV12_BUFFER_CONFIG *b);
67 void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
68                           const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr,
69                           unsigned int bit_depth, unsigned int in_bit_depth);
70 void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
71                    PSNR_STATS *psnr);
72 
73 double aom_psnrhvs(const YV12_BUFFER_CONFIG *source,
74                    const YV12_BUFFER_CONFIG *dest, double *phvs_y,
75                    double *phvs_u, double *phvs_v, uint32_t bd, uint32_t in_bd);
76 #ifdef __cplusplus
77 }  // extern "C"
78 #endif
79 #endif  // AOM_AOM_DSP_PSNR_H_
80