blob: 3fd6c1e145510d798b98a480ed2bc333fa41ef4c [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * 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.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AOM_DSP_SSIM_H_
13#define AOM_DSP_SSIM_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
15#define MAX_SSIM_DB 100.0;
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
Yaowu Xuf883b422016-08-30 14:01:10 -070021#include "./aom_config.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070022#include "aom_scale/yv12config.h"
23
24// metrics used for calculating ssim, ssim2, dssim, and ssimc
25typedef struct {
26 // source sum ( over 8x8 region )
27 uint32_t sum_s;
28
29 // reference sum (over 8x8 region )
30 uint32_t sum_r;
31
32 // source sum squared ( over 8x8 region )
33 uint32_t sum_sq_s;
34
35 // reference sum squared (over 8x8 region )
36 uint32_t sum_sq_r;
37
38 // sum of source times reference (over 8x8 region)
39 uint32_t sum_sxr;
40
41 // calculated ssim score between source and reference
42 double ssim;
43} Ssimv;
44
45// metrics collected on a frame basis
46typedef struct {
47 // ssim consistency error metric ( see code for explanation )
48 double ssimc;
49
50 // standard ssim
51 double ssim;
52
53 // revised ssim ( see code for explanation)
54 double ssim2;
55
56 // ssim restated as an error metric like sse
57 double dssim;
58
59 // dssim converted to decibels
60 double dssimd;
61
62 // ssimc converted to decibels
63 double ssimcd;
64} Metrics;
65
Yaowu Xuf883b422016-08-30 14:01:10 -070066double aom_get_ssim_metrics(uint8_t *img1, int img1_pitch, uint8_t *img2,
Yaowu Xuc27fc142016-08-22 16:08:15 -070067 int img2_pitch, int width, int height, Ssimv *sv2,
68 Metrics *m, int do_inconsistency);
69
Yaowu Xuf883b422016-08-30 14:01:10 -070070double aom_calc_ssim(const YV12_BUFFER_CONFIG *source,
Yaowu Xuc27fc142016-08-22 16:08:15 -070071 const YV12_BUFFER_CONFIG *dest, double *weight);
72
Yaowu Xuf883b422016-08-30 14:01:10 -070073double aom_calc_fastssim(const YV12_BUFFER_CONFIG *source,
Yaowu Xuc27fc142016-08-22 16:08:15 -070074 const YV12_BUFFER_CONFIG *dest, double *ssim_y,
75 double *ssim_u, double *ssim_v, uint32_t bd,
76 uint32_t in_bd);
77
Yaowu Xuf883b422016-08-30 14:01:10 -070078#if CONFIG_AOM_HIGHBITDEPTH
79double aom_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source,
Yaowu Xuc27fc142016-08-22 16:08:15 -070080 const YV12_BUFFER_CONFIG *dest, double *weight,
81 uint32_t bd, uint32_t in_bd);
Yaowu Xuf883b422016-08-30 14:01:10 -070082#endif // CONFIG_AOM_HIGHBITDEPTH
Yaowu Xuc27fc142016-08-22 16:08:15 -070083
84#ifdef __cplusplus
85} // extern "C"
86#endif
87
Yaowu Xuf883b422016-08-30 14:01:10 -070088#endif // AOM_DSP_SSIM_H_