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

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Sep 21, 2024

see #13676

@ronso0 ronso0 added this to the 2.4.2 milestone Sep 21, 2024
src/util/versionstore.cpp Outdated Show resolved Hide resolved
Copy link
Member

@Swiftb0y Swiftb0y left a 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.

@ronso0
Copy link
Member Author

ronso0 commented Sep 21, 2024

I can reproduce it with a silent track (empty Mixxx recording, ~3 sec)
space.mp3.zip

@Swiftb0y
Copy link
Member

right, makes sense that you'd need "infinite" gain to get that to a fixed level. This should be caught but libebur though.

Comment on lines 74 to 76
// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.

// 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 ||
Copy link
Member

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:

Suggested change
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.

Copy link
Member Author

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

@ronso0 ronso0 linked an issue Sep 22, 2024 that may be closed by this pull request
@ronso0
Copy link
Member Author

ronso0 commented Sep 22, 2024

How reproducible is the issue? We should escalate this to upstream libebur128.

Hmm, the last (code) activity was 3 years ago.
edit okay, jiixyj is stil lactive in the PRs.

Comment on lines 72 to 76
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)) {
Copy link
Member

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

Suggested change
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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you.

@daschuer daschuer merged commit 3a30c03 into mixxxdj:2.4 Sep 23, 2024
14 checks passed
@ronso0 ronso0 deleted the libebur-debug branch September 23, 2024 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Analyzer: handle INF gain value
3 participants