[Scummvm-cvs-logs] SF.net SVN: scummvm:[46795] scummvm/trunk/graphics/jpeg.cpp
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Thu Dec 31 11:13:59 CET 2009
Revision: 46795
http://scummvm.svn.sourceforge.net/scummvm/?rev=46795&view=rev
Author: eriktorbjorn
Date: 2009-12-31 10:13:59 +0000 (Thu, 31 Dec 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
scummvm/trunk/graphics/jpeg.cpp
Modified: scummvm/trunk/graphics/jpeg.cpp
===================================================================
--- scummvm/trunk/graphics/jpeg.cpp 2009-12-31 09:59:44 UTC (rev 46794)
+++ scummvm/trunk/graphics/jpeg.cpp 2009-12-31 10:13:59 UTC (rev 46795)
@@ -114,16 +114,41 @@
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list