calc-cbs-params: fix off-by-one on locredit calculation#37
Open
cataldor wants to merge 1 commit intoAvnu:masterfrom
Open
calc-cbs-params: fix off-by-one on locredit calculation#37cataldor wants to merge 1 commit intoAvnu:masterfrom
cataldor wants to merge 1 commit intoAvnu:masterfrom
Conversation
The locredit parameter is a rounded up integer from a floating-point division. Unfortunately, locredit is a negative number (as it is derived from sendslope), and the rounding up python function employed (math.ceil()) provides the relative (not absolute) rounded up value. Thus, math.ceil(-4.2) is -4 and not -5. Use math.floor() for this specific case. Before this patch: $ ./calc-cbs-params.py --stream class=a,transport=avtp-aaf,rate=8000,psize=384 Class A: idleslope 28800 sendslope -971200 hicredit 45 locredit -437 (...) After this patch: $ ./calc-cbs-params.py --stream class=a,transport=avtp-aaf,rate=8000,psize=384 Class A: idleslope 28800 sendslope -971200 hicredit 45 locredit -438 (...) Signed-off-by: Rodrigo Cataldo <rodrigo.cadore@l-acoustics.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello everyone,
i think i found an off-by-one issue on locredit calculation, assuming that the intent of
ceilwas to always round up.Let me know if you all agree.
If I am wrong, i still think we should add a comment since
ceil()may not behave as "expected".The locredit parameter is a rounded up integer from a floating-point division. Unfortunately, locredit is a negative number (as it is derived from sendslope), and the rounding up python function employed (math.ceil()) provides the relative (not absolute) rounded up value.
Thus, math.ceil(-4.2) is -4 and not -5.
Use math.floor() for this specific case.
Before this patch:
$ ./calc-cbs-params.py --stream class=a,transport=avtp-aaf,rate=8000,psize=384
Class A: idleslope 28800 sendslope -971200 hicredit 45 locredit -437
(...)
After this patch:
$ ./calc-cbs-params.py --stream class=a,transport=avtp-aaf,rate=8000,psize=384
Class A: idleslope 28800 sendslope -971200 hicredit 45 locredit -438
(...)