Skip to content
Permalink
Browse files
Add ebur128_libinit() for global one-time initialization
  • Loading branch information
sdroege committed Jan 5, 2020
1 parent 84614aa commit 3a329b96fad613434a001dce01d159e141aa3382
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
@@ -400,6 +400,24 @@ void ebur128_get_version(int* major, int* minor, int* patch) {
} \
} while (0);

void
ebur128_libinit(void) {
int i;

/* initialize static constants */
relative_gate_factor = pow(10.0, relative_gate / 10.0);
minus_twenty_decibels = pow(10.0, -20.0 / 10.0);
histogram_energy_boundaries[0] = pow(10.0, (-70.0 + 0.691) / 10.0);
for (i = 0; i < 1000; ++i) {
histogram_energies[i] =
pow(10.0, ((double) i / 10.0 - 69.95 + 0.691) / 10.0);
}
for (i = 1; i < 1001; ++i) {
histogram_energy_boundaries[i] =
pow(10.0, ((double) i / 10.0 - 70.0 + 0.691) / 10.0);
}
}

ebur128_state*
ebur128_init(unsigned int channels, unsigned long samplerate, int mode) {
int result;
@@ -500,21 +518,6 @@ ebur128_init(unsigned int channels, unsigned long samplerate, int mode) {
/* start at the beginning of the buffer */
st->d->audio_data_index = 0;

/* initialize static constants */
relative_gate_factor = pow(10.0, relative_gate / 10.0);
minus_twenty_decibels = pow(10.0, -20.0 / 10.0);
histogram_energy_boundaries[0] = pow(10.0, (-70.0 + 0.691) / 10.0);
if (st->d->use_histogram) {
for (i = 0; i < 1000; ++i) {
histogram_energies[i] =
pow(10.0, ((double) i / 10.0 - 69.95 + 0.691) / 10.0);
}
for (i = 1; i < 1001; ++i) {
histogram_energy_boundaries[i] =
pow(10.0, ((double) i / 10.0 - 70.0 + 0.691) / 10.0);
}
}

return st;

free_short_term_block_energy_histogram:
@@ -117,6 +117,10 @@ typedef struct {
*/
void ebur128_get_version(int* major, int* minor, int* patch);

/** \brief Initialize global library state.
*/
void ebur128_libinit(void);

/** \brief Initialize library state.
*
* @param channels the number of channels.
@@ -1 +1,4 @@
68abf1bd0a904b4bae613f9aeed85e215af1c4e3 from https://github.com/jiixyj/libebur128

Changes:
- Adding ebur128_libinit() for global one-time initialization.
@@ -135,6 +135,10 @@ extern "C" {
patch: *mut ::std::os::raw::c_int,
);
}
extern "C" {
#[doc = " \\brief Initialize global library state."]
pub fn ebur128_libinit();
}
extern "C" {
#[doc = " \\brief Initialize library state."]
#[doc = ""]

0 comments on commit 3a329b9

Please sign in to comment.