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
EOFException on transcoding of compressed image that is larger when compressed than uncompressed #1411
Comments
Could you provide a sample? Have you tried transcoding with weasis-dicom-tools |
Sample file for use in the reproducer I'm about to upload. |
Hi @nroduit, In trying to reproduce this using the The problem isn't able to be reproduced using the
So we get the scenario where the padding value is a large number due to the compressed pixels being actually larger than the uncompressed pixels, the skip function will skip beyond the file EOF and this will work because of the stated behavior of the FileInputStream skip method. However other InputStreams like for example ServletInputStream will throw an EOFException if you try to skip beyond the end of the stream and hence we see this issue. In the attached reproducer we use the RLE encoded instance that exhibits the condition of being larger compressed than raw. We have a passing test when reading the instance from a FileInputStream, and then a failing test when reading it from different input stream. |
Thanks for the example. Indeed the problem seems to be in the padding part. I've also tested weasis-dicom-tools, which has a transcoding part (which could eventually replace the current implementation) and there doesn't seem to be any transcoding problem with this sample. |
Describe the bug
When reading an instance to transcode that has been compressed such that the resulting pixel item length is greater than the image descriptor length, it leads to an EOFException.
I am trying to process some instances that have been RLE compressed and the compressed pixel data is larger than the input data.
To Reproduce
In the
Transcoder
classIn the normal case reading an uncompressed image, the padding will be 0 or 1.
Reading a compressed image, we would also expect the
unsignedLength()
to be less than theimageDescriptor.getLength()
so this will result in a negative number.In the normal case, this value returned will be a negative number, 0 or 1.
However, if the compressed pixels actually were larger in size than the uncompressed pixels, it would lead to a very large padding value and when the call is made to
skipFully()
it will try to skip a large number of bytes and throw the EOFException.Expected behavior
If the compressed pixel size is larger than the image descriptor length, the dis shouldn't throw an EOFException.
The text was updated successfully, but these errors were encountered: