aboutsummaryrefslogtreecommitdiff
path: root/image
diff options
context:
space:
mode:
authorMatthew Hoops2014-02-27 21:27:25 -0500
committerMatthew Hoops2014-02-28 00:32:06 -0500
commit05e9ff136ae059622a0262380be7bc6460d204f0 (patch)
treedc91928bfbb8f00038ea63234fe64402d1efbd5a /image
parent231a02c759169a5c927018699e1533d267ea8372 (diff)
downloadscummvm-rg350-05e9ff136ae059622a0262380be7bc6460d204f0.tar.gz
scummvm-rg350-05e9ff136ae059622a0262380be7bc6460d204f0.tar.bz2
scummvm-rg350-05e9ff136ae059622a0262380be7bc6460d204f0.zip
IMAGE: Share the same pool of codecs between bitmap and AVI
Diffstat (limited to 'image')
-rw-r--r--image/bmp.cpp16
-rw-r--r--image/codecs/codec.cpp77
-rw-r--r--image/codecs/codec.h5
-rw-r--r--image/module.mk1
4 files changed, 90 insertions, 9 deletions
diff --git a/image/bmp.cpp b/image/bmp.cpp
index eb8e300daf..cdf6e4097d 100644
--- a/image/bmp.cpp
+++ b/image/bmp.cpp
@@ -27,7 +27,7 @@
#include "common/textconsole.h"
#include "graphics/pixelformat.h"
#include "graphics/surface.h"
-#include "image/codecs/bmp_raw.h"
+#include "image/codecs/codec.h"
namespace Image {
@@ -93,13 +93,7 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
return false;
}
- uint32 compression = stream.readUint32LE();
-
- if (compression != 0) {
- warning("Compressed bitmaps not supported");
- return false;
- }
-
+ uint32 compression = stream.readUint32BE();
uint32 imageSize = stream.readUint32LE();
/* uint32 pixelsPerMeterX = */ stream.readUint32LE();
/* uint32 pixelsPerMeterY = */ stream.readUint32LE();
@@ -120,11 +114,15 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
}
}
+ // Create the codec (it will warn about unhandled compression)
+ _codec = createBitmapCodec(compression, width, height, bitsPerPixel);
+ if (!_codec)
+ return false;
+
// Grab the frame data
Common::SeekableSubReadStream subStream(&stream, imageOffset, imageOffset + imageSize);
// We only support raw bitmaps for now
- _codec = new BitmapRawDecoder(width, height, bitsPerPixel);
_surface = _codec->decodeFrame(subStream);
return true;
diff --git a/image/codecs/codec.cpp b/image/codecs/codec.cpp
new file mode 100644
index 0000000000..7d4e34320f
--- /dev/null
+++ b/image/codecs/codec.cpp
@@ -0,0 +1,77 @@
+/* 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.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "image/codecs/codec.h"
+
+#include "image/codecs/bmp_raw.h"
+#include "image/codecs/cinepak.h"
+#include "image/codecs/indeo3.h"
+#include "image/codecs/mjpeg.h"
+#include "image/codecs/mpeg.h"
+#include "image/codecs/msvideo1.h"
+#include "image/codecs/msrle.h"
+#include "image/codecs/truemotion1.h"
+
+#include "common/endian.h"
+#include "common/textconsole.h"
+
+namespace Image {
+
+Codec *createBitmapCodec(uint32 tag, int width, int height, int bitsPerPixel) {
+ switch (tag) {
+ case SWAP_CONSTANT_32(0):
+ return new BitmapRawDecoder(width, height, bitsPerPixel);
+ case SWAP_CONSTANT_32(1):
+ return new MSRLEDecoder(width, height, bitsPerPixel);
+ case MKTAG('C','R','A','M'):
+ case MKTAG('m','s','v','c'):
+ case MKTAG('W','H','A','M'):
+ return new MSVideo1Decoder(width, height, bitsPerPixel);
+ case MKTAG('c','v','i','d'):
+ return new CinepakDecoder(bitsPerPixel);
+ case MKTAG('I','V','3','2'):
+ return new Indeo3Decoder(width, height);
+#ifdef VIDEO_CODECS_TRUEMOTION1_H
+ case MKTAG('D','U','C','K'):
+ case MKTAG('d','u','c','k'):
+ return new TrueMotion1Decoder(width, height);
+#endif
+#ifdef USE_MPEG2
+ case MKTAG('m','p','g','2'):
+ return new MPEGDecoder();
+#endif
+ case MKTAG('M','J','P','G'):
+ case MKTAG('m','j','p','g'):
+ return new MJPEGDecoder();
+ default:
+ if (tag & 0x00FFFFFF)
+ warning("Unknown BMP/AVI compression format \'%s\'", tag2str(tag));
+ else
+ warning("Unknown BMP/AVI compression format %d", SWAP_BYTES_32(tag));
+ }
+
+ return 0;
+}
+
+} // End of namespace Image
diff --git a/image/codecs/codec.h b/image/codecs/codec.h
index 092f9754f3..87d6d6b998 100644
--- a/image/codecs/codec.h
+++ b/image/codecs/codec.h
@@ -84,6 +84,11 @@ public:
virtual bool hasDirtyPalette() const { return false; }
};
+/**
+ * Create a codec given a bitmap/AVI compression tag.
+ */
+Codec *createBitmapCodec(uint32 tag, int width, int height, int bitsPerPixel);
+
} // End of namespace Image
#endif
diff --git a/image/module.mk b/image/module.mk
index ab0a2a9a1f..fdf52ec09f 100644
--- a/image/module.mk
+++ b/image/module.mk
@@ -11,6 +11,7 @@ MODULE_OBJS := \
codecs/bmp_raw.o \
codecs/cdtoons.o \
codecs/cinepak.o \
+ codecs/codec.o \
codecs/indeo3.o \
codecs/mjpeg.o \
codecs/msrle.o \