Skip to content

Incompatibilty with non-interleaved JPEG #176

Description

@nolmoonen

JPEG files with non-interleaved scans are not handled correctly:

  1. Lepton files produced by Dropbox' implementation cannot be decoded correctly by this project.
  2. Dropbox' implementation cannot decode Lepton files produced by this project.

To test this, I took cathedral.ppm from https://imagecompression.info/test_images/ and compressed with with cjpeg from libjpeg-turbo (e.g. the libjpeg-turbo-progs package on Ubuntu):

# scan.txt contains "0;1;2;", see https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/doc/wizard.txt
cjpeg -optimize -outfile cathedral.jpg -scans scan.txt cathedral.ppm

cathedral.jpg

I had to zip the Lepton files otherwise I couldn't upload them to GitHub.

I used the current main branch of this project (adf4f4a).

Compressed with Dropbox's implementation (./lepton cathedral.jpg && mv cathedral.lep cathedral_db.lep): cathedral_db.zip.

Decompressing with this project (./lepton_jpeg_util cathedral_db.lep cathedral_db_ms.jpg) gives a greyscale JPEG:
cathedral_db_ms.jpg. It seems that only the first scan is decoded (can be observed by trying some different scan order, e.g. 2;0;1;).

Compressing with this project (./lepton_jpeg_util cathedral.jpg cathedral_ms.lep): cathedral_ms.zip

Decompressing with Dropbox' implementation (./lepton cathedral_ms.lep) reports ASSERTION_FAILURE and fails.

Note that compression and decompression (roundtripping/validating) with the same project does work correctly.

I haven't looked myself in how the produced Lepton files differ, but I assume that the preferred option is to produce the Lepton file similarly to how Dropbox' implementation does it. Otherwise, the Lepton "specification" is expanded and a Lepton file in the wild has two possible ways of decoding. From my experience, non-interleaved JPEG files aren't very common but I suspect that this will appear more often than the math overflow in the Dropbox implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions