libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

stats.h (2934B)


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