Dmitry Kovalev | 129cb23 | 2014-04-08 16:08:39 -0700 | [diff] [blame] | 1 | /* |
| 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 Converse | c65e79d | 2015-08-06 13:46:28 -0700 | [diff] [blame] | 11 | #ifndef VPX_DSP_SSIM_H_ |
| 12 | #define VPX_DSP_SSIM_H_ |
Dmitry Kovalev | 129cb23 | 2014-04-08 16:08:39 -0700 | [diff] [blame] | 13 | |
Yaowu Xu | efe1b1d | 2016-02-04 14:03:48 -0800 | [diff] [blame] | 14 | #define MAX_SSIM_DB 100.0; |
| 15 | |
Dmitry Kovalev | 129cb23 | 2014-04-08 16:08:39 -0700 | [diff] [blame] | 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif |
| 19 | |
Alex Converse | c7b7011 | 2015-08-06 12:53:59 -0700 | [diff] [blame] | 20 | #include "./vpx_config.h" |
Dmitry Kovalev | 129cb23 | 2014-04-08 16:08:39 -0700 | [diff] [blame] | 21 | #include "vpx_scale/yv12config.h" |
| 22 | |
Jim Bankoski | ee87e20 | 2015-04-21 10:05:37 -0700 | [diff] [blame] | 23 | // metrics used for calculating ssim, ssim2, dssim, and ssimc |
| 24 | typedef struct { |
| 25 | // source sum ( over 8x8 region ) |
Alex Converse | c65e79d | 2015-08-06 13:46:28 -0700 | [diff] [blame] | 26 | uint32_t sum_s; |
Jim Bankoski | ee87e20 | 2015-04-21 10:05:37 -0700 | [diff] [blame] | 27 | |
| 28 | // reference sum (over 8x8 region ) |
Alex Converse | c65e79d | 2015-08-06 13:46:28 -0700 | [diff] [blame] | 29 | uint32_t sum_r; |
Jim Bankoski | ee87e20 | 2015-04-21 10:05:37 -0700 | [diff] [blame] | 30 | |
| 31 | // source sum squared ( over 8x8 region ) |
Alex Converse | c65e79d | 2015-08-06 13:46:28 -0700 | [diff] [blame] | 32 | uint32_t sum_sq_s; |
Jim Bankoski | ee87e20 | 2015-04-21 10:05:37 -0700 | [diff] [blame] | 33 | |
| 34 | // reference sum squared (over 8x8 region ) |
Alex Converse | c65e79d | 2015-08-06 13:46:28 -0700 | [diff] [blame] | 35 | uint32_t sum_sq_r; |
Jim Bankoski | ee87e20 | 2015-04-21 10:05:37 -0700 | [diff] [blame] | 36 | |
| 37 | // sum of source times reference (over 8x8 region) |
Alex Converse | c65e79d | 2015-08-06 13:46:28 -0700 | [diff] [blame] | 38 | uint32_t sum_sxr; |
Jim Bankoski | ee87e20 | 2015-04-21 10:05:37 -0700 | [diff] [blame] | 39 | |
| 40 | // calculated ssim score between source and reference |
| 41 | double ssim; |
| 42 | } Ssimv; |
| 43 | |
| 44 | // metrics collected on a frame basis |
| 45 | typedef 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 Converse | c7b7011 | 2015-08-06 12:53:59 -0700 | [diff] [blame] | 65 | double vpx_get_ssim_metrics(uint8_t *img1, int img1_pitch, uint8_t *img2, |
Jim Bankoski | ee87e20 | 2015-04-21 10:05:37 -0700 | [diff] [blame] | 66 | int img2_pitch, int width, int height, Ssimv *sv2, |
| 67 | Metrics *m, int do_inconsistency); |
| 68 | |
Alex Converse | 26f4f2d | 2015-08-07 10:48:32 -0700 | [diff] [blame] | 69 | double vpx_calc_ssim(const YV12_BUFFER_CONFIG *source, |
| 70 | const YV12_BUFFER_CONFIG *dest, |
Jim Bankoski | 3c463ab | 2014-08-22 12:25:07 -0700 | [diff] [blame] | 71 | double *weight); |
Dmitry Kovalev | 129cb23 | 2014-04-08 16:08:39 -0700 | [diff] [blame] | 72 | |
Alex Converse | 4ea7f2b | 2015-08-07 12:02:49 -0700 | [diff] [blame] | 73 | double vpx_calc_fastssim(const YV12_BUFFER_CONFIG *source, |
| 74 | const YV12_BUFFER_CONFIG *dest, |
Yaowu Xu | c0874f2 | 2016-02-05 11:30:12 -0800 | [diff] [blame] | 75 | double *ssim_y, double *ssim_u, |
Yaowu Xu | d1c5cd4 | 2016-02-22 12:58:38 -0800 | [diff] [blame] | 76 | double *ssim_v, uint32_t bd, uint32_t in_bd); |
Jim Bankoski | 3f7f194 | 2015-04-17 10:23:24 -0700 | [diff] [blame] | 77 | |
Deb Mukherjee | 4109372 | 2014-09-19 16:51:59 -0700 | [diff] [blame] | 78 | #if CONFIG_VP9_HIGHBITDEPTH |
Alex Converse | 26f4f2d | 2015-08-07 10:48:32 -0700 | [diff] [blame] | 79 | double vpx_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source, |
| 80 | const YV12_BUFFER_CONFIG *dest, |
Deb Mukherjee | 4109372 | 2014-09-19 16:51:59 -0700 | [diff] [blame] | 81 | double *weight, |
Yaowu Xu | eeaf8e6 | 2016-02-22 16:05:19 -0800 | [diff] [blame] | 82 | uint32_t bd, uint32_t in_bd); |
Deb Mukherjee | 4109372 | 2014-09-19 16:51:59 -0700 | [diff] [blame] | 83 | #endif // CONFIG_VP9_HIGHBITDEPTH |
| 84 | |
Dmitry Kovalev | 129cb23 | 2014-04-08 16:08:39 -0700 | [diff] [blame] | 85 | #ifdef __cplusplus |
| 86 | } // extern "C" |
| 87 | #endif |
| 88 | |
Alex Converse | c65e79d | 2015-08-06 13:46:28 -0700 | [diff] [blame] | 89 | #endif // VPX_DSP_SSIM_H_ |