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)
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)