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

CharLS should only use the valid bits from the passed input buffer #26

Closed
vbaderks opened this issue Dec 1, 2016 · 3 comments
Closed
Assignees
Milestone

Comments

@vbaderks
Copy link
Contributor

vbaderks commented Dec 1, 2016

During the encoding process the caller needs to pass the bitPerSample parameter and the buffer with the samples to encode. CharLS will not check if the samples are in the correct range, example:
bitPerSample = 10 (max value = 1014) and passing a sample of 2000.
In the debug build a ASSERT deep down will trigger that a computation failed. As most users use the release build they silently generate bad encoded bit streams.

@vbaderks
Copy link
Contributor Author

Note: the actual solution is going in the direction to apply a bitmask and only use the bits that need to be used and not rely on the fact that the caller ensure that all unused bits are set to zero.

@vbaderks vbaderks modified the milestones: 2.1.0, 2.2.0 Nov 9, 2019
@nroduit
Copy link

nroduit commented Jul 21, 2020

Out of range samples could be a consequence of signed data. We have opened a discussion on the dicom forum about the near-lossless encoding problem.

I think there are two problems:

  1. The conversion of the signed values which changes the range of BitsStored
  2. Possible artifacts with lossy compression and two's complement representation, see JPEG-LS lossy is not adapted to signed data dcm4che/dcm4che#656

As a result, I think that the conversion of signed data to lossy should be banned. However, this problem is outside the scope of the CharLS library.

@vbaderks vbaderks changed the title CharLS should return an error when the input stream contains out of range samples. CharLS should only use the valid bits from the passed input buffer Jan 2, 2021
@vbaderks vbaderks self-assigned this Jan 2, 2021
@vbaderks
Copy link
Contributor Author

vbaderks commented Jan 2, 2021

Commit 6a30e19 adds support to ensure CharLS only uses the bits that are valid from the input buffer.

@vbaderks vbaderks closed this as completed Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants