Menu

#513 Abrupt exit if transcoding a 16bit image to 1.2.840.10008.1.2.4.51

3.0.9
closed
None
1
2020-12-11
2020-12-03
No

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-

1 Attachments

Discussion

  • Mathieu Malaterre

    What's the use-case for compression data in range [0, 9535] using 12bits jpeg (lossy) ?

     
  • Mathieu Malaterre

    • assigned_to: Mathieu Malaterre
     
  • Mathieu Malaterre

    [note to self]
    Behavior of dcmtk is quite suprising (compare CT vs MR) using: dcmcjpeg +q 99 --encode-progressive --bits-force-12 ...

     
  • Mathieu Malaterre

    • Priority: 5 --> 1
     
  • Mathieu Malaterre

    OK, nevermind. I think what you want is the error, but not the explicit exit call.

    See fcedc4de5

     
  • Sébastien Jodogne

    Hi, yes, indeed, the problem is with the exit that stops the entire program, it would be fine to receive an error signaling that the image is invalid.

     
  • Mathieu Malaterre

    For reference, 860579d897cf0d087ab9af453f0dcb4fa075b1c9 was tested with:

    #include "gdcmFileChangeTransferSyntax.h"
    #include "gdcmJPEGCodec.h"
    
    int main()
    {
    
      gdcm::FileChangeTransferSyntax change;
      change.SetInputFileName("/tmp/input.dcm");
      change.SetOutputFileName("/tmp/output.dcm");
      change.SetTransferSyntax(gdcm::TransferSyntax::JPEGExtendedProcess2_4);
      gdcm::JPEGCodec *code = (gdcm::JPEGCodec*)change.GetCodec();
      code->SetLossless(false);
      code->SetQuality(99);
      if(!change.Change())return 1;
    
      return 0;
    }
    
     
  • Mathieu Malaterre

    • status: open --> closed
    • Group: 3.1 --> 3.0.9
     

Log in to post a comment.