Fix lossless restart boundary handling in reconstruction - #287
TidalPaladin wants to merge 1 commit into
Conversation
Reset prediction at restart intervals based on pixel index and add a restart-marker regression fixture to guard decoder behavior.
Note that the git override should be removed once image-rs/jpeg-decoder#287 is available in a stable crates.io release.
* Pin jpeg-decoder to restart-boundary fix fork Use a crates.io patch override to pull TidalPaladin/jpeg-decoder branch fix/lossless-restart-boundary-286 and lock the resolved commit. * Document temporary jpeg-decoder fork pin Note that the git override should be removed once image-rs/jpeg-decoder#287 is available in a stable crates.io release.
|
We independently hit this exact bug (before finding this issue/PR) while debugging a rendering failure in dcmnorm, a DICOM toolkit that uses That file has We wrote an equivalent fix independently (tracking restart-marker positions and using them in reconstruction for both the One thing that might be blocking merge: the Given restart intervals are common in mammography JPEG Lossless (at least Hologic uses them), this affects real clinical images beyond synthetic test cases. Would be great to see this merged. |
|
Just chiming in to say that I have also encountered some DICOM images in production that this revision is decoding more reliably. It would be more convenient for this patch to be upstream in the same crate, though considering the status of this crate and that it is unclear when support for JPEG lossless and JPEG extended will be integrated into zune_image, we may need to be open to relying on a self-maintained implementation. |
Motivation
Lossless JPEG scans with restart markers can decode incorrect pixel values if prediction is not reset exactly at restart boundaries.
Solution
Detect restart boundaries from the absolute pixel index and reset predictor initialization at those boundaries. Keep the reconstruction logic aligned across predictor paths with shared indexing helpers.
Changes
Predictor::Raand generic predictor paths..jpg+ expected.png) that exercises lossless restart-marker decoding.Closes #286
Generated with Codex