diff options
author | Torbjörn Andersson | 2009-12-31 10:13:59 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2009-12-31 10:13:59 +0000 |
commit | 9f2b65888a1fffa4876f02e12371002fa931e563 (patch) | |
tree | 0d6ca2776aafa818b6f1d2afe61e8155e64c09ce /graphics | |
parent | 43f349f4875aabde66414a3b3ba83803b0467a4a (diff) | |
download | scummvm-rg350-9f2b65888a1fffa4876f02e12371002fa931e563.tar.gz scummvm-rg350-9f2b65888a1fffa4876f02e12371002fa931e563.tar.bz2 scummvm-rg350-9f2b65888a1fffa4876f02e12371002fa931e563.zip |
Worked around what appears to be a bad JPEG image in the Masterpiece edition of
Myst. If I dump the image to file, I'm able to read it into other programs,
such as The GIMP, just fine. It seems that the only thing that's missing is the
End Of Image marker, and what everyone else does is to just fake one.
svn-id: r46795
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/jpeg.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/graphics/jpeg.cpp b/graphics/jpeg.cpp index fc3d99ca4a..8ff253fda7 100644 --- a/graphics/jpeg.cpp +++ b/graphics/jpeg.cpp @@ -114,16 +114,41 @@ bool JPEG::read(Common::SeekableReadStream *str) { bool done = false; while (!_str->eos() && ok && !done) { // Read the marker + + // WORKAROUND: While each and every JPEG file should end with + // an EOI (end of image) tag, in reality this may not be the + // case. For instance, at least one image in the Masterpiece + // edition of Myst doesn't, yet other programs are able to read + // the image without complaining. + // + // Apparently, the customary workaround is to insert a fake + // EOI tag. + uint16 marker = _str->readByte(); + bool fakeEOI = false; + + if (_str->eos()) { + fakeEOI = true; + marker = 0xFF; + } + if (marker != 0xFF) { error("JPEG: Invalid marker[0]: 0x%02X", marker); ok = false; break; } - while (marker == 0xFF) + while (marker == 0xFF && !_str->eos()) marker = _str->readByte(); + if (_str->eos()) { + fakeEOI = true; + marker = 0xD9; + } + + if (fakeEOI) + warning("JPEG: Inserted fake EOI"); + // Process the marker data switch (marker) { case 0xC0: // Start Of Frame |