thorfdbg / libjpeg

A complete implementation of 10918-1 (JPEG) coming from jpeg.org (the ISO group) with extensions for HDR, lossless and alpha channel coding standardized as ISO/IEC 18477 (JPEG XT).
327 stars 81 forks source link

Decompression failure with lossless huffman #63

Closed scaramallion closed 2 years ago

scaramallion commented 2 years ago

I seem to be unable to correctly decode this JPEG file which appears to be lossless huffman. Compiling the current master and running jpeg A_1465_1.RIGHT_MLO.LJPEG out.ppm gives: mlo

Rather than what it should (apparently) look like, although probably without the red markup: A_1465_1 RIGHT_MLO LJPEG 1_highpass

The proportions are obviously different, but while changing X and Y around in the codestream gives a somewhat recognisable image, it still looks really bad.

Any assistance is appreciated

thorfdbg commented 2 years ago

Am 26.01.22 um 10:26 schrieb scaramallion:

I seem to be unable to correctly decode this JPEG file

Pardon me, but what do you expect? As far as I can tell, there are multiple things wrong about this codestream. You have already observed that width and height are confused, so image dimensions are wrong. Second, it seems it to use incorrect prediction. While it signals a diagonal predictor, it seems to use no prediction at all. You can try that by patching up codestream/predictor.hpp, and replace there the diagonal predictor with no prediction at all. Note, however, that this would be in violation to the standard.

Greetigs, Thomas

scaramallion commented 2 years ago

OK, thanks, I wasn't sure if it was just a dodgy JPEG or something else.

Thanks!