[Scummvm-cvs-logs] SF.net SVN: scummvm:[48028] scummvm/trunk/engines/mohawk
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Wed Feb 10 01:20:34 CET 2010
Revision: 48028
http://scummvm.svn.sourceforge.net/scummvm/?rev=48028&view=rev
Author: mthreepwood
Date: 2010-02-10 00:20:33 +0000 (Wed, 10 Feb 2010)
Log Message:
-----------
Add support for the Motion JPEG codec (used in some Myst ME 10th Anniversary videos); minor cleanup.
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/graphics.cpp
scummvm/trunk/engines/mohawk/graphics.h
scummvm/trunk/engines/mohawk/module.mk
scummvm/trunk/engines/mohawk/myst_pict.cpp
scummvm/trunk/engines/mohawk/myst_pict.h
scummvm/trunk/engines/mohawk/video/qt_player.cpp
Added Paths:
-----------
scummvm/trunk/engines/mohawk/jpeg.cpp
scummvm/trunk/engines/mohawk/jpeg.h
Removed Paths:
-------------
scummvm/trunk/engines/mohawk/myst_jpeg.cpp
scummvm/trunk/engines/mohawk/myst_jpeg.h
Modified: scummvm/trunk/engines/mohawk/graphics.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.cpp 2010-02-09 22:37:13 UTC (rev 48027)
+++ scummvm/trunk/engines/mohawk/graphics.cpp 2010-02-10 00:20:33 UTC (rev 48028)
@@ -76,7 +76,8 @@
error("Myst requires greater than 256 colors to run");
if (_vm->getFeatures() & GF_ME) {
- _jpegDecoder = new MystJPEG();
+ // We want to delete our own JPEG surfaces, so don't free after use.
+ _jpegDecoder = new JPEGDecoder(false);
_pictDecoder = new MystPICT(_jpegDecoder);
} else {
_jpegDecoder = NULL;
Modified: scummvm/trunk/engines/mohawk/graphics.h
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.h 2010-02-09 22:37:13 UTC (rev 48027)
+++ scummvm/trunk/engines/mohawk/graphics.h 2010-02-10 00:20:33 UTC (rev 48028)
@@ -27,8 +27,8 @@
#define MOHAWK_GRAPHICS_H
#include "mohawk/bitmap.h"
+#include "mohawk/jpeg.h"
#include "mohawk/livingbooks.h"
-#include "mohawk/myst_jpeg.h"
#include "mohawk/myst_pict.h"
#include "common/file.h"
@@ -104,7 +104,7 @@
MohawkEngine_Myst *_vm;
MystBitmap *_bmpDecoder;
MystPICT *_pictDecoder;
- MystJPEG *_jpegDecoder;
+ JPEGDecoder *_jpegDecoder;
Graphics::PixelFormat _pixelFormat;
struct PictureFile {
Copied: scummvm/trunk/engines/mohawk/jpeg.cpp (from rev 48027, scummvm/trunk/engines/mohawk/myst_jpeg.cpp)
===================================================================
--- scummvm/trunk/engines/mohawk/jpeg.cpp (rev 0)
+++ scummvm/trunk/engines/mohawk/jpeg.cpp 2010-02-10 00:20:33 UTC (rev 48028)
@@ -0,0 +1,87 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/system.h"
+#include "graphics/conversion.h" // For YUV2RGB
+
+#include "mohawk/jpeg.h"
+
+namespace Mohawk {
+
+JPEGDecoder::JPEGDecoder(bool freeSurfaceAfterUse) : Graphics::Codec(), _freeSurfaceAfterUse(freeSurfaceAfterUse) {
+ _jpeg = new Graphics::JPEG();
+ _pixelFormat = g_system->getScreenFormat();
+ _surface = NULL;
+}
+
+JPEGDecoder::~JPEGDecoder() {
+ delete _jpeg;
+
+ if (_surface) {
+ _surface->free();
+ delete _surface;
+ }
+}
+
+Graphics::Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream* stream) {
+ _jpeg->read(stream);
+ Graphics::Surface *ySurface = _jpeg->getComponent(1);
+ Graphics::Surface *uSurface = _jpeg->getComponent(2);
+ Graphics::Surface *vSurface = _jpeg->getComponent(3);
+
+ Graphics::Surface *destSurface = NULL;
+
+ // If we should free the surface after use, use the internal _surface storage
+ // (this should be used when using as a Codec, as the Codecs should free their
+ // surfaces when deleting the Codec object). Otherwise, create a new Surface
+ // as the destination.
+ if (_freeSurfaceAfterUse) {
+ if (!_surface) {
+ _surface = new Graphics::Surface();
+ _surface->create(ySurface->w, ySurface->h, _pixelFormat.bytesPerPixel);
+ }
+ destSurface = _surface;
+ } else {
+ destSurface = new Graphics::Surface();
+ destSurface->create(ySurface->w, ySurface->h, _pixelFormat.bytesPerPixel);
+ }
+
+ assert(destSurface);
+
+ for (uint16 i = 0; i < destSurface->h; i++) {
+ for (uint16 j = 0; j < destSurface->w; j++) {
+ byte r = 0, g = 0, b = 0;
+ Graphics::YUV2RGB(*((byte *)ySurface->getBasePtr(j, i)), *((byte *)uSurface->getBasePtr(j, i)), *((byte *)vSurface->getBasePtr(j, i)), r, g, b);
+ if (_pixelFormat.bytesPerPixel == 2)
+ *((uint16 *)destSurface->getBasePtr(j, i)) = _pixelFormat.RGBToColor(r, g, b);
+ else
+ *((uint32 *)destSurface->getBasePtr(j, i)) = _pixelFormat.RGBToColor(r, g, b);
+ }
+ }
+
+ return destSurface;
+}
+
+} // End of namespace Mohawk
Copied: scummvm/trunk/engines/mohawk/jpeg.h (from rev 48027, scummvm/trunk/engines/mohawk/myst_jpeg.h)
===================================================================
--- scummvm/trunk/engines/mohawk/jpeg.h (rev 0)
+++ scummvm/trunk/engines/mohawk/jpeg.h 2010-02-10 00:20:33 UTC (rev 48028)
@@ -0,0 +1,58 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef MOHAWK_JPEG_H
+#define MOHAWK_JPEG_H
+
+#include "common/scummsys.h"
+#include "common/stream.h"
+
+#include "graphics/video/codecs/codec.h"
+#include "graphics/jpeg.h"
+#include "graphics/pixelformat.h"
+
+namespace Mohawk {
+
+// Mohawk's JPEG Decoder
+// Basically a wrapper around JPEG which converts to RGB and also functions
+// as a Codec.
+
+class JPEGDecoder : public Graphics::Codec {
+public:
+ JPEGDecoder(bool freeSurfaceAfterUse);
+ ~JPEGDecoder();
+
+ Graphics::Surface *decodeImage(Common::SeekableReadStream *stream);
+
+private:
+ Graphics::PixelFormat _pixelFormat;
+ Graphics::JPEG *_jpeg;
+ Graphics::Surface *_surface;
+ bool _freeSurfaceAfterUse;
+};
+
+} // End of namespace Mohawk
+
+#endif
Modified: scummvm/trunk/engines/mohawk/module.mk
===================================================================
--- scummvm/trunk/engines/mohawk/module.mk 2010-02-09 22:37:13 UTC (rev 48027)
+++ scummvm/trunk/engines/mohawk/module.mk 2010-02-10 00:20:33 UTC (rev 48028)
@@ -6,10 +6,10 @@
detection.o \
dialogs.o \
graphics.o \
+ jpeg.o \
livingbooks.o \
mohawk.o \
myst.o \
- myst_jpeg.o \
myst_pict.o \
myst_vars.o \
myst_saveload.o \
Deleted: scummvm/trunk/engines/mohawk/myst_jpeg.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_jpeg.cpp 2010-02-09 22:37:13 UTC (rev 48027)
+++ scummvm/trunk/engines/mohawk/myst_jpeg.cpp 2010-02-10 00:20:33 UTC (rev 48028)
@@ -1,66 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/system.h"
-#include "graphics/conversion.h" // For YUV2RGB
-
-#include "mohawk/myst_jpeg.h"
-
-namespace Mohawk {
-
-MystJPEG::MystJPEG() {
- _jpeg = new Graphics::JPEG();
- _pixelFormat = g_system->getScreenFormat();
-
- // We're going to have to dither if we're running in 8bpp.
- // We'll take RGBA8888 for best color performance in this case.
- if (_pixelFormat.bytesPerPixel == 1)
- _pixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-}
-
-Graphics::Surface *MystJPEG::decodeImage(Common::SeekableReadStream* stream) {
- _jpeg->read(stream);
- Graphics::Surface *ySurface = _jpeg->getComponent(1);
- Graphics::Surface *uSurface = _jpeg->getComponent(2);
- Graphics::Surface *vSurface = _jpeg->getComponent(3);
-
- Graphics::Surface *finalSurface = new Graphics::Surface();
- finalSurface->create(ySurface->w, ySurface->h, _pixelFormat.bytesPerPixel);
-
- for (uint16 i = 0; i < finalSurface->h; i++) {
- for (uint16 j = 0; j < finalSurface->w; j++) {
- byte r = 0, g = 0, b = 0;
- Graphics::YUV2RGB(*((byte *)ySurface->getBasePtr(j, i)), *((byte *)uSurface->getBasePtr(j, i)), *((byte *)vSurface->getBasePtr(j, i)), r, g, b);
- if (_pixelFormat.bytesPerPixel == 2)
- *((uint16 *)finalSurface->getBasePtr(j, i)) = _pixelFormat.RGBToColor(r, g, b);
- else
- *((uint32 *)finalSurface->getBasePtr(j, i)) = _pixelFormat.RGBToColor(r, g, b);
- }
- }
-
- return finalSurface;
-}
-
-} // End of namespace Mohawk
Deleted: scummvm/trunk/engines/mohawk/myst_jpeg.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_jpeg.h 2010-02-09 22:37:13 UTC (rev 48027)
+++ scummvm/trunk/engines/mohawk/myst_jpeg.h 2010-02-10 00:20:33 UTC (rev 48028)
@@ -1,54 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef MYST_JPEG_H
-#define MYST_JPEG_H
-
-#include "common/scummsys.h"
-#include "common/stream.h"
-
-#include "graphics/jpeg.h"
-#include "graphics/pixelformat.h"
-
-namespace Mohawk {
-
-// Myst JPEG Decoder
-// Basically a wrapper around JPEG which converts to RGB
-
-class MystJPEG {
-public:
- MystJPEG();
- ~MystJPEG() { delete _jpeg; }
-
- Graphics::Surface *decodeImage(Common::SeekableReadStream *stream);
-
-private:
- Graphics::PixelFormat _pixelFormat;
- Graphics::JPEG *_jpeg;
-};
-
-}
-
-#endif
Modified: scummvm/trunk/engines/mohawk/myst_pict.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_pict.cpp 2010-02-09 22:37:13 UTC (rev 48027)
+++ scummvm/trunk/engines/mohawk/myst_pict.cpp 2010-02-10 00:20:33 UTC (rev 48028)
@@ -32,7 +32,7 @@
// The PICT code is based off of the QuickDraw specs:
// http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-461.html
-MystPICT::MystPICT(MystJPEG *jpegDecoder) {
+MystPICT::MystPICT(JPEGDecoder *jpegDecoder) {
_jpegDecoder = jpegDecoder;
_pixelFormat = g_system->getScreenFormat();
}
Modified: scummvm/trunk/engines/mohawk/myst_pict.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_pict.h 2010-02-09 22:37:13 UTC (rev 48027)
+++ scummvm/trunk/engines/mohawk/myst_pict.h 2010-02-10 00:20:33 UTC (rev 48028)
@@ -32,18 +32,18 @@
#include "graphics/pixelformat.h"
#include "graphics/surface.h"
-#include "mohawk/myst_jpeg.h"
+#include "mohawk/jpeg.h"
namespace Mohawk {
class MystPICT {
public:
- MystPICT(MystJPEG *jpegDecoder);
+ MystPICT(JPEGDecoder *jpegDecoder);
~MystPICT() {}
Graphics::Surface *decodeImage(Common::SeekableReadStream *stream);
private:
- MystJPEG *_jpegDecoder;
+ JPEGDecoder *_jpegDecoder;
Common::Rect _imageRect;
Graphics::PixelFormat _pixelFormat;
Modified: scummvm/trunk/engines/mohawk/video/qt_player.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/video/qt_player.cpp 2010-02-09 22:37:13 UTC (rev 48027)
+++ scummvm/trunk/engines/mohawk/video/qt_player.cpp 2010-02-10 00:20:33 UTC (rev 48028)
@@ -44,6 +44,7 @@
#include "mohawk/video/qdm2.h"
// Video codecs
+#include "mohawk/jpeg.h"
#include "mohawk/video/cinepak.h"
#include "mohawk/video/qtrle.h"
#include "mohawk/video/rpza.h"
@@ -174,8 +175,8 @@
// Sorenson Video 3: Used by some Myst ME videos.
warning ("Sorenson Video 3 not yet supported");
} else if (codecTag == MKID_BE('jpeg')) {
- // Motion JPEG: Used by some Myst ME videos.
- warning ("Motion JPEG not yet supported");
+ // Motion JPEG: Used by some Myst ME 10th Anniversary videos.
+ return new JPEGDecoder(true);
} else if (codecTag == MKID_BE('QkBk')) {
// CDToons: Used by most of the Broderbund games. This is an unknown format so far.
warning ("CDToons not yet supported");
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