ssim.h 2.93 KB
Newer Older
Dmitry Kovalev's avatar
Dmitry Kovalev committed
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Dmitry Kovalev's avatar
Dmitry Kovalev committed
3
 *
4 5 6 7 8 9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Dmitry Kovalev's avatar
Dmitry Kovalev committed
10 11
 */

12 13
#ifndef VPX_DSP_SSIM_H_
#define VPX_DSP_SSIM_H_
Dmitry Kovalev's avatar
Dmitry Kovalev committed
14 15 16 17 18

#ifdef __cplusplus
extern "C" {
#endif

Adrian Grange's avatar
Adrian Grange committed
19
#include "./aom_config.h"
Yaowu Xu's avatar
Yaowu Xu committed
20
#include "aom_scale/yv12config.h"
Dmitry Kovalev's avatar
Dmitry Kovalev committed
21

22 23 24
// metrics used for calculating ssim, ssim2, dssim, and ssimc
typedef struct {
  // source sum ( over 8x8 region )
25
  uint32_t sum_s;
26 27

  // reference sum (over 8x8 region )
28
  uint32_t sum_r;
29 30

  // source sum squared ( over 8x8 region )
31
  uint32_t sum_sq_s;
32 33

  // reference sum squared (over 8x8 region )
34
  uint32_t sum_sq_r;
35 36

  // sum of source times reference (over 8x8 region)
37
  uint32_t sum_sxr;
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

  // calculated ssim score between source and reference
  double ssim;
} Ssimv;

// metrics collected on a frame basis
typedef struct {
  // ssim consistency error metric ( see code for explanation )
  double ssimc;

  // standard ssim
  double ssim;

  // revised ssim ( see code for explanation)
  double ssim2;

  // ssim restated as an error metric like sse
  double dssim;

  // dssim converted to decibels
  double dssimd;

  // ssimc converted to decibels
  double ssimcd;
} Metrics;

Adrian Grange's avatar
Adrian Grange committed
64
double aom_get_ssim_metrics(uint8_t *img1, int img1_pitch, uint8_t *img2,
clang-format's avatar
clang-format committed
65 66
                            int img2_pitch, int width, int height, Ssimv *sv2,
                            Metrics *m, int do_inconsistency);
67

Adrian Grange's avatar
Adrian Grange committed
68
double aom_calc_ssim(const YV12_BUFFER_CONFIG *source,
clang-format's avatar
clang-format committed
69
                     const YV12_BUFFER_CONFIG *dest, double *weight);
Dmitry Kovalev's avatar
Dmitry Kovalev committed
70

Adrian Grange's avatar
Adrian Grange committed
71
double aom_calc_ssimg(const YV12_BUFFER_CONFIG *source,
clang-format's avatar
clang-format committed
72 73
                      const YV12_BUFFER_CONFIG *dest, double *ssim_y,
                      double *ssim_u, double *ssim_v);
Dmitry Kovalev's avatar
Dmitry Kovalev committed
74

Adrian Grange's avatar
Adrian Grange committed
75
double aom_calc_fastssim(const YV12_BUFFER_CONFIG *source,
clang-format's avatar
clang-format committed
76 77
                         const YV12_BUFFER_CONFIG *dest, double *ssim_y,
                         double *ssim_u, double *ssim_v);
78

Adrian Grange's avatar
Adrian Grange committed
79
double aom_psnrhvs(const YV12_BUFFER_CONFIG *source,
clang-format's avatar
clang-format committed
80 81
                   const YV12_BUFFER_CONFIG *dest, double *ssim_y,
                   double *ssim_u, double *ssim_v);
Jim Bankoski's avatar
Jim Bankoski committed
82

83
#if CONFIG_AOM_HIGHBITDEPTH
Adrian Grange's avatar
Adrian Grange committed
84
double aom_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source,
clang-format's avatar
clang-format committed
85
                            const YV12_BUFFER_CONFIG *dest, double *weight,
Deb Mukherjee's avatar
Deb Mukherjee committed
86
                            unsigned int bd);
87

Adrian Grange's avatar
Adrian Grange committed
88
double aom_highbd_calc_ssimg(const YV12_BUFFER_CONFIG *source,
clang-format's avatar
clang-format committed
89 90
                             const YV12_BUFFER_CONFIG *dest, double *ssim_y,
                             double *ssim_u, double *ssim_v, unsigned int bd);
91
#endif  // CONFIG_AOM_HIGHBITDEPTH
92

Dmitry Kovalev's avatar
Dmitry Kovalev committed
93 94 95 96
#ifdef __cplusplus
}  // extern "C"
#endif

97
#endif  // VPX_DSP_SSIM_H_