-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FF 00 found where marker was expected #228
Comments
This is a malformed jpeg file -- some analysis follows. In the file, starting from the hex offset 0x390 (the 912th byte), you'll find the following bytes, near the top'ish of the entropy stream: [23 3A FF FF 00 22 3F ...] Those FF bytes there are the problem. In the spec:
Plainly stated, an FF FF in the stream is invalid. So, the question becomes -- what should we do when we encounter this pattern? I imagine three choices:
I believe jpeg-decoder is doing the right thing here, by throwing an error on the problem, but for the purpose of completeness, let's consider a more lenient approach. In this scenario, only choice 2 actually correctly decodes the stream -- this can be shown by removing the second FF byte, and seeing that the file loads without error. The problem is, from the standpoint of the library, it's completely ambiguous as whether or not deleting the next byte, or virtually inserting an invisible 00 in there is the correct decision to make. Sure, they'll both decode now, but it's ambiguous as to which was the intent of the encoder -- in this case method 3 yields visual artifacts in the decoding. |
This image fails to decode with "FF 00 found where marker was expected", but succeeds in libjpeg-turbo (tested via sxiv), Dolphin, Firefox and VS Code (not sure what library those use):
The text was updated successfully, but these errors were encountered: