]> granicus.if.org Git - libvpx/blob - vpx_dsp/ssim.h
psnrhvs: Add missing consts and static consts.
[libvpx] / vpx_dsp / ssim.h
1 /*
2  *  Copyright (c) 2014 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_SSIM_H_
12 #define VPX_DSP_SSIM_H_
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 #include "./vpx_config.h"
19 #include "vpx_scale/yv12config.h"
20
21 // TODO(aconverse): Unify vp8/vp9_clear_system_state
22 #if ARCH_X86 || ARCH_X86_64
23 void vpx_reset_mmx_state(void);
24 #define vpx_clear_system_state() vpx_reset_mmx_state()
25 #else
26 #define vpx_clear_system_state()
27 #endif
28
29 // metrics used for calculating ssim, ssim2, dssim, and ssimc
30 typedef struct {
31   // source sum ( over 8x8 region )
32   uint32_t sum_s;
33
34   // reference sum (over 8x8 region )
35   uint32_t sum_r;
36
37   // source sum squared ( over 8x8 region )
38   uint32_t sum_sq_s;
39
40   // reference sum squared (over 8x8 region )
41   uint32_t sum_sq_r;
42
43   // sum of source times reference (over 8x8 region)
44   uint32_t sum_sxr;
45
46   // calculated ssim score between source and reference
47   double ssim;
48 } Ssimv;
49
50 // metrics collected on a frame basis
51 typedef struct {
52   // ssim consistency error metric ( see code for explanation )
53   double ssimc;
54
55   // standard ssim
56   double ssim;
57
58   // revised ssim ( see code for explanation)
59   double ssim2;
60
61   // ssim restated as an error metric like sse
62   double dssim;
63
64   // dssim converted to decibels
65   double dssimd;
66
67   // ssimc converted to decibels
68   double ssimcd;
69 } Metrics;
70
71 double vpx_get_ssim_metrics(uint8_t *img1, int img1_pitch, uint8_t *img2,
72                       int img2_pitch, int width, int height, Ssimv *sv2,
73                       Metrics *m, int do_inconsistency);
74
75 double vpx_calc_ssim(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest,
76                      double *weight);
77
78 double vpx_calc_ssimg(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest,
79                       double *ssim_y, double *ssim_u, double *ssim_v);
80
81 double vpx_calc_fastssim(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest,
82                          double *ssim_y, double *ssim_u, double *ssim_v);
83
84 double vpx_psnrhvs(const YV12_BUFFER_CONFIG *source,
85                    const YV12_BUFFER_CONFIG *dest,
86                    double *ssim_y, double *ssim_u, double *ssim_v);
87
88 #if CONFIG_VP9_HIGHBITDEPTH
89 double vpx_highbd_calc_ssim(YV12_BUFFER_CONFIG *source,
90                             YV12_BUFFER_CONFIG *dest,
91                             double *weight,
92                             unsigned int bd);
93
94 double vpx_highbd_calc_ssimg(YV12_BUFFER_CONFIG *source,
95                              YV12_BUFFER_CONFIG *dest,
96                              double *ssim_y,
97                              double *ssim_u,
98                              double *ssim_v,
99                              unsigned int bd);
100 #endif  // CONFIG_VP9_HIGHBITDEPTH
101
102 #ifdef __cplusplus
103 }  // extern "C"
104 #endif
105
106 #endif  // VPX_DSP_SSIM_H_