2
0

ssim.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #ifndef VPX_VPX_DSP_SSIM_H_
  11. #define VPX_VPX_DSP_SSIM_H_
  12. #define MAX_SSIM_DB 100.0;
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #include "./vpx_config.h"
  17. #include "vpx_scale/yv12config.h"
  18. // metrics used for calculating ssim, ssim2, dssim, and ssimc
  19. typedef struct {
  20. // source sum ( over 8x8 region )
  21. uint32_t sum_s;
  22. // reference sum (over 8x8 region )
  23. uint32_t sum_r;
  24. // source sum squared ( over 8x8 region )
  25. uint32_t sum_sq_s;
  26. // reference sum squared (over 8x8 region )
  27. uint32_t sum_sq_r;
  28. // sum of source times reference (over 8x8 region)
  29. uint32_t sum_sxr;
  30. // calculated ssim score between source and reference
  31. double ssim;
  32. } Ssimv;
  33. // metrics collected on a frame basis
  34. typedef struct {
  35. // ssim consistency error metric ( see code for explanation )
  36. double ssimc;
  37. // standard ssim
  38. double ssim;
  39. // revised ssim ( see code for explanation)
  40. double ssim2;
  41. // ssim restated as an error metric like sse
  42. double dssim;
  43. // dssim converted to decibels
  44. double dssimd;
  45. // ssimc converted to decibels
  46. double ssimcd;
  47. } Metrics;
  48. double vpx_get_ssim_metrics(uint8_t *img1, int img1_pitch, uint8_t *img2,
  49. int img2_pitch, int width, int height, Ssimv *sv2,
  50. Metrics *m, int do_inconsistency);
  51. double vpx_calc_ssim(const YV12_BUFFER_CONFIG *source,
  52. const YV12_BUFFER_CONFIG *dest, double *weight);
  53. double vpx_calc_fastssim(const YV12_BUFFER_CONFIG *source,
  54. const YV12_BUFFER_CONFIG *dest, double *ssim_y,
  55. double *ssim_u, double *ssim_v, uint32_t bd,
  56. uint32_t in_bd);
  57. #if CONFIG_VP9_HIGHBITDEPTH
  58. double vpx_highbd_calc_ssim(const YV12_BUFFER_CONFIG *source,
  59. const YV12_BUFFER_CONFIG *dest, double *weight,
  60. uint32_t bd, uint32_t in_bd);
  61. #endif // CONFIG_VP9_HIGHBITDEPTH
  62. #ifdef __cplusplus
  63. } // extern "C"
  64. #endif
  65. #endif // VPX_VPX_DSP_SSIM_H_