Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 4 | * 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 Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_AOM_DSP_SSIM_H_ |
| 13 | #define AOM_AOM_DSP_SSIM_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
Tom Finegan | 60e653d | 2018-05-22 11:34:58 -0700 | [diff] [blame] | 19 | #include "config/aom_config.h" |
| 20 | |
Jayashri Murugan | 0164477 | 2021-05-03 15:53:25 +0530 | [diff] [blame] | 21 | #if CONFIG_INTERNAL_STATS |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 22 | #include "aom_scale/yv12config.h" |
| 23 | |
| 24 | // metrics used for calculating ssim, ssim2, dssim, and ssimc |
| 25 | typedef 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 |
| 46 | typedef 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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 66 | double aom_get_ssim_metrics(uint8_t *img1, int img1_pitch, uint8_t *img2, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 67 | int img2_pitch, int width, int height, Ssimv *sv2, |
| 68 | Metrics *m, int do_inconsistency); |
| 69 | |
Aniket Wanare | f459c55c | 2021-05-06 15:16:03 +0530 | [diff] [blame] | 70 | void aom_lowbd_calc_ssim(const YV12_BUFFER_CONFIG *source, |
| 71 | const YV12_BUFFER_CONFIG *dest, double *weight, |
| 72 | double *fast_ssim); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 73 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 74 | double aom_calc_fastssim(const YV12_BUFFER_CONFIG *source, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 75 | 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 Wanare | f459c55c | 2021-05-06 15:16:03 +0530 | [diff] [blame] | 79 | #if CONFIG_AV1_HIGHBITDEPTH |
Aasaipriya Chandran | 6aa351c | 2020-08-17 20:47:44 +0530 | [diff] [blame] | 80 | void 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 Wanare | f459c55c | 2021-05-06 15:16:03 +0530 | [diff] [blame] | 83 | #endif // CONFIG_AV1_HIGHBITDEPTH |
| 84 | |
| 85 | void 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 Murugan | 0164477 | 2021-05-03 15:53:25 +0530 | [diff] [blame] | 89 | #endif // CONFIG_INTERNAL_STATS |
| 90 | |
| 91 | double 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 |
| 95 | double 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 Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 99 | |
| 100 | #ifdef __cplusplus |
| 101 | } // extern "C" |
| 102 | #endif |
| 103 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 104 | #endif // AOM_AOM_DSP_SSIM_H_ |