summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/include/jxl/stats.h
blob: 5ed440636f35560481e3b26d7d9317448a40cec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* Copyright (c) the JPEG XL Project Authors. All rights reserved.
 *
 * Use of this source code is governed by a BSD-style
 * license that can be found in the LICENSE file.
 */

/** @addtogroup libjxl_encoder
 * @{
 * @file stats.h
 * @brief API to collect various statistics from JXL encoder.
 */

#ifndef JXL_STATS_H_
#define JXL_STATS_H_

#include <jxl/jxl_export.h>
#include <stddef.h>

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

/**
 * Opaque structure that holds the encoder statistics.
 *
 * Allocated and initialized with @ref JxlEncoderStatsCreate().
 * Cleaned up and deallocated with @ref JxlEncoderStatsDestroy().
 */
typedef struct JxlEncoderStatsStruct JxlEncoderStats;

/**
 * Creates an instance of JxlEncoderStats and initializes it.
 *
 * @return pointer to initialized @ref JxlEncoderStats instance
 */
JXL_EXPORT JxlEncoderStats* JxlEncoderStatsCreate(void);

/**
 * Deinitializes and frees JxlEncoderStats instance.
 *
 * @param stats instance to be cleaned up and deallocated. No-op if stats is
 * null pointer.
 */
JXL_EXPORT void JxlEncoderStatsDestroy(JxlEncoderStats* stats);

/** Data type for querying @ref JxlEncoderStats object
 */
typedef enum {
  JXL_ENC_STAT_HEADER_BITS,
  JXL_ENC_STAT_TOC_BITS,
  JXL_ENC_STAT_DICTIONARY_BITS,
  JXL_ENC_STAT_SPLINES_BITS,
  JXL_ENC_STAT_NOISE_BITS,
  JXL_ENC_STAT_QUANT_BITS,
  JXL_ENC_STAT_MODULAR_TREE_BITS,
  JXL_ENC_STAT_MODULAR_GLOBAL_BITS,
  JXL_ENC_STAT_DC_BITS,
  JXL_ENC_STAT_MODULAR_DC_GROUP_BITS,
  JXL_ENC_STAT_CONTROL_FIELDS_BITS,
  JXL_ENC_STAT_COEF_ORDER_BITS,
  JXL_ENC_STAT_AC_HISTOGRAM_BITS,
  JXL_ENC_STAT_AC_BITS,
  JXL_ENC_STAT_MODULAR_AC_GROUP_BITS,
  JXL_ENC_STAT_NUM_SMALL_BLOCKS,
  JXL_ENC_STAT_NUM_DCT4X8_BLOCKS,
  JXL_ENC_STAT_NUM_AFV_BLOCKS,
  JXL_ENC_STAT_NUM_DCT8_BLOCKS,
  JXL_ENC_STAT_NUM_DCT8X32_BLOCKS,
  JXL_ENC_STAT_NUM_DCT16_BLOCKS,
  JXL_ENC_STAT_NUM_DCT16X32_BLOCKS,
  JXL_ENC_STAT_NUM_DCT32_BLOCKS,
  JXL_ENC_STAT_NUM_DCT32X64_BLOCKS,
  JXL_ENC_STAT_NUM_DCT64_BLOCKS,
  JXL_ENC_STAT_NUM_BUTTERAUGLI_ITERS,
  JXL_ENC_NUM_STATS,
} JxlEncoderStatsKey;

/** Returns the value of the statistics corresponding the given key.
 *
 * @param stats object that was passed to the encoder with a
 *   @ref JxlEncoderCollectStats function
 * @param key the particular statistics to query
 *
 * @return the value of the statistics
 */
JXL_EXPORT size_t JxlEncoderStatsGet(const JxlEncoderStats* stats,
                                     JxlEncoderStatsKey key);

/** Updates the values of the given stats object with that of an other.
 *
 * @param stats object whose values will be updated (usually added together)
 * @param other stats object whose values will be merged with stats
 */
JXL_EXPORT void JxlEncoderStatsMerge(JxlEncoderStats* stats,
                                     const JxlEncoderStats* other);

#if defined(__cplusplus) || defined(c_plusplus)
}
#endif

#endif /* JXL_STATS_H_ */

/** @}*/