xref: /aosp_15_r20/external/libaom/aom_dsp/psnr.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *
4*77c1e3ccSAndroid Build Coastguard Worker  * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker  * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker  * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AOM_DSP_PSNR_H_
13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AOM_DSP_PSNR_H_
14*77c1e3ccSAndroid Build Coastguard Worker 
15*77c1e3ccSAndroid Build Coastguard Worker #include "aom_scale/yv12config.h"
16*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
17*77c1e3ccSAndroid Build Coastguard Worker 
18*77c1e3ccSAndroid Build Coastguard Worker #define MAX_PSNR 100.0
19*77c1e3ccSAndroid Build Coastguard Worker 
20*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
21*77c1e3ccSAndroid Build Coastguard Worker extern "C" {
22*77c1e3ccSAndroid Build Coastguard Worker #endif
23*77c1e3ccSAndroid Build Coastguard Worker 
24*77c1e3ccSAndroid Build Coastguard Worker typedef struct {
25*77c1e3ccSAndroid Build Coastguard Worker   double psnr[4];           // total/y/u/v
26*77c1e3ccSAndroid Build Coastguard Worker   uint64_t sse[4];          // total/y/u/v
27*77c1e3ccSAndroid Build Coastguard Worker   uint32_t samples[4];      // total/y/u/v
28*77c1e3ccSAndroid Build Coastguard Worker   double psnr_hbd[4];       // total/y/u/v when input-bit-depth < bit-depth
29*77c1e3ccSAndroid Build Coastguard Worker   uint64_t sse_hbd[4];      // total/y/u/v when input-bit-depth < bit-depth
30*77c1e3ccSAndroid Build Coastguard Worker   uint32_t samples_hbd[4];  // total/y/u/v when input-bit-depth < bit-depth
31*77c1e3ccSAndroid Build Coastguard Worker } PSNR_STATS;
32*77c1e3ccSAndroid Build Coastguard Worker 
33*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_INTERNAL_STATS
34*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Converts SSE to PSNR
35*77c1e3ccSAndroid Build Coastguard Worker  *
36*77c1e3ccSAndroid Build Coastguard Worker  * Converts sum of squared errros (SSE) to peak signal-to-noise ratio (PSNR).
37*77c1e3ccSAndroid Build Coastguard Worker  *
38*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    samples       Number of samples
39*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    peak          Max sample value
40*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    sse           Sum of squared errors
41*77c1e3ccSAndroid Build Coastguard Worker  */
42*77c1e3ccSAndroid Build Coastguard Worker double aom_sse_to_psnr(double samples, double peak, double sse);
43*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_INTERNAL_STATS
44*77c1e3ccSAndroid Build Coastguard Worker uint64_t aom_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
45*77c1e3ccSAndroid Build Coastguard Worker                        int vstart, int height);
46*77c1e3ccSAndroid Build Coastguard Worker uint64_t aom_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
47*77c1e3ccSAndroid Build Coastguard Worker                        int vstart, int height);
48*77c1e3ccSAndroid Build Coastguard Worker uint64_t aom_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
49*77c1e3ccSAndroid Build Coastguard Worker                        int vstart, int height);
50*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
51*77c1e3ccSAndroid Build Coastguard Worker                            const YV12_BUFFER_CONFIG *b, int hstart, int width,
52*77c1e3ccSAndroid Build Coastguard Worker                            int vstart, int height);
53*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
54*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_get_u_sse_part(const YV12_BUFFER_CONFIG *a,
55*77c1e3ccSAndroid Build Coastguard Worker                            const YV12_BUFFER_CONFIG *b, int hstart, int width,
56*77c1e3ccSAndroid Build Coastguard Worker                            int vstart, int height);
57*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_get_u_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
58*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
59*77c1e3ccSAndroid Build Coastguard Worker                            const YV12_BUFFER_CONFIG *b, int hstart, int width,
60*77c1e3ccSAndroid Build Coastguard Worker                            int vstart, int height);
61*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
62*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
63*77c1e3ccSAndroid Build Coastguard Worker                           const YV12_BUFFER_CONFIG *b, int plane, int highbd);
64*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
65*77c1e3ccSAndroid Build Coastguard Worker uint64_t aom_highbd_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart,
66*77c1e3ccSAndroid Build Coastguard Worker                               int width, int vstart, int height);
67*77c1e3ccSAndroid Build Coastguard Worker uint64_t aom_highbd_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart,
68*77c1e3ccSAndroid Build Coastguard Worker                               int width, int vstart, int height);
69*77c1e3ccSAndroid Build Coastguard Worker uint64_t aom_highbd_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart,
70*77c1e3ccSAndroid Build Coastguard Worker                               int width, int vstart, int height);
71*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
72*77c1e3ccSAndroid Build Coastguard Worker                                   const YV12_BUFFER_CONFIG *b, int hstart,
73*77c1e3ccSAndroid Build Coastguard Worker                                   int width, int vstart, int height);
74*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a,
75*77c1e3ccSAndroid Build Coastguard Worker                              const YV12_BUFFER_CONFIG *b);
76*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_highbd_get_u_sse_part(const YV12_BUFFER_CONFIG *a,
77*77c1e3ccSAndroid Build Coastguard Worker                                   const YV12_BUFFER_CONFIG *b, int hstart,
78*77c1e3ccSAndroid Build Coastguard Worker                                   int width, int vstart, int height);
79*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_highbd_get_u_sse(const YV12_BUFFER_CONFIG *a,
80*77c1e3ccSAndroid Build Coastguard Worker                              const YV12_BUFFER_CONFIG *b);
81*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_highbd_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
82*77c1e3ccSAndroid Build Coastguard Worker                                   const YV12_BUFFER_CONFIG *b, int hstart,
83*77c1e3ccSAndroid Build Coastguard Worker                                   int width, int vstart, int height);
84*77c1e3ccSAndroid Build Coastguard Worker int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a,
85*77c1e3ccSAndroid Build Coastguard Worker                              const YV12_BUFFER_CONFIG *b);
86*77c1e3ccSAndroid Build Coastguard Worker void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
87*77c1e3ccSAndroid Build Coastguard Worker                           const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr,
88*77c1e3ccSAndroid Build Coastguard Worker                           unsigned int bit_depth, unsigned int in_bit_depth);
89*77c1e3ccSAndroid Build Coastguard Worker #endif
90*77c1e3ccSAndroid Build Coastguard Worker void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
91*77c1e3ccSAndroid Build Coastguard Worker                    PSNR_STATS *psnr);
92*77c1e3ccSAndroid Build Coastguard Worker 
93*77c1e3ccSAndroid Build Coastguard Worker double aom_psnrhvs(const YV12_BUFFER_CONFIG *source,
94*77c1e3ccSAndroid Build Coastguard Worker                    const YV12_BUFFER_CONFIG *dest, double *phvs_y,
95*77c1e3ccSAndroid Build Coastguard Worker                    double *phvs_u, double *phvs_v, uint32_t bd, uint32_t in_bd);
96*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
97*77c1e3ccSAndroid Build Coastguard Worker }  // extern "C"
98*77c1e3ccSAndroid Build Coastguard Worker #endif
99*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_AOM_DSP_PSNR_H_
100