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_VPX_DSP_SSIM_H_ 12 #define VPX_VPX_DSP_SSIM_H_ 13 14 #define MAX_SSIM_DB 100.0; 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 #include "./vpx_config.h" 21 #include "vpx_scale/yv12config.h" 22 23 // metrics used for calculating ssim, ssim2, dssim, and ssimc 24 typedef struct { 25 // source sum ( over 8x8 region ) 26 uint32_t sum_s; 27 28 // reference sum (over 8x8 region ) 29 uint32_t sum_r; 30 31 // source sum squared ( over 8x8 region ) 32 uint32_t sum_sq_s; 33 34 // reference sum squared (over 8x8 region ) 35 uint32_t sum_sq_r; 36 37 // sum of source times reference (over 8x8 region) 38 uint32_t sum_sxr; 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 65 double vpx_get_ssim_metrics(uint8_t *img1, int img1_pitch, uint8_t *img2, 66 int img2_pitch, int width, int height, Ssimv *sv2, 67 Metrics *m, int do_inconsistency); 68 69 double vpx_calc_ssim(const YV12_BUFFER_CONFIG *source, 70 const YV12_BUFFER_CONFIG *dest, double *weight); 71 72 double vpx_calc_fastssim(const YV12_BUFFER_CONFIG *source, 73 const YV12_BUFFER_CONFIG *dest, double *ssim_y, 74 double *ssim_u, double *ssim_v, uint32_t bd, 75 uint32_t in_bd); 76 77 #if CONFIG_VP9_HIGHBITDEPTH 78 double vpx_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source, 79 const YV12_BUFFER_CONFIG *dest, double *weight, 80 uint32_t bd, uint32_t in_bd); 81 #endif // CONFIG_VP9_HIGHBITDEPTH 82 83 #ifdef __cplusplus 84 } // extern "C" 85 #endif 86 87 #endif // VPX_VPX_DSP_SSIM_H_ 88