jai-imageio / jai-imageio-jpeg2000

JPEG2000 support for Java Advanced Imaging Image I/O Tools API
Other
73 stars 56 forks source link

Allow up to 3 bytes of padding at the end of stream #33

Closed red1408 closed 3 years ago

red1408 commented 4 years ago

Fix for use with dcm4che: DICOM tags have to have even length and there is no way discern actual encoded data length vs padded (at dcm4che level), so padded length can be fed to decompressor as is. Which it currently can't process.

Since anything less than 4 bytes can't comprise a valid box (need to read box type Int), ignoring up to 3 trailing bytes seems safe.

(also there is no need to recalculate RandomAccessIO.length() multiple times)