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

Resolves issue #65 - treat classification byte as unsigned char #66

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

jason-daly
Copy link
Contributor

All 8 bits of the classification byte have the potential to be used, in both the older formats (0..5) and in the newer formats (6..10). The code had been reading this byte into a signed byte, and then casting it to a short.
For the older formats, this would mean that if the 'Withheld' bit was set (bit index 7), this bit would be interpreted as a sign bit, and effectively be lost in the cast (I think!).
For the newer formats, where the entire byte is used for the classification value, any classifications > 127 are being incorrectly read as negative values.

I think the same issue applies in the compressed decoders, because the uncompressed/decoded classification value was being cast down to a signed byte, when it should be treated as an unsigned byte.

Looking at the original C++ copy of this code, a U8 is used for all of the decoding and reading of the classification byte. These code changes are attempting to produce the equivalent unsigned byte treatment in the java.

@mreutegg
Copy link
Owner

Looks good to me. Thanks for the fix.

@mreutegg mreutegg merged commit 215b867 into mreutegg:master Feb 13, 2023
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

Successfully merging this pull request may close these issues.

2 participants