<commit_before>/* See COPYING file for copyright and license details. */

#ifndef EBUR128_H_
#define EBUR128_H_

/** \file ebur128.h
 *  \brief libebur128 - a library for loudness measurement according to
 *         the EBU R128 standard.
 */

#ifdef __cplusplus
extern "C" {
#endif

#define EBUR128_VERSION_MAJOR 1
#define EBUR128_VERSION_MINOR 2
#define EBUR128_VERSION_PATCH 2

#include <stddef.h>       /* for size_t */

/** \enum channel
 *  Use these values when setting the channel map with ebur128_set_channel().
 *  See definitions in ITU R-REC-BS 1770-4
 */
enum channel {
  EBUR128_UNUSED = 0,     /**< unused channel (for example LFE channel) */
  EBUR128_LEFT   = 1,
  EBUR128_Mp030  = 1,     /**< itu M+030 */
  EBUR128_RIGHT  = 2,
  EBUR128_Mm030  = 2,     /**< itu M-030 */
  EBUR128_CENTER = 3,
  EBUR128_Mp000  = 3,     /**< itu M+000 */
  EBUR128_LEFT_SURROUND  = 4,
  EBUR128_Mp110  = 4,     /**< itu M+110 */
  EBUR128_RIGHT_SURROUND = 5,
  EBUR128_Mm110  = 5,     /**< itu M-110 */
  EBUR128_DUAL_MONO,      /**< a channel that is counted twice */
  EBUR128_MpSC,           /**< itu M+SC */
  EBUR128_MmSC,           /**< itu M-SC */
  EBUR128_Mp060,          /**< itu M+060 */
  EBUR128_Mm060,          /**< itu M-060 */
  EBUR128_Mp090,          /**< itu M+090 */
  EBUR128_Mm090,          /**< itu M-090 */
  EBUR128_Mp135,          /**< itu M+135 */
  EBUR128_Mm135,          /**< itu M-135 */
  EBUR128_Mp180,          /**< itu M+180 */
  EBUR128_Up000,          /**< itu U+000 */
  EBUR128_Up030,          /**< itu U+030 */
  EBUR128_Um030,          /**< itu U-030 */
  EBUR128_Up045,          /**< itu U+045 */
  EBUR128_Um045,          /**< itu U-030 */
  EBUR128_Up090,          /**< itu U+090 */
  EBUR128_Um090,          /**< itu U-090 */
  EBUR128_Up110,          /**< itu U+110 */
  EBUR128_Um110,          /**< itu U-110 */
  EBUR128_Up135,          /**< itu U+135 */
  EBUR128_Um135,          /**< itu U-135 */
  EBUR128_Up180,          /**< itu U+180 */
  EBUR128_Tp000,          /**< itu T+000 */
  EBUR128_Bp000,          /**< itu B+000 */
  EBUR128_Bp045,          /**< itu B+045 */
  EBUR128_Bm045           /**< itu B-045 */
};

/** \enum error
 *  Error return values.
 */
enum error {
  EBUR128_SUCCESS = 0,
  EBUR128_ERROR_NOMEM,
  EBUR128_ERROR_INVALID_MODE,
  EBUR128_ERROR_INVALID_CHANNEL_INDEX,
  EBUR128_ERROR_NO_CHANGE
};

/** \enum mode
 *  Use these values in ebur128_init (or'ed). Try to use the lowest possible
 *  modes that suit your needs, as performance will be better.
 */
enum mode {
  /** can call ebur128_loudness_momentary */
  EBUR128_MODE_M           = (1 << 0),
  /** can call ebur128_loudness_shortterm */
  EBUR128_MODE_S           = (1 << 1) | EBUR128_MODE_M,
  /** can call ebur128_loudness_global_* and ebur128_relative_threshold */
  EBUR128_MODE_I           = (1 << 2) | EBUR128_MODE_M,
  /** can call ebur128_loudness_range */
  EBUR128_MODE_LRA         = (1 << 3) | EBUR128_MODE_S,
  /** can call ebur128_sample_peak */
  EBUR128_MODE_SAMPLE_PEAK = (1 << 4) | EBUR128_MODE_M,
  /** can call ebur128_true_peak */
  EBUR128_MODE_TRUE_PEAK   = (1 << 5) | EBUR128_MODE_M
                                      | EBUR128_MODE_SAMPLE_PEAK,
  /** uses histogram algorithm to calculate loudness */
  EBUR128_MODE_HISTOGRAM   = (1 << 6)
};

/** forward declaration of ebur128_state_internal */
struct ebur128_state_internal;

/** \brief Contains information about the state of a loudness measurement.
 *
 *  You should not need to modify this struct directly.
 */
typedef struct {
  int mode;                           /**< The current mode. */
  unsigned int channels;              /**< The number of channels. */
  unsigned long samplerate;           /**< The sample rate. */
  struct ebur128_state_internal* d;   /**< Internal state. */
} ebur128_state;

/** \brief Get library version number. Do not pass null pointers here.
 *
 *  @param major major version number of library
 *  @param minor minor version number of library
 *  @param patch patch version number of library
 */
void ebur128_get_version(int* major, int* minor, int* patch);

/** \brief Initialize library state.
 *
 *  @param channels the number of channels.
 *  @param samplerate the sample rate.
 *  @param mode see the mode enum for possible values.
 *  @return an initialized library state.
 */
ebur128_state* ebur128_init(unsigned int channels,
                            unsigned long samplerate,
                            int mode);

/** \brief Destroy library state.
 *
 *  @param st pointer to a library state.
 */
void ebur128_destroy(ebur128_state** st);

/** \brief Set channel type.
 *
 *  The default is:
 *  - 0 -> EBUR128_LEFT
 *  - 1 -> EBUR128_RIGHT
 *  - 2 -> EBUR128_CENTER
 *  - 3 -> EBUR128_UNUSED
 *  - 4 -> EBUR128_LEFT_SURROUND
 *  - 5 -> EBUR128_RIGHT_SURROUND
 *
 *  @param st library state.<commit_msg>document that ebur128_init can return NULL on error<commit_after>/* See COPYING file for copyright and license details. */

#ifndef EBUR128_H_
#define EBUR128_H_

/** \file ebur128.h
 *  \brief libebur128 - a library for loudness measurement according to
 *         the EBU R128 standard.
 */

#ifdef __cplusplus
extern "C" {
#endif

#define EBUR128_VERSION_MAJOR 1
#define EBUR128_VERSION_MINOR 2
#define EBUR128_VERSION_PATCH 2

#include <stddef.h>       /* for size_t */

/** \enum channel
 *  Use these values when setting the channel map with ebur128_set_channel().
 *  See definitions in ITU R-REC-BS 1770-4
 */
enum channel {
  EBUR128_UNUSED = 0,     /**< unused channel (for example LFE channel) */
  EBUR128_LEFT   = 1,
  EBUR128_Mp030  = 1,     /**< itu M+030 */
  EBUR128_RIGHT  = 2,
  EBUR128_Mm030  = 2,     /**< itu M-030 */
  EBUR128_CENTER = 3,
  EBUR128_Mp000  = 3,     /**< itu M+000 */
  EBUR128_LEFT_SURROUND  = 4,
  EBUR128_Mp110  = 4,     /**< itu M+110 */
  EBUR128_RIGHT_SURROUND = 5,
  EBUR128_Mm110  = 5,     /**< itu M-110 */
  EBUR128_DUAL_MONO,      /**< a channel that is counted twice */
  EBUR128_MpSC,           /**< itu M+SC */
  EBUR128_MmSC,           /**< itu M-SC */
  EBUR128_Mp060,          /**< itu M+060 */
  EBUR128_Mm060,          /**< itu M-060 */
  EBUR128_Mp090,          /**< itu M+090 */
  EBUR128_Mm090,          /**< itu M-090 */
  EBUR128_Mp135,          /**< itu M+135 */
  EBUR128_Mm135,          /**< itu M-135 */
  EBUR128_Mp180,          /**< itu M+180 */
  EBUR128_Up000,          /**< itu U+000 */
  EBUR128_Up030,          /**< itu U+030 */
  EBUR128_Um030,          /**< itu U-030 */
  EBUR128_Up045,          /**< itu U+045 */
  EBUR128_Um045,          /**< itu U-030 */
  EBUR128_Up090,          /**< itu U+090 */
  EBUR128_Um090,          /**< itu U-090 */
  EBUR128_Up110,          /**< itu U+110 */
  EBUR128_Um110,          /**< itu U-110 */
  EBUR128_Up135,          /**< itu U+135 */
  EBUR128_Um135,          /**< itu U-135 */
  EBUR128_Up180,          /**< itu U+180 */
  EBUR128_Tp000,          /**< itu T+000 */
  EBUR128_Bp000,          /**< itu B+000 */
  EBUR128_Bp045,          /**< itu B+045 */
  EBUR128_Bm045           /**< itu B-045 */
};

/** \enum error
 *  Error return values.
 */
enum error {
  EBUR128_SUCCESS = 0,
  EBUR128_ERROR_NOMEM,
  EBUR128_ERROR_INVALID_MODE,
  EBUR128_ERROR_INVALID_CHANNEL_INDEX,
  EBUR128_ERROR_NO_CHANGE
};

/** \enum mode
 *  Use these values in ebur128_init (or'ed). Try to use the lowest possible
 *  modes that suit your needs, as performance will be better.
 */
enum mode {
  /** can call ebur128_loudness_momentary */
  EBUR128_MODE_M           = (1 << 0),
  /** can call ebur128_loudness_shortterm */
  EBUR128_MODE_S           = (1 << 1) | EBUR128_MODE_M,
  /** can call ebur128_loudness_global_* and ebur128_relative_threshold */
  EBUR128_MODE_I           = (1 << 2) | EBUR128_MODE_M,
  /** can call ebur128_loudness_range */
  EBUR128_MODE_LRA         = (1 << 3) | EBUR128_MODE_S,
  /** can call ebur128_sample_peak */
  EBUR128_MODE_SAMPLE_PEAK = (1 << 4) | EBUR128_MODE_M,
  /** can call ebur128_true_peak */
  EBUR128_MODE_TRUE_PEAK   = (1 << 5) | EBUR128_MODE_M
                                      | EBUR128_MODE_SAMPLE_PEAK,
  /** uses histogram algorithm to calculate loudness */
  EBUR128_MODE_HISTOGRAM   = (1 << 6)
};

/** forward declaration of ebur128_state_internal */
struct ebur128_state_internal;

/** \brief Contains information about the state of a loudness measurement.
 *
 *  You should not need to modify this struct directly.
 */
typedef struct {
  int mode;                           /**< The current mode. */
  unsigned int channels;              /**< The number of channels. */
  unsigned long samplerate;           /**< The sample rate. */
  struct ebur128_state_internal* d;   /**< Internal state. */
} ebur128_state;

/** \brief Get library version number. Do not pass null pointers here.
 *
 *  @param major major version number of library
 *  @param minor minor version number of library
 *  @param patch patch version number of library
 */
void ebur128_get_version(int* major, int* minor, int* patch);

/** \brief Initialize library state.
 *
 *  @param channels the number of channels.
 *  @param samplerate the sample rate.
 *  @param mode see the mode enum for possible values.
 *  @return an initialized library state, or NULL on error.
 */
ebur128_state* ebur128_init(unsigned int channels,
                            unsigned long samplerate,
                            int mode);

/** \brief Destroy library state.
 *
 *  @param st pointer to a library state.
 */
void ebur128_destroy(ebur128_state** st);

/** \brief Set channel type.
 *
 *  The default is:
 *  - 0 -> EBUR128_LEFT
 *  - 1 -> EBUR128_RIGHT
 *  - 2 -> EBUR128_CENTER
 *  - 3 -> EBUR128_UNUSED
 *  - 4 -> EBUR128_LEFT_SURROUND
 *  - 5 -> EBUR128_RIGHT_SURROUND
 *
 *  @param st library state.
{'fraction_non_alphanumeric': 0.12155541947336192, 'fraction_numerical': 0.09604000816493162, 'mean_word_length': 2.3239484396200814, 'pattern_counts': {'":': 0, '<': 105, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '184424', 'n_tokens_mistral': 4322, 'n_tokens_neox': 3517, 'n_words': 896}