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 11 #ifndef VPX_DSP_SSIM_H_ 12 #define VPX_DSP_SSIM_H_ 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 #include "./vpx_config.h" 19 #include "vpx_scale/yv12config.h" 20 21 // metrics used for calculating ssim, ssim2, dssim, and ssimc 22 typedef struct { 23 // source sum ( over 8x8 region ) 24 uint32_t sum_s; 25 26 // reference sum (over 8x8 region ) 27 uint32_t sum_r; 28 29 // source sum squared ( over 8x8 region ) 30 uint32_t sum_sq_s; 31 32 // reference sum squared (over 8x8 region ) 33 uint32_t sum_sq_r; 34 35 // sum of source times reference (over 8x8 region) 36 uint32_t sum_sxr; 37 38 // calculated ssim score between source and reference 39 double ssim; 40 } Ssimv; 41 42 // metrics collected on a frame basis 43 typedef struct { 44 // ssim consistency error metric ( see code for explanation ) 45 double ssimc; 46 47 // standard ssim 48 double ssim; 49 50 // revised ssim ( see code for explanation) 51 double ssim2; 52 53 // ssim restated as an error metric like sse 54 double dssim; 55 56 // dssim converted to decibels 57 double dssimd; 58 59 // ssimc converted to decibels 60 double ssimcd; 61 } Metrics; 62 63 double vpx_get_ssim_metrics(uint8_t *img1, int img1_pitch, uint8_t *img2, 64 int img2_pitch, int width, int height, Ssimv *sv2, 65 Metrics *m, int do_inconsistency); 66 67 double vpx_calc_ssim(const YV12_BUFFER_CONFIG *source, 68 const YV12_BUFFER_CONFIG *dest, 69 double *weight); 70 71 double vpx_calc_ssimg(const YV12_BUFFER_CONFIG *source, 72 const YV12_BUFFER_CONFIG *dest, 73 double *ssim_y, double *ssim_u, double *ssim_v); 74 75 double vpx_calc_fastssim(const YV12_BUFFER_CONFIG *source, 76 const YV12_BUFFER_CONFIG *dest, 77 double *ssim_y, double *ssim_u, double *ssim_v); 78 79 double vpx_psnrhvs(const YV12_BUFFER_CONFIG *source, 80 const YV12_BUFFER_CONFIG *dest, 81 double *ssim_y, double *ssim_u, double *ssim_v); 82 83 #if CONFIG_VP9_HIGHBITDEPTH 84 double vpx_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source, 85 const YV12_BUFFER_CONFIG *dest, 86 double *weight, 87 unsigned int bd); 88 89 double vpx_highbd_calc_ssimg(const YV12_BUFFER_CONFIG *source, 90 const YV12_BUFFER_CONFIG *dest, 91 double *ssim_y, 92 double *ssim_u, 93 double *ssim_v, 94 unsigned int bd); 95 #endif // CONFIG_VP9_HIGHBITDEPTH 96 97 #ifdef __cplusplus 98 } // extern "C" 99 #endif 100 101 #endif // VPX_DSP_SSIM_H_ 102