nvJPEG2000 fails to parse some j2k codestreams

Hello folks,

I’m having difficulties making nvJPEG2000 (tested with v0.3 and v0.4) decode a J2K codestream. Calls to nvjpeg2kStreamParse() fails with error code 3 (NVJPEG2K_STATUS_BAD_JPEG) while it works with some other streams. I can’t see what’s wrong with it (proper header & footer). Also, Openjpeg is able to decode it without any issue.

Any clue ?

I attached a sample of the failing J2K codestream.

test.j2k (5.3 MB)

Hello,

We have tested your test image with OpenJPEG and found that there are two issues at the time of decoding the bitstreams

[INFO] Psot value of the current tile-part is equal to zero, we assuming it is the last tile-part of the codestream.
[WARNING] Stream does not end with EOC

The length of the tile partition which is part of the SOT (start of tile partition) marker is set to 0 for this bitstream. This is allowed by the JPEG 2000 standard under certain conditions. However nvJPEG2000 does not support this in the current release. We can add this in future releases.
The bitstream is also missing the EOC (end of codestream) marker which are the last two bytes of the bitstream.
The work around for now will be to set the length of the tile partition in SOT and include the EOC marker at the end of the j2k bitstream.

Hello,

Thanks a lot for your analysis and sensible answer. I’ll work through the issues you raised and will come back to you with the result.

Note that this codestream originates from medical images in DICOM format. It’s likely that some vendors do not strictly follow the J2K specifications. Supporting those natively in nvJPEG2000 would be very helpful.

Thanks again for taking care of this issue.

1 Like

Hi, bro. Please do let me know if it worked for you. I am just curious to know that because I also facing the same issue.

I have just sorted out this for me, I am creating a resource for embroidery machines that will contain this as a back-end resource. And, mkhadatare explanation really helped me a lot to sort this out.

1 Like