vp9_ssim.h 2.8 KB

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