libjpeg-turbo: Corrupt JPEG data: premature end of data segment
Samsung SCX-3200 Series when scanning in JEPG mode intermittently report libjpeg-turbo
error:
Corrupt JPEG data: premature end of data segment
Looking as the issue I found that some JPEG images are "corrupted". (I verified that device is actually sending corrupted JPEG and this is not receiving side error.)
Corruption consists of EOI
JPEG tag (ffd9
) appearing 1 bit earlier than libjpeg-turbo
is expecting. As result libjpeg is assuming lost bit is zero and this is OK (I don't notice corruption on the image). Inserting one zero byte before ffd9
removes the warning message.
- Question is: does someone seen such errors on other deices? How to deal with them assuming that image is not actually looked corrupted.
- (For JPEG experts) Is this an actual JPEG corruption (device bug) or
libjpeg-turbo
bug? Maybe trailing bits are allowed to by skipped by the JPEG standard?