stats.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Copyright (c) the JPEG XL Project Authors. All rights reserved.
  2. *
  3. * Use of this source code is governed by a BSD-style
  4. * license that can be found in the LICENSE file.
  5. */
  6. /** @addtogroup libjxl_encoder
  7. * @{
  8. * @file stats.h
  9. * @brief API to collect various statistics from JXL encoder.
  10. */
  11. #ifndef JXL_STATS_H_
  12. #define JXL_STATS_H_
  13. #include <jxl/jxl_export.h>
  14. #include <stddef.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /**
  19. * Opaque structure that holds the encoder statistics.
  20. *
  21. * Allocated and initialized with @ref JxlEncoderStatsCreate().
  22. * Cleaned up and deallocated with @ref JxlEncoderStatsDestroy().
  23. */
  24. typedef struct JxlEncoderStatsStruct JxlEncoderStats;
  25. /**
  26. * Creates an instance of JxlEncoderStats and initializes it.
  27. *
  28. * @return pointer to initialized @ref JxlEncoderStats instance
  29. */
  30. JXL_EXPORT JxlEncoderStats* JxlEncoderStatsCreate(void);
  31. /**
  32. * Deinitializes and frees JxlEncoderStats instance.
  33. *
  34. * @param stats instance to be cleaned up and deallocated. No-op if stats is
  35. * null pointer.
  36. */
  37. JXL_EXPORT void JxlEncoderStatsDestroy(JxlEncoderStats* stats);
  38. /** Data type for querying @ref JxlEncoderStats object
  39. */
  40. typedef enum {
  41. JXL_ENC_STAT_HEADER_BITS,
  42. JXL_ENC_STAT_TOC_BITS,
  43. JXL_ENC_STAT_DICTIONARY_BITS,
  44. JXL_ENC_STAT_SPLINES_BITS,
  45. JXL_ENC_STAT_NOISE_BITS,
  46. JXL_ENC_STAT_QUANT_BITS,
  47. JXL_ENC_STAT_MODULAR_TREE_BITS,
  48. JXL_ENC_STAT_MODULAR_GLOBAL_BITS,
  49. JXL_ENC_STAT_DC_BITS,
  50. JXL_ENC_STAT_MODULAR_DC_GROUP_BITS,
  51. JXL_ENC_STAT_CONTROL_FIELDS_BITS,
  52. JXL_ENC_STAT_COEF_ORDER_BITS,
  53. JXL_ENC_STAT_AC_HISTOGRAM_BITS,
  54. JXL_ENC_STAT_AC_BITS,
  55. JXL_ENC_STAT_MODULAR_AC_GROUP_BITS,
  56. JXL_ENC_STAT_NUM_SMALL_BLOCKS,
  57. JXL_ENC_STAT_NUM_DCT4X8_BLOCKS,
  58. JXL_ENC_STAT_NUM_AFV_BLOCKS,
  59. JXL_ENC_STAT_NUM_DCT8_BLOCKS,
  60. JXL_ENC_STAT_NUM_DCT8X32_BLOCKS,
  61. JXL_ENC_STAT_NUM_DCT16_BLOCKS,
  62. JXL_ENC_STAT_NUM_DCT16X32_BLOCKS,
  63. JXL_ENC_STAT_NUM_DCT32_BLOCKS,
  64. JXL_ENC_STAT_NUM_DCT32X64_BLOCKS,
  65. JXL_ENC_STAT_NUM_DCT64_BLOCKS,
  66. JXL_ENC_STAT_NUM_BUTTERAUGLI_ITERS,
  67. JXL_ENC_NUM_STATS,
  68. } JxlEncoderStatsKey;
  69. /** Returns the value of the statistics corresponding the given key.
  70. *
  71. * @param stats object that was passed to the encoder with a
  72. * @ref JxlEncoderCollectStats function
  73. * @param key the particular statistics to query
  74. *
  75. * @return the value of the statistics
  76. */
  77. JXL_EXPORT size_t JxlEncoderStatsGet(const JxlEncoderStats* stats,
  78. JxlEncoderStatsKey key);
  79. /** Updates the values of the given stats object with that of an other.
  80. *
  81. * @param stats object whose values will be updated (usually added together)
  82. * @param other stats object whose values will be merged with stats
  83. */
  84. JXL_EXPORT void JxlEncoderStatsMerge(JxlEncoderStats* stats,
  85. const JxlEncoderStats* other);
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89. #endif /* JXL_STATS_H_ */
  90. /** @}*/