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

(fix) AnalyzerEbur128: catch invalid return values inf/-inf #13680

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/analyzer/analyzerebur128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ void AnalyzerEbur128::storeResults(TrackPointer pTrack) {
qWarning() << "AnalyzerEbur128::storeResults() failed with" << e;
return;
}
if (averageLufs == -HUGE_VAL || averageLufs == 0.0) {
if (averageLufs == -HUGE_VAL ||
averageLufs == HUGE_VAL ||
// This catches 0 and abnormal values inf and -inf (that may have
// slipped through in libebur for some reason.
util_isnormal(averageLufs)) {
qWarning() << "AnalyzerEbur128::storeResults() averageLufs invalid:"
<< averageLufs;
return;
Expand Down
8 changes: 4 additions & 4 deletions src/util/fpclassify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ int util_fpclassify(float x) {
return std::fpclassify(x);
}

int util_isfinite(float x) {
bool util_isfinite(float x) {
return std::isfinite(x);
}

int util_isnormal(float x) {
bool util_isnormal(float x) {
return std::isnormal(x);
}

Expand All @@ -33,11 +33,11 @@ int util_fpclassify(double x) {
return std::fpclassify(x);
}

int util_isfinite(double x) {
bool util_isfinite(double x) {
return std::isfinite(x);
}

int util_isnormal(double x) {
bool util_isnormal(double x) {
return std::isnormal(x);
}

Expand Down
8 changes: 4 additions & 4 deletions src/util/fpclassify.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
int util_fpclassify(float x);
int util_fpclassify(double x);

int util_isfinite(float x);
int util_isfinite(double x);
bool util_isfinite(float x);
bool util_isfinite(double x);

int util_isnormal(float x);
int util_isnormal(double x);
bool util_isnormal(float x);
bool util_isnormal(double x);

int util_isnan(float x);
int util_isnan(double x);
Expand Down
11 changes: 11 additions & 0 deletions src/util/versionstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <FLAC/format.h>
#include <chromaprint.h>
#include <ebur128.h>
#include <lame/lame.h>
#include <portaudio.h>
#include <sndfile.h>
Expand Down Expand Up @@ -151,6 +152,12 @@ QStringList VersionStore::dependencyVersions() {
sf_command(nullptr, SFC_GET_LIB_VERSION, sndfile_version, sizeof(sndfile_version));
// Null-terminate just in case.
sndfile_version[sizeof(sndfile_version) - 1] = '\0';

int eburMaj = 0;
int eburMin = 0;
int eburP = 0;
ebur128_get_version(&eburMaj, &eburMin, &eburP);

// WARNING: may be inaccurate since some come from compile-time header
// definitions instead of the actual dynamically loaded library).
QStringList result;
Expand Down Expand Up @@ -181,6 +188,10 @@ QStringList VersionStore::dependencyVersions() {
.arg(QString::number(CHROMAPRINT_VERSION_MAJOR),
QString::number(CHROMAPRINT_VERSION_MINOR),
QString::number(CHROMAPRINT_VERSION_PATCH))
<< QString("libebur128: %1.%2.%3")
.arg(QString::number(eburMaj),
QString::number(eburMin),
QString::number(eburP))
// Should be accurate.
<< QString("Vorbis: %1").arg(vorbis_version_string())
// Should be accurate.
Expand Down
Loading