blob: fb92556a8cae6d24f90142212b8f39f176c74e08 [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
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_AOM_DSP_SSIM_H_
13#define AOM_AOM_DSP_SSIM_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
Yaowu Xuc27fc142016-08-22 16:08:15 -070015#ifdef __cplusplus
16extern "C" {
17#endif
18
Tom Finegan60e653d2018-05-22 11:34:58 -070019#include "config/aom_config.h"
20
Jayashri Murugan01644772021-05-03 15:53:25 +053021#if CONFIG_INTERNAL_STATS
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
Aniket Wanaref459c55c2021-05-06 15:16:03 +053070void aom_lowbd_calc_ssim(const YV12_BUFFER_CONFIG *source,
71 const YV12_BUFFER_CONFIG *dest, double *weight,
72 double *fast_ssim);
Yaowu Xuc27fc142016-08-22 16:08:15 -070073
Yaowu Xuf883b422016-08-30 14:01:10 -070074double aom_calc_fastssim(const YV12_BUFFER_CONFIG *source,
Yaowu Xuc27fc142016-08-22 16:08:15 -070075 const YV12_BUFFER_CONFIG *dest, double *ssim_y,
76 double *ssim_u, double *ssim_v, uint32_t bd,
77 uint32_t in_bd);
78
Aniket Wanaref459c55c2021-05-06 15:16:03 +053079#if CONFIG_AV1_HIGHBITDEPTH
Aasaipriya Chandran6aa351c2020-08-17 20:47:44 +053080void aom_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source,
81 const YV12_BUFFER_CONFIG *dest, double *weight,
82 uint32_t bd, uint32_t in_bd, double *fast_ssim);
Aniket Wanaref459c55c2021-05-06 15:16:03 +053083#endif // CONFIG_AV1_HIGHBITDEPTH
84
85void aom_calc_ssim(const YV12_BUFFER_CONFIG *orig,
86 const YV12_BUFFER_CONFIG *recon, const uint32_t bit_depth,
87 const uint32_t in_bit_depth, int is_hbd, double *weight,
88 double *frame_ssim2);
Jayashri Murugan01644772021-05-03 15:53:25 +053089#endif // CONFIG_INTERNAL_STATS
90
91double aom_ssim2(const uint8_t *img1, const uint8_t *img2, int stride_img1,
92 int stride_img2, int width, int height);
93
94#if CONFIG_AV1_HIGHBITDEPTH
95double aom_highbd_ssim2(const uint8_t *img1, const uint8_t *img2,
96 int stride_img1, int stride_img2, int width, int height,
97 uint32_t bd, uint32_t shift);
98#endif // CONFIG_AV1_HIGHBITDEPTH
Yaowu Xuc27fc142016-08-22 16:08:15 -070099
100#ifdef __cplusplus
101} // extern "C"
102#endif
103
James Zerne1cbb132018-08-22 14:10:36 -0700104#endif // AOM_AOM_DSP_SSIM_H_