blob: d4d6b0d8a93d3a9f51884f3d73e5823b71e9c12e [file] [log] [blame]
Dmitry Kovalev129cb232014-04-08 16:08:39 -07001/*
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
Alex Conversec65e79d2015-08-06 13:46:28 -070011#ifndef VPX_DSP_SSIM_H_
12#define VPX_DSP_SSIM_H_
Dmitry Kovalev129cb232014-04-08 16:08:39 -070013
Yaowu Xuefe1b1d2016-02-04 14:03:48 -080014#define MAX_SSIM_DB 100.0;
15
Dmitry Kovalev129cb232014-04-08 16:08:39 -070016#ifdef __cplusplus
17extern "C" {
18#endif
19
Alex Conversec7b70112015-08-06 12:53:59 -070020#include "./vpx_config.h"
Dmitry Kovalev129cb232014-04-08 16:08:39 -070021#include "vpx_scale/yv12config.h"
22
Jim Bankoskiee87e202015-04-21 10:05:37 -070023// metrics used for calculating ssim, ssim2, dssim, and ssimc
24typedef struct {
25 // source sum ( over 8x8 region )
Alex Conversec65e79d2015-08-06 13:46:28 -070026 uint32_t sum_s;
Jim Bankoskiee87e202015-04-21 10:05:37 -070027
28 // reference sum (over 8x8 region )
Alex Conversec65e79d2015-08-06 13:46:28 -070029 uint32_t sum_r;
Jim Bankoskiee87e202015-04-21 10:05:37 -070030
31 // source sum squared ( over 8x8 region )
Alex Conversec65e79d2015-08-06 13:46:28 -070032 uint32_t sum_sq_s;
Jim Bankoskiee87e202015-04-21 10:05:37 -070033
34 // reference sum squared (over 8x8 region )
Alex Conversec65e79d2015-08-06 13:46:28 -070035 uint32_t sum_sq_r;
Jim Bankoskiee87e202015-04-21 10:05:37 -070036
37 // sum of source times reference (over 8x8 region)
Alex Conversec65e79d2015-08-06 13:46:28 -070038 uint32_t sum_sxr;
Jim Bankoskiee87e202015-04-21 10:05:37 -070039
40 // calculated ssim score between source and reference
41 double ssim;
42} Ssimv;
43
44// metrics collected on a frame basis
45typedef struct {
46 // ssim consistency error metric ( see code for explanation )
47 double ssimc;
48
49 // standard ssim
50 double ssim;
51
52 // revised ssim ( see code for explanation)
53 double ssim2;
54
55 // ssim restated as an error metric like sse
56 double dssim;
57
58 // dssim converted to decibels
59 double dssimd;
60
61 // ssimc converted to decibels
62 double ssimcd;
63} Metrics;
64
Alex Conversec7b70112015-08-06 12:53:59 -070065double vpx_get_ssim_metrics(uint8_t *img1, int img1_pitch, uint8_t *img2,
Jim Bankoskiee87e202015-04-21 10:05:37 -070066 int img2_pitch, int width, int height, Ssimv *sv2,
67 Metrics *m, int do_inconsistency);
68
Alex Converse26f4f2d2015-08-07 10:48:32 -070069double vpx_calc_ssim(const YV12_BUFFER_CONFIG *source,
70 const YV12_BUFFER_CONFIG *dest,
Jim Bankoski3c463ab2014-08-22 12:25:07 -070071 double *weight);
Dmitry Kovalev129cb232014-04-08 16:08:39 -070072
Alex Converse4ea7f2b2015-08-07 12:02:49 -070073double vpx_calc_fastssim(const YV12_BUFFER_CONFIG *source,
74 const YV12_BUFFER_CONFIG *dest,
Yaowu Xuc0874f22016-02-05 11:30:12 -080075 double *ssim_y, double *ssim_u,
Yaowu Xud1c5cd42016-02-22 12:58:38 -080076 double *ssim_v, uint32_t bd, uint32_t in_bd);
Jim Bankoski3f7f1942015-04-17 10:23:24 -070077
Deb Mukherjee41093722014-09-19 16:51:59 -070078#if CONFIG_VP9_HIGHBITDEPTH
Alex Converse26f4f2d2015-08-07 10:48:32 -070079double vpx_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source,
80 const YV12_BUFFER_CONFIG *dest,
Deb Mukherjee41093722014-09-19 16:51:59 -070081 double *weight,
Yaowu Xueeaf8e62016-02-22 16:05:19 -080082 uint32_t bd, uint32_t in_bd);
Deb Mukherjee41093722014-09-19 16:51:59 -070083#endif // CONFIG_VP9_HIGHBITDEPTH
84
Dmitry Kovalev129cb232014-04-08 16:08:39 -070085#ifdef __cplusplus
86} // extern "C"
87#endif
88
Alex Conversec65e79d2015-08-06 13:46:28 -070089#endif // VPX_DSP_SSIM_H_