-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
9f57755
to
6306f91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you. How reproducible is the issue? We should escalate this to upstream libebur128.
I can reproduce it with a silent track (empty Mixxx recording, ~3 sec) |
right, makes sense that you'd need "infinite" gain to get that to a fixed level. This should be caught but libebur though. |
src/analyzer/analyzerebur128.cpp
Outdated
// This catches inf and -inf that slipped through in libebur for some reason.. | ||
// TODO Move this to a VERIFY_OR_DEBUG_ASSERT() once the root cause | ||
// has been identified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// This catches inf and -inf that slipped through in libebur for some reason.. | |
// TODO Move this to a VERIFY_OR_DEBUG_ASSERT() once the root cause | |
// has been identified. | |
// This catches inf and -inf that slipped through in libebur for some reason. | |
// TODO: Move this to a VERIFY_OR_DEBUG_ASSERT() once the root cause | |
// has been identified. |
src/analyzer/analyzerebur128.cpp
Outdated
// This catches inf and -inf that slipped through in libebur for some reason.. | ||
// TODO Move this to a VERIFY_OR_DEBUG_ASSERT() once the root cause | ||
// has been identified. | ||
util_isinf(averageLufs) != 0 || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
util_isinf introduces a insymmetry compared the the C89 HUGE_VAL constant.
How about this:
util_isinf(averageLufs) != 0 || | |
util_isnormal(averageLufs) || |
We can only really deal with a normal value.
The alternative would be to check for HUGE_VAL instead.
There is by the way the issue that util_isnormal() shall return bool, not int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I've prepended a commit to fix the return types in fpclassify and use util_isnormal()
here
6306f91
to
8481a3c
Compare
Hmm, the last (code) activity was 3 years ago. |
src/analyzer/analyzerebur128.cpp
Outdated
if (averageLufs == -HUGE_VAL || | ||
averageLufs == HUGE_VAL || | ||
// This catches 0, inf and -inf (that may have slipped through in | ||
// libebur for some reason. | ||
// TODO Move this to a VERIFY_OR_DEBUG_ASSERT() once the root cause | ||
// has been identified, and only do a zero check here. | ||
util_isnormal(averageLufs)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the check for 0 is gone.
My idea was to just
if (averageLufs == -HUGE_VAL || | |
averageLufs == HUGE_VAL || | |
// This catches 0, inf and -inf (that may have slipped through in | |
// libebur for some reason. | |
// TODO Move this to a VERIFY_OR_DEBUG_ASSERT() once the root cause | |
// has been identified, and only do a zero check here. | |
util_isnormal(averageLufs)) { | |
if (!util_isnormal(averageLufs) || averageLufs == 0.0) { | |
// This catches 0, inf (HUGE_VAL), -inf (-HUGE_VAL) and denormals (treated as zero), | |
// that may have slipped through in libebur for some reason. |
Returning -HUGE_VAL is the documented invalid value. I am in doubt there will be a "fix" for HUGE_VAL and even then we deal with user data, where Bad things are not "impossible". So I would not add the TODO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zero is covered by std::isnormal
https://en.cppreference.com/w/cpp/numeric/math/isnormal
I'll remove the TODO then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups, thank you for the hint.
8481a3c
to
19f699f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you.
see #13676