Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_histogram_index() is being called from ebur128_gated_loudness() when not using histogram mode #76

Open
DarenFord opened this issue Feb 9, 2018 · 0 comments

Comments

@DarenFord
Copy link

DarenFord commented Feb 9, 2018

The following code in ebur128_gated_loudness() is calling find_histogram_index() unconditionally (whether histogram mode is specified or not):

if (relative_threshold < histogram_energy_boundaries[0]) {
start_index = 0;
} else {
start_index = find_histogram_index(relative_threshold);
if (relative_threshold > histogram_energies[start_index]) {
++start_index;
}
}

As a local fix, I have moved this block of code so that the function is only called when histogram mode is specified:

for (i = 0; i < size; i++) {
if (!sts[i]) continue;
if (sts[i]->d->use_histogram) {
if (relative_threshold < m_dHistogramEnergyBoundaries[0]) {
start_index = 0;
} else {
start_index = find_histogram_index(relative_threshold);
if (relative_threshold > m_dHistogramEnergies[start_index]) {
++start_index;
}
}
for (j = start_index; j < 1000; ++j) {
gated_loudness += sts[i]->d->block_energy_histogram[j] * m_dHistogramEnergies[j];
above_thresh_counter += sts[i]->d->block_energy_histogram[j];
}
} else {
STAILQ_FOREACH(it, &sts[i]->d->block_list, entries) {
if (it->z >= relative_threshold) {
++above_thresh_counter;
gated_loudness += it->z;
}
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant