psnr.h 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (c) 2016, Alliance for Open Media. All rights reserved
  3. *
  4. * This source code is subject to the terms of the BSD 2 Clause License and
  5. * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
  6. * was not distributed with this source code in the LICENSE file, you can
  7. * obtain it at www.aomedia.org/license/software. If the Alliance for Open
  8. * Media Patent License 1.0 was not distributed with this source code in the
  9. * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
  10. */
  11. #ifndef AOM_AOM_DSP_PSNR_H_
  12. #define AOM_AOM_DSP_PSNR_H_
  13. #include "aom_scale/yv12config.h"
  14. #define MAX_PSNR 100.0
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. typedef struct {
  19. double psnr[4]; // total/y/u/v
  20. uint64_t sse[4]; // total/y/u/v
  21. uint32_t samples[4]; // total/y/u/v
  22. double psnr_hbd[4]; // total/y/u/v when input-bit-depth < bit-depth
  23. uint64_t sse_hbd[4]; // total/y/u/v when input-bit-depth < bit-depth
  24. uint32_t samples_hbd[4]; // total/y/u/v when input-bit-depth < bit-depth
  25. } PSNR_STATS;
  26. /*!\brief Converts SSE to PSNR
  27. *
  28. * Converts sum of squared errros (SSE) to peak signal-to-noise ratio (PNSR).
  29. *
  30. * \param[in] samples Number of samples
  31. * \param[in] peak Max sample value
  32. * \param[in] sse Sum of squared errors
  33. */
  34. double aom_sse_to_psnr(double samples, double peak, double sse);
  35. uint64_t aom_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
  36. int vstart, int height);
  37. uint64_t aom_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
  38. int vstart, int height);
  39. uint64_t aom_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
  40. int vstart, int height);
  41. int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
  42. const YV12_BUFFER_CONFIG *b, int hstart, int width,
  43. int vstart, int height);
  44. int64_t aom_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
  45. int64_t aom_get_u_sse_part(const YV12_BUFFER_CONFIG *a,
  46. const YV12_BUFFER_CONFIG *b, int hstart, int width,
  47. int vstart, int height);
  48. int64_t aom_get_u_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
  49. int64_t aom_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
  50. const YV12_BUFFER_CONFIG *b, int hstart, int width,
  51. int vstart, int height);
  52. int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
  53. int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
  54. const YV12_BUFFER_CONFIG *b, int plane, int highbd);
  55. #if CONFIG_AV1_HIGHBITDEPTH
  56. uint64_t aom_highbd_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart,
  57. int width, int vstart, int height);
  58. uint64_t aom_highbd_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart,
  59. int width, int vstart, int height);
  60. uint64_t aom_highbd_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart,
  61. int width, int vstart, int height);
  62. int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
  63. const YV12_BUFFER_CONFIG *b, int hstart,
  64. int width, int vstart, int height);
  65. int64_t aom_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a,
  66. const YV12_BUFFER_CONFIG *b);
  67. int64_t aom_highbd_get_u_sse_part(const YV12_BUFFER_CONFIG *a,
  68. const YV12_BUFFER_CONFIG *b, int hstart,
  69. int width, int vstart, int height);
  70. int64_t aom_highbd_get_u_sse(const YV12_BUFFER_CONFIG *a,
  71. const YV12_BUFFER_CONFIG *b);
  72. int64_t aom_highbd_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
  73. const YV12_BUFFER_CONFIG *b, int hstart,
  74. int width, int vstart, int height);
  75. int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a,
  76. const YV12_BUFFER_CONFIG *b);
  77. void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
  78. const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr,
  79. unsigned int bit_depth, unsigned int in_bit_depth);
  80. #endif
  81. void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
  82. PSNR_STATS *psnr);
  83. double aom_psnrhvs(const YV12_BUFFER_CONFIG *source,
  84. const YV12_BUFFER_CONFIG *dest, double *phvs_y,
  85. double *phvs_u, double *phvs_v, uint32_t bd, uint32_t in_bd);
  86. #ifdef __cplusplus
  87. } // extern "C"
  88. #endif
  89. #endif // AOM_AOM_DSP_PSNR_H_