Abrupt exit if transcoding a 16bit image to 1.2.840.10008.1.2.4.51
Cross-platform DICOM implementation
Brought to you by:
malat
Hello,
An user of Orthanc has reported a crash that turns to be an issue within GDCM. If running the following sample with the attached image, the program is abruptly stopped by a call to exit(EXIT_FAILURE) in the file Utilities/gdcmjpeg/jerror.c:
/**
Debian Unstable (gdcm 3.0.7)
$ g++ -I/usr/include/gdcm-3.0/ ./sample.cpp -lgdcmMSFF
$ ./a.out
Ubuntu 18.04 (gdcm 2.8.4)
$ g++ -I/usr/include/gdcm-2.8/ ./sample.cpp -lgdcmMSFF
$ ./a.out
**/
#include <gdcmImageChangeTransferSyntax.h>
#include <gdcmImageReader.h>
#include <stdio.h>
int main()
{
std::ifstream s("70557791-1bb8-4a87-9777-ce10deb45b9a.dcm");
gdcm::ImageReader reader;
reader.SetStream(s);
if (reader.Read())
{
gdcm::ImageChangeTransferSyntax change;
change.SetTransferSyntax(gdcm::TransferSyntax::JPEGExtendedProcess2_4);
change.SetInput(reader.GetImage());
printf("Trying to change the transfer syntax\n");
change.Change();
printf("One never reaches this line\n");
}
return 0;
}
The program stops with error message DCT coefficient out of range. The problem occurs both in GDCM 2.8.4 and GDCM 3.0.7.
Thanks in advance for your support!
Kind Regards,
Sébastien-
What's the use-case for compression data in range [0, 9535] using 12bits jpeg (lossy) ?
[note to self]
Behavior of dcmtk is quite suprising (compare CT vs MR) using: dcmcjpeg +q 99 --encode-progressive --bits-force-12 ...
OK, nevermind. I think what you want is the error, but not the explicit
exitcall.See fcedc4de5
Hi, yes, indeed, the problem is with the
exitthat stops the entire program, it would be fine to receive an error signaling that the image is invalid.For reference, 860579d897cf0d087ab9af453f0dcb4fa075b1c9 was tested with: