aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/sci.cpp5
-rw-r--r--graphics/module.mk1
-rw-r--r--graphics/video/avi_decoder.cpp6
-rw-r--r--graphics/video/codecs/msrle.cpp133
-rw-r--r--graphics/video/codecs/msrle.h50
5 files changed, 193 insertions, 2 deletions
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 0bcc299162..60a6b2957e 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -90,11 +90,14 @@ SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc)
SearchMan.addSubDirectoryMatching(_gameDataDir, "actors"); // KQ6 hi-res portraits
SearchMan.addSubDirectoryMatching(_gameDataDir, "aud"); // resource.aud and audio files
SearchMan.addSubDirectoryMatching(_gameDataDir, "avi"); // AVI movie files for Windows versions
- //SearchMan.addSubDirectoryMatching(_gameDataDir, "patches"); // resource patches
SearchMan.addSubDirectoryMatching(_gameDataDir, "seq"); // SEQ movie files for DOS versions
SearchMan.addSubDirectoryMatching(_gameDataDir, "wav"); // speech files in WAV format
SearchMan.addSubDirectoryMatching(_gameDataDir, "sfx"); // music/sound files in WAV format
SearchMan.addSubDirectoryMatching(_gameDataDir, "robot"); // robot files
+
+ // Add the patches directory, except in KQ6; KQ6 comes with broken patches.
+ if (getGameID() != "kq6")
+ SearchMan.addSubDirectoryMatching(_gameDataDir, "patches"); // resource patches
}
SciEngine::~SciEngine() {
diff --git a/graphics/module.mk b/graphics/module.mk
index 97fff5a400..378ec97747 100644
--- a/graphics/module.mk
+++ b/graphics/module.mk
@@ -27,6 +27,7 @@ MODULE_OBJS := \
video/mpeg_player.o \
video/smk_decoder.o \
video/video_player.o \
+ video/codecs/msrle.o \
video/codecs/msvideo1.o \
video/coktelvideo/indeo3.o \
video/coktelvideo/coktelvideo.o
diff --git a/graphics/video/avi_decoder.cpp b/graphics/video/avi_decoder.cpp
index cfc48e20e4..037ea6d9bf 100644
--- a/graphics/video/avi_decoder.cpp
+++ b/graphics/video/avi_decoder.cpp
@@ -37,6 +37,7 @@
// Codecs
#include "graphics/video/codecs/msvideo1.h"
+#include "graphics/video/codecs/msrle.h"
namespace Graphics {
@@ -332,7 +333,8 @@ Surface *AviDecoder::getNextFrame() {
_audStream->queueBuffer(data, chunkSize, DisposeAfterUse::YES, flags);
_fileStream->skip(chunkSize & 1); // Alignment
- } else if (getStreamType(nextTag) == 'dc' || getStreamType(nextTag) == 'id' || getStreamType(nextTag) == 'AM') {
+ } else if (getStreamType(nextTag) == 'dc' || getStreamType(nextTag) == 'id' ||
+ getStreamType(nextTag) == 'AM' || getStreamType(nextTag) == '32') {
// Compressed Frame
_videoInfo.currentFrame++;
uint32 chunkSize = _fileStream->readUint32LE();
@@ -427,6 +429,8 @@ Codec *AviDecoder::createCodec() {
case ID_MSVC:
case ID_WHAM:
return new MSVideo1Decoder(_bmInfo.width, _bmInfo.height, _bmInfo.bitCount);
+ case ID_RLE :
+ return new MSRLEDecoder(_bmInfo.width, _bmInfo.height, _bmInfo.bitCount);
default:
warning ("Unknown/Unhandled compression format \'%s\'", tag2str(_vidsHeader.streamHandler));
}
diff --git a/graphics/video/codecs/msrle.cpp b/graphics/video/codecs/msrle.cpp
new file mode 100644
index 0000000000..64099430d3
--- /dev/null
+++ b/graphics/video/codecs/msrle.cpp
@@ -0,0 +1,133 @@
+/* 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$
+ *
+ */
+
+// Based off ffmpeg's msrledec.c
+
+#include "graphics/video/codecs/msrle.h"
+
+namespace Graphics {
+
+MSRLEDecoder::MSRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) {
+ _surface = new Graphics::Surface();
+ _surface->create(width, height, 1);
+ _bitsPerPixel = bitsPerPixel;
+}
+
+MSRLEDecoder::~MSRLEDecoder() {
+ _surface->free();
+ delete _surface;
+}
+
+Surface *MSRLEDecoder::decodeImage(Common::SeekableReadStream *stream) {
+ if (_bitsPerPixel == 8) {
+ decode8(stream);
+ } else
+ error("Unhandled %d bit Microsoft RLE encoding", _bitsPerPixel);
+
+ return _surface;
+}
+
+void MSRLEDecoder::decode8(Common::SeekableReadStream *stream) {
+
+ int x = 0;
+ int y = _surface->h - 1;
+
+ byte *data = (byte *) _surface->pixels;
+ uint16 width = _surface->w;
+ uint16 height = _surface->h;
+
+ byte *output = data + ((height - 1) * width);
+ byte *output_end = data + ((height) * width);
+
+ while (!stream->eos()) {
+ byte count = stream->readByte();
+ byte value = stream->readByte();
+
+ if (count == 0) {
+ if (value == 0) {
+ // End of line
+
+ x = 0;
+ y--;
+ output = data + (y * width);
+
+ if (y < 0) {
+ warning("Next line is beyond picture bounds");
+ return;
+ }
+
+ } else if (value == 1) {
+ // End of image
+
+ return;
+ } else if (value == 2) {
+ // Skip
+
+ count = stream->readByte();
+ value = stream->readByte();
+
+ y -= value;
+ x += count;
+
+ if (y < 0) {
+ warning("Skip beyond picture bounds");
+ return;
+ }
+
+ output = data + ((y * width) + x);
+
+ } else {
+ // Copy data
+
+ if (output + value > output_end) {
+ stream->skip(value);
+ continue;
+ }
+
+ for (int i = 0; i < value; i++)
+ *output++ = stream->readByte();
+
+ if (value & 1)
+ stream->skip(1);
+
+ x += value;
+ }
+
+ } else {
+ // Run data
+
+ if (output + count > output_end)
+ continue;
+
+ for (int i = 0; i < count; i++, x++)
+ *output++ = value;
+ }
+
+ }
+
+ warning("No end-of-picture code");
+}
+
+} // End of namespace Graphics
diff --git a/graphics/video/codecs/msrle.h b/graphics/video/codecs/msrle.h
new file mode 100644
index 0000000000..634fe754ba
--- /dev/null
+++ b/graphics/video/codecs/msrle.h
@@ -0,0 +1,50 @@
+/* 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 GRAPHICS_MSRLE_H
+#define GRAPHICS_MSRLE_H
+
+#include "graphics/video/codecs/codec.h"
+
+namespace Graphics {
+
+class MSRLEDecoder : public Codec {
+public:
+ MSRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel);
+ ~MSRLEDecoder();
+
+ Surface *decodeImage(Common::SeekableReadStream *stream);
+
+private:
+ byte _bitsPerPixel;
+
+ Surface *_surface;
+
+ void decode8(Common::SeekableReadStream *stream);
+};
+
+} // End of namespace Graphics
+
+#endif