diff options
author | Matthew Hoops | 2011-05-18 18:23:37 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-05-18 18:23:37 -0400 |
commit | d4c92983920cfe3b25a22d91e12c750e591b917e (patch) | |
tree | c0b63318b9ba0e67528337cfaa21515def1c3962 /graphics | |
parent | 7e2edf16b3e2bf1d2b31999979a60802514df6cb (diff) | |
parent | cf107e24be28c7e6db65b5c7ffed120af4a7994b (diff) | |
download | scummvm-rg350-d4c92983920cfe3b25a22d91e12c750e591b917e.tar.gz scummvm-rg350-d4c92983920cfe3b25a22d91e12c750e591b917e.tar.bz2 scummvm-rg350-d4c92983920cfe3b25a22d91e12c750e591b917e.zip |
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'graphics')
59 files changed, 600 insertions, 167 deletions
diff --git a/graphics/VectorRenderer.cpp b/graphics/VectorRenderer.cpp index e3ca0bf588..4dbcd9845f 100644 --- a/graphics/VectorRenderer.cpp +++ b/graphics/VectorRenderer.cpp @@ -18,9 +18,6 @@ * 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/textconsole.h" diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 9285fa21c5..ec8a8f7245 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -18,9 +18,6 @@ * 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 VECTOR_RENDERER_H diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 3eb8b1345f..a2cb693b78 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -18,9 +18,6 @@ * 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/util.h" diff --git a/graphics/VectorRendererSpec.h b/graphics/VectorRendererSpec.h index 07d37e1847..3ba7d88e4e 100644 --- a/graphics/VectorRendererSpec.h +++ b/graphics/VectorRendererSpec.h @@ -18,9 +18,6 @@ * 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 VECTOR_RENDERER_SPEC_H diff --git a/graphics/colormasks.h b/graphics/colormasks.h index 824d980ca3..2a2523f4b3 100644 --- a/graphics/colormasks.h +++ b/graphics/colormasks.h @@ -18,9 +18,6 @@ * 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_COLORMASKS_H diff --git a/graphics/conversion.cpp b/graphics/conversion.cpp index c9679432fa..713a06ea74 100644 --- a/graphics/conversion.cpp +++ b/graphics/conversion.cpp @@ -17,9 +17,6 @@ * 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 "graphics/conversion.h" diff --git a/graphics/conversion.h b/graphics/conversion.h index 2759f3bb5e..6babc763e2 100644 --- a/graphics/conversion.h +++ b/graphics/conversion.h @@ -18,9 +18,6 @@ * 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_CONVERSION_H diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 8f31421a8b..297b583d54 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -17,9 +17,6 @@ * 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 "graphics/cursorman.h" diff --git a/graphics/cursorman.h b/graphics/cursorman.h index 2f3891aee7..1e7ce83611 100644 --- a/graphics/cursorman.h +++ b/graphics/cursorman.h @@ -17,9 +17,6 @@ * 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_CURSORMAN_H diff --git a/graphics/dither.cpp b/graphics/dither.cpp index 5f423d1c7a..3876db152b 100644 --- a/graphics/dither.cpp +++ b/graphics/dither.cpp @@ -17,9 +17,6 @@ * 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 "graphics/dither.h" diff --git a/graphics/dither.h b/graphics/dither.h index e5f67b9c71..dbde03df82 100644 --- a/graphics/dither.h +++ b/graphics/dither.h @@ -17,9 +17,6 @@ * 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_DITHER_H diff --git a/graphics/font.cpp b/graphics/font.cpp index 7fa39d07db..5f5a9b2fca 100644 --- a/graphics/font.cpp +++ b/graphics/font.cpp @@ -17,9 +17,6 @@ * 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/stream.h" diff --git a/graphics/font.h b/graphics/font.h index 9e6e180ec3..f68f49175f 100644 --- a/graphics/font.h +++ b/graphics/font.h @@ -17,9 +17,6 @@ * 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_FONT_H diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp index bbd75bfca2..f937e55b69 100644 --- a/graphics/fontman.cpp +++ b/graphics/fontman.cpp @@ -17,9 +17,6 @@ * 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 "graphics/font.h" diff --git a/graphics/fontman.h b/graphics/fontman.h index 34b457ae83..d3b84ffa7c 100644 --- a/graphics/fontman.h +++ b/graphics/fontman.h @@ -17,9 +17,6 @@ * 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_FONTMAN_H diff --git a/graphics/fonts/scummfont.cpp b/graphics/fonts/scummfont.cpp index 3331b72c47..1ff1e51fdc 100644 --- a/graphics/fonts/scummfont.cpp +++ b/graphics/fonts/scummfont.cpp @@ -17,9 +17,6 @@ * 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 "graphics/font.h" diff --git a/graphics/fonts/winfont.cpp b/graphics/fonts/winfont.cpp index 7db9a233f6..0e87769f2f 100644 --- a/graphics/fonts/winfont.cpp +++ b/graphics/fonts/winfont.cpp @@ -17,9 +17,6 @@ * 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/file.h" diff --git a/graphics/fonts/winfont.h b/graphics/fonts/winfont.h index c31d45e2ce..b6c1be7064 100644 --- a/graphics/fonts/winfont.h +++ b/graphics/fonts/winfont.h @@ -17,9 +17,6 @@ * 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_WINFONT_H diff --git a/graphics/iff.cpp b/graphics/iff.cpp index fee71de485..4bb971f299 100644 --- a/graphics/iff.cpp +++ b/graphics/iff.cpp @@ -17,9 +17,6 @@ * 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 "graphics/iff.h" diff --git a/graphics/iff.h b/graphics/iff.h index fc837a3ea2..761c57c932 100644 --- a/graphics/iff.h +++ b/graphics/iff.h @@ -17,9 +17,6 @@ * 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$ */ /* diff --git a/graphics/imagedec.cpp b/graphics/imagedec.cpp index f45f0ce5ef..eb595a750e 100644 --- a/graphics/imagedec.cpp +++ b/graphics/imagedec.cpp @@ -17,9 +17,6 @@ * 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 "graphics/imagedec.h" diff --git a/graphics/imagedec.h b/graphics/imagedec.h index 7ea987b1e4..da45ecca4f 100644 --- a/graphics/imagedec.h +++ b/graphics/imagedec.h @@ -17,9 +17,6 @@ * 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_IMAGEDEC_H diff --git a/graphics/jpeg.cpp b/graphics/jpeg.cpp index 70ffb06f6b..c97a540d33 100644 --- a/graphics/jpeg.cpp +++ b/graphics/jpeg.cpp @@ -18,9 +18,6 @@ * 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 "graphics/conversion.h" diff --git a/graphics/jpeg.h b/graphics/jpeg.h index 3e26e9add2..bda0c08240 100644 --- a/graphics/jpeg.h +++ b/graphics/jpeg.h @@ -18,9 +18,6 @@ * 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_JPEG_H diff --git a/graphics/maccursor.cpp b/graphics/maccursor.cpp new file mode 100644 index 0000000000..8ad6c95961 --- /dev/null +++ b/graphics/maccursor.cpp @@ -0,0 +1,182 @@ +/* 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/textconsole.h" + +#include "graphics/maccursor.h" + +namespace Graphics { + +MacCursor::MacCursor() { + _surface = 0; + memset(_palette, 0, 256 * 3); + + _hotspotX = 0; + _hotspotY = 0; +} + +MacCursor::~MacCursor() { + clear(); +} + +void MacCursor::clear() { + delete[] _surface; _surface = 0; + memset(_palette, 0, 256 * 3); +} + +bool MacCursor::readFromStream(Common::SeekableReadStream &stream, bool forceMonochrome) { + clear(); + + // Older Mac CURS monochrome cursors had a set size + // All crsr cursors are larger than this + if (stream.size() == 32 * 2 + 4) + return readFromCURS(stream); + + return readFromCRSR(stream, forceMonochrome); +} + +bool MacCursor::readFromCURS(Common::SeekableReadStream &stream) { + // Grab B/W icon data + _surface = new byte[16 * 16]; + for (int i = 0; i < 32; i++) { + byte imageByte = stream.readByte(); + for (int b = 0; b < 8; b++) + _surface[i * 8 + b] = (byte)((imageByte & (0x80 >> b)) > 0 ? 0 : 1); + } + + // Apply mask data + for (int i = 0; i < 32; i++) { + byte imageByte = stream.readByte(); + for (int b = 0; b < 8; b++) + if ((imageByte & (0x80 >> b)) == 0) + _surface[i * 8 + b] = 0xff; + } + + _hotspotY = stream.readUint16BE(); + _hotspotX = stream.readUint16BE(); + + // Setup a basic palette + _palette[1 * 3 + 0] = 0xff; + _palette[1 * 3 + 1] = 0xff; + _palette[1 * 3 + 2] = 0xff; + + return !stream.eos(); +} + +bool MacCursor::readFromCRSR(Common::SeekableReadStream &stream, bool forceMonochrome) { + stream.readUint16BE(); // type + stream.readUint32BE(); // offset to pixel map + stream.readUint32BE(); // offset to pixel data + stream.readUint32BE(); // expanded cursor data + stream.readUint16BE(); // expanded data depth + stream.readUint32BE(); // reserved + + // Read the B/W data first + if (!readFromCURS(stream)) + return false; + + // Use b/w cursor on backends which don't support cursor palettes + if (forceMonochrome) + return true; + + stream.readUint32BE(); // reserved + stream.readUint32BE(); // cursorID + + // Color version of cursor + stream.readUint32BE(); // baseAddr + + // Keep only lowbyte for now + stream.readByte(); + int iconRowBytes = stream.readByte(); + + if (!iconRowBytes) + return false; + + int iconBounds[4]; + iconBounds[0] = stream.readUint16BE(); + iconBounds[1] = stream.readUint16BE(); + iconBounds[2] = stream.readUint16BE(); + iconBounds[3] = stream.readUint16BE(); + + stream.readUint16BE(); // pmVersion + stream.readUint16BE(); // packType + stream.readUint32BE(); // packSize + + stream.readUint32BE(); // hRes + stream.readUint32BE(); // vRes + + stream.readUint16BE(); // pixelType + stream.readUint16BE(); // pixelSize + stream.readUint16BE(); // cmpCount + stream.readUint16BE(); // cmpSize + + stream.readUint32BE(); // planeByte + stream.readUint32BE(); // pmTable + stream.readUint32BE(); // reserved + + // Pixel data for cursor + int iconDataSize = iconRowBytes * (iconBounds[3] - iconBounds[1]); + byte *iconData = new byte[iconDataSize]; + + if (!iconData) + error("Cannot allocate Mac color cursor iconData"); + + stream.read(iconData, iconDataSize); + + // Color table + stream.readUint32BE(); // ctSeed + stream.readUint16BE(); // ctFlag + uint16 ctSize = stream.readUint16BE() + 1; + + // Read just high byte of 16-bit color + for (int c = 0; c < ctSize; c++) { + stream.readUint16BE(); + _palette[c * 3 + 0] = stream.readUint16BE() >> 8; + _palette[c * 3 + 1] = stream.readUint16BE() >> 8; + _palette[c * 3 + 2] = stream.readUint16BE() >> 8; + } + + int pixelsPerByte = (iconBounds[2] - iconBounds[0]) / iconRowBytes; + int bpp = 8 / pixelsPerByte; + + // build a mask to make sure the pixels are properly shifted out + int bitmask = 0; + for (int m = 0; m < bpp; m++) { + bitmask <<= 1; + bitmask |= 1; + } + + // Extract pixels from bytes + for (int j = 0; j < iconDataSize; j++) { + for (int b = 0; b < pixelsPerByte; b++) { + int idx = j * pixelsPerByte + (pixelsPerByte - 1 - b); + + if (_surface[idx] != 0xff) // if mask is not there + _surface[idx] = (byte)((iconData[j] >> (b * bpp)) & bitmask); + } + } + + delete[] iconData; + return stream.pos() == stream.size(); +} + +} // End of namespace Common diff --git a/graphics/maccursor.h b/graphics/maccursor.h new file mode 100644 index 0000000000..cca7f3456b --- /dev/null +++ b/graphics/maccursor.h @@ -0,0 +1,80 @@ +/* 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. + * + */ + +/** + * @file + * Macintosh cursor decoding used in engines: + * - mohawk + * - sci + * - scumm + */ + +#include "common/stream.h" + +#ifndef GRAPHICS_MACCURSOR_H +#define GRAPHICS_MACCURSOR_H + +namespace Graphics { + +/** + * A Mac crsr or CURS cursor + * TODO: Think about making a base class with WinCursor + */ +class MacCursor { +public: + MacCursor(); + ~MacCursor(); + + /** Return the cursor's width. */ + uint16 getWidth() const { return 16; } + /** Return the cursor's height. */ + uint16 getHeight() const { return 16; } + /** Return the cursor's hotspot's x coordinate. */ + uint16 getHotspotX() const { return _hotspotX; } + /** Return the cursor's hotspot's y coordinate. */ + uint16 getHotspotY() const { return _hotspotY; } + /** Return the cursor's transparent key. */ + byte getKeyColor() const { return 0xFF; } + + const byte *getSurface() const { return _surface; } + const byte *getPalette() const { return _palette; } + + /** Read the cursor's data out of a stream. */ + bool readFromStream(Common::SeekableReadStream &stream, bool forceMonochrome = false); + +private: + bool readFromCURS(Common::SeekableReadStream &stream); + bool readFromCRSR(Common::SeekableReadStream &stream, bool forceMonochrome); + + byte *_surface; + byte _palette[256 * 3]; + + uint16 _hotspotX; ///< The cursor's hotspot's x coordinate. + uint16 _hotspotY; ///< The cursor's hotspot's y coordinate. + + /** Clear the cursor. */ + void clear(); +}; + +} // End of namespace Graphics + +#endif diff --git a/graphics/module.mk b/graphics/module.mk index cb3a07e691..a9051c868a 100644 --- a/graphics/module.mk +++ b/graphics/module.mk @@ -14,6 +14,7 @@ MODULE_OBJS := \ iff.o \ imagedec.o \ jpeg.o \ + maccursor.o \ pict.o \ png.o \ primitives.o \ @@ -24,7 +25,8 @@ MODULE_OBJS := \ thumbnail.o \ VectorRenderer.o \ VectorRendererSpec.o \ - wincursor.o + wincursor.o \ + yuv_to_rgb.o ifdef USE_SCALERS MODULE_OBJS += \ diff --git a/graphics/palette.h b/graphics/palette.h index 14e433f153..7eedb0f78d 100644 --- a/graphics/palette.h +++ b/graphics/palette.h @@ -18,9 +18,6 @@ * 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_PALETTE_H diff --git a/graphics/pict.cpp b/graphics/pict.cpp index acade48515..9779d3231c 100644 --- a/graphics/pict.cpp +++ b/graphics/pict.cpp @@ -18,9 +18,6 @@ * 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/debug.h" diff --git a/graphics/pict.h b/graphics/pict.h index 22f36aafe7..485c88b733 100644 --- a/graphics/pict.h +++ b/graphics/pict.h @@ -18,9 +18,6 @@ * 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_PICT_H diff --git a/graphics/pixelformat.h b/graphics/pixelformat.h index fa45738650..e0cf6ce401 100644 --- a/graphics/pixelformat.h +++ b/graphics/pixelformat.h @@ -18,9 +18,6 @@ * 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_PIXELFORMAT_H diff --git a/graphics/png.cpp b/graphics/png.cpp index 3cdb9f7cca..e6dceab3fa 100644 --- a/graphics/png.cpp +++ b/graphics/png.cpp @@ -18,12 +18,12 @@ * 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 "graphics/png.h" + +#ifdef GRAPHICS_PNG_H + #include "graphics/pixelformat.h" #include "graphics/surface.h" @@ -492,3 +492,5 @@ void PNG::readTransparencyChunk(uint32 chunkLength) { } } // End of Graphics namespace + +#endif // GRAPHICS_PNG_H diff --git a/graphics/png.h b/graphics/png.h index 21e0f35be1..3f8ea85320 100644 --- a/graphics/png.h +++ b/graphics/png.h @@ -18,16 +18,25 @@ * 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$ - * */ /* * PNG decoder used in engines: * - sword25 + * Dependencies: + * - zlib */ +// Currently, only the sword25 engine uses the PNG decoder, so skip compiling +// it if sword25 is not enabled, or if zlib (a required dependency) is not +// enabled. + +#if !(defined(ENABLE_SWORD25) || defined(USE_ZLIB)) + +// Do not compile the PNG decoder code + +#else + #ifndef GRAPHICS_PNG_H #define GRAPHICS_PNG_H @@ -167,3 +176,5 @@ private: } // End of Graphics namespace #endif // GRAPHICS_PNG_H + +#endif // Engine and zlib guard diff --git a/graphics/primitives.cpp b/graphics/primitives.cpp index b98b2cefa5..9834af65ba 100644 --- a/graphics/primitives.cpp +++ b/graphics/primitives.cpp @@ -17,9 +17,6 @@ * 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/util.h" diff --git a/graphics/primitives.h b/graphics/primitives.h index 0c96c1545a..6055404b96 100644 --- a/graphics/primitives.h +++ b/graphics/primitives.h @@ -17,9 +17,6 @@ * 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_PRIMITIVES_H diff --git a/graphics/scaler.cpp b/graphics/scaler.cpp index 304d194a1a..8038e2089e 100644 --- a/graphics/scaler.cpp +++ b/graphics/scaler.cpp @@ -18,9 +18,6 @@ * 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 "graphics/scaler/intern.h" diff --git a/graphics/scaler.h b/graphics/scaler.h index 577a91ccc1..1e5b796631 100644 --- a/graphics/scaler.h +++ b/graphics/scaler.h @@ -17,9 +17,6 @@ * 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_SCALER_H diff --git a/graphics/scaler/2xsai.cpp b/graphics/scaler/2xsai.cpp index 43a5b2fd1d..2afdd9385d 100644 --- a/graphics/scaler/2xsai.cpp +++ b/graphics/scaler/2xsai.cpp @@ -18,9 +18,6 @@ * 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 "graphics/scaler/intern.h" diff --git a/graphics/scaler/Normal2xARM.s b/graphics/scaler/Normal2xARM.s index e75d917567..9afe3f34f0 100644 --- a/graphics/scaler/Normal2xARM.s +++ b/graphics/scaler/Normal2xARM.s @@ -18,9 +18,6 @@ @ 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$ -@ @ @author Robin Watts (robin@wss.co.uk) .text diff --git a/graphics/scaler/aspect.cpp b/graphics/scaler/aspect.cpp index 85768fbced..64a1cd1534 100644 --- a/graphics/scaler/aspect.cpp +++ b/graphics/scaler/aspect.cpp @@ -18,9 +18,6 @@ * 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 "graphics/scaler/intern.h" @@ -79,10 +76,7 @@ static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint1 } } else { while (width--) { - // TODO: We really would like to use interpolate16_5_3, but that - // does not exist (yet), so we use this trick instead. - uint16 tmp = *srcA++; - *dst++ = interpolate16_5_2_1<ColorMask>(*srcB++, tmp, tmp); + *dst++ = interpolate16_5_3<ColorMask>(*srcB++, *srcA++); } } } diff --git a/graphics/scaler/aspect.h b/graphics/scaler/aspect.h index 850b8f0b85..bb354c79ac 100644 --- a/graphics/scaler/aspect.h +++ b/graphics/scaler/aspect.h @@ -17,9 +17,6 @@ * 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_SCALER_ASPECT_H diff --git a/graphics/scaler/downscaler.cpp b/graphics/scaler/downscaler.cpp index 3aad4168f1..fa17490475 100644 --- a/graphics/scaler/downscaler.cpp +++ b/graphics/scaler/downscaler.cpp @@ -18,9 +18,6 @@ * 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 "graphics/scaler/downscaler.h" #include "graphics/scaler/intern.h" diff --git a/graphics/scaler/downscaler.h b/graphics/scaler/downscaler.h index 158b187940..97e55dc3d5 100644 --- a/graphics/scaler/downscaler.h +++ b/graphics/scaler/downscaler.h @@ -18,9 +18,6 @@ * 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_SCALER_DOWNSCALER_H diff --git a/graphics/scaler/downscalerARM.s b/graphics/scaler/downscalerARM.s index 3422e68762..e4662522aa 100644 --- a/graphics/scaler/downscalerARM.s +++ b/graphics/scaler/downscalerARM.s @@ -18,9 +18,6 @@ @ 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$ -@ @ @author Robin Watts (robin@wss.co.uk) .text diff --git a/graphics/scaler/hq2x.cpp b/graphics/scaler/hq2x.cpp index 02c63c8be5..246e8f62d7 100644 --- a/graphics/scaler/hq2x.cpp +++ b/graphics/scaler/hq2x.cpp @@ -18,9 +18,6 @@ * 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 "graphics/scaler/intern.h" diff --git a/graphics/scaler/hq3x.cpp b/graphics/scaler/hq3x.cpp index f588c2ad89..7f7867d5a6 100644 --- a/graphics/scaler/hq3x.cpp +++ b/graphics/scaler/hq3x.cpp @@ -18,9 +18,6 @@ * 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 "graphics/scaler/intern.h" diff --git a/graphics/scaler/intern.h b/graphics/scaler/intern.h index 4addd6d3bd..255cc1a511 100644 --- a/graphics/scaler/intern.h +++ b/graphics/scaler/intern.h @@ -18,9 +18,6 @@ * 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_SCALER_INTERN_H @@ -77,6 +74,16 @@ static inline unsigned interpolate16_3_1(unsigned p1, unsigned p2) { } /** + * Interpolate two 16 bit pixels with weights 5 and 3 and 1, i.e., (5*p1+3*p2)/8. + */ +template<typename ColorMask> +static inline unsigned interpolate16_5_3(unsigned p1, unsigned p2) { + const unsigned lowbits = (((p1 & ColorMask::kLowBits) << 2) + (p1 & ColorMask::kLow3Bits) + + ((p2 & ColorMask::kLow2Bits) << 1) + (p2 & ColorMask::kLow3Bits)) & ColorMask::kLow3Bits; + return ((p1*5 + p2*3) - lowbits) >> 3; +} + +/** * Interpolate two 16 bit pixels with weights 7 and 1, i.e., (7*p1+p2)/8. */ template<typename ColorMask> diff --git a/graphics/scaler/scale2xARM.s b/graphics/scaler/scale2xARM.s index bf4b886bd7..563a22eeb1 100644 --- a/graphics/scaler/scale2xARM.s +++ b/graphics/scaler/scale2xARM.s @@ -18,9 +18,6 @@ @ 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$ -@ @ @author Robin Watts (robin@wss.co.uk) .text diff --git a/graphics/scaler/thumbnail_intern.cpp b/graphics/scaler/thumbnail_intern.cpp index d78648c325..154763070a 100644 --- a/graphics/scaler/thumbnail_intern.cpp +++ b/graphics/scaler/thumbnail_intern.cpp @@ -18,9 +18,6 @@ * 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/endian.h" diff --git a/graphics/sjis.cpp b/graphics/sjis.cpp index caa53a4f63..660abf556c 100644 --- a/graphics/sjis.cpp +++ b/graphics/sjis.cpp @@ -17,9 +17,6 @@ * 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/scummsys.h" diff --git a/graphics/sjis.h b/graphics/sjis.h index 86bc167b52..21ced62b1d 100644 --- a/graphics/sjis.h +++ b/graphics/sjis.h @@ -17,9 +17,6 @@ * 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$ */ // The code in this file is currently only used in KYRA and SCI. diff --git a/graphics/surface.cpp b/graphics/surface.cpp index 88bdcfc822..3f53ce56f4 100644 --- a/graphics/surface.cpp +++ b/graphics/surface.cpp @@ -17,9 +17,6 @@ * 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/algorithm.h" diff --git a/graphics/surface.h b/graphics/surface.h index 1b54690aa9..2a0f71955a 100644 --- a/graphics/surface.h +++ b/graphics/surface.h @@ -17,9 +17,6 @@ * 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_SURFACE_H diff --git a/graphics/thumbnail.cpp b/graphics/thumbnail.cpp index 32ab04ed24..5fad25967e 100644 --- a/graphics/thumbnail.cpp +++ b/graphics/thumbnail.cpp @@ -17,9 +17,6 @@ * 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 "graphics/thumbnail.h" diff --git a/graphics/thumbnail.h b/graphics/thumbnail.h index 0bfeeda2ed..bf48fd1189 100644 --- a/graphics/thumbnail.h +++ b/graphics/thumbnail.h @@ -17,9 +17,6 @@ * 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_THUMBNAIL_H diff --git a/graphics/wincursor.cpp b/graphics/wincursor.cpp index bae64f9303..6208f5f053 100644 --- a/graphics/wincursor.cpp +++ b/graphics/wincursor.cpp @@ -18,9 +18,6 @@ * 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/ptr.h" diff --git a/graphics/wincursor.h b/graphics/wincursor.h index 717a1be588..86693db88b 100644 --- a/graphics/wincursor.h +++ b/graphics/wincursor.h @@ -18,9 +18,6 @@ * 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_WINCURSOR_H diff --git a/graphics/yuv_to_rgb.cpp b/graphics/yuv_to_rgb.cpp new file mode 100644 index 0000000000..831736cd75 --- /dev/null +++ b/graphics/yuv_to_rgb.cpp @@ -0,0 +1,247 @@ +/* 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$ + * + */ + +// The YUV to RGB conversion code is derived from SDL's YUV overlay code, which +// in turn appears to be derived from mpeg_play. The following copyright +// notices have been included in accordance with the original license. Please +// note that the term "software" in this context only applies to the +// buildLookup() and plotYUV*() functions below. + +// Copyright (c) 1995 The Regents of the University of California. +// All rights reserved. +// +// Permission to use, copy, modify, and distribute this software and its +// documentation for any purpose, without fee, and without written agreement is +// hereby granted, provided that the above copyright notice and the following +// two paragraphs appear in all copies of this software. +// +// IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR +// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT +// OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF +// CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, +// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +// AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS +// ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO +// PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +// Copyright (c) 1995 Erik Corry +// All rights reserved. +// +// Permission to use, copy, modify, and distribute this software and its +// documentation for any purpose, without fee, and without written agreement is +// hereby granted, provided that the above copyright notice and the following +// two paragraphs appear in all copies of this software. +// +// IN NO EVENT SHALL ERIK CORRY BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF +// THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ERIK CORRY HAS BEEN ADVISED +// OF THE POSSIBILITY OF SUCH DAMAGE. +// +// ERIK CORRY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" +// BASIS, AND ERIK CORRY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, +// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +// Portions of this software Copyright (c) 1995 Brown University. +// All rights reserved. +// +// Permission to use, copy, modify, and distribute this software and its +// documentation for any purpose, without fee, and without written agreement +// is hereby granted, provided that the above copyright notice and the +// following two paragraphs appear in all copies of this software. +// +// IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE TO ANY PARTY FOR +// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT +// OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF BROWN +// UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// BROWN UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" +// BASIS, AND BROWN UNIVERSITY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, +// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +#include "common/scummsys.h" +#include "common/singleton.h" + +#include "graphics/surface.h" + +namespace Graphics { + +class YUVToRGBLookup { +public: + YUVToRGBLookup(Graphics::PixelFormat format); + ~YUVToRGBLookup(); + + int16 *_colorTab; + uint32 *_rgbToPix; +}; + +YUVToRGBLookup::YUVToRGBLookup(Graphics::PixelFormat format) { + _colorTab = new int16[4 * 256]; // 2048 bytes + + int16 *Cr_r_tab = &_colorTab[0 * 256]; + int16 *Cr_g_tab = &_colorTab[1 * 256]; + int16 *Cb_g_tab = &_colorTab[2 * 256]; + int16 *Cb_b_tab = &_colorTab[3 * 256]; + + _rgbToPix = new uint32[3 * 768]; // 9216 bytes + + uint32 *r_2_pix_alloc = &_rgbToPix[0 * 768]; + uint32 *g_2_pix_alloc = &_rgbToPix[1 * 768]; + uint32 *b_2_pix_alloc = &_rgbToPix[2 * 768]; + + int16 CR, CB; + int i; + + // Generate the tables for the display surface + + for (i = 0; i < 256; i++) { + // Gamma correction (luminescence table) and chroma correction + // would be done here. See the Berkeley mpeg_play sources. + + CR = CB = (i - 128); + Cr_r_tab[i] = (int16) ( (0.419 / 0.299) * CR) + 0 * 768 + 256; + Cr_g_tab[i] = (int16) (-(0.299 / 0.419) * CR) + 1 * 768 + 256; + Cb_g_tab[i] = (int16) (-(0.114 / 0.331) * CB); + Cb_b_tab[i] = (int16) ( (0.587 / 0.331) * CB) + 2 * 768 + 256; + } + + // Set up entries 0-255 in rgb-to-pixel value tables. + for (i = 0; i < 256; i++) { + r_2_pix_alloc[i + 256] = format.RGBToColor(i, 0, 0); + g_2_pix_alloc[i + 256] = format.RGBToColor(0, i, 0); + b_2_pix_alloc[i + 256] = format.RGBToColor(0, 0, i); + } + + // Spread out the values we have to the rest of the array so that we do + // not need to check for overflow. + for (i = 0; i < 256; i++) { + r_2_pix_alloc[i] = r_2_pix_alloc[256]; + r_2_pix_alloc[i + 512] = r_2_pix_alloc[511]; + g_2_pix_alloc[i] = g_2_pix_alloc[256]; + g_2_pix_alloc[i + 512] = g_2_pix_alloc[511]; + b_2_pix_alloc[i] = b_2_pix_alloc[256]; + b_2_pix_alloc[i + 512] = b_2_pix_alloc[511]; + } +} + +YUVToRGBLookup::~YUVToRGBLookup() { + delete[] _rgbToPix; + delete[] _colorTab; +} + +class YUVToRGBManager : public Common::Singleton<YUVToRGBManager> { +public: + const YUVToRGBLookup *getLookup(Graphics::PixelFormat format); + +private: + friend class Common::Singleton<SingletonBaseType>; + YUVToRGBManager(); + ~YUVToRGBManager(); + + Graphics::PixelFormat _lastFormat; + YUVToRGBLookup *_lookup; +}; + +YUVToRGBManager::YUVToRGBManager() { + _lookup = 0; +} + +YUVToRGBManager::~YUVToRGBManager() { + delete _lookup; +} + +const YUVToRGBLookup *YUVToRGBManager::getLookup(Graphics::PixelFormat format) { + if (_lastFormat == format) + return _lookup; + + delete _lookup; + _lookup = new YUVToRGBLookup(format); + _lastFormat = format; + return _lookup; +} + +} // End of namespace Graphics + +DECLARE_SINGLETON(Graphics::YUVToRGBManager); + +#define YUVToRGBMan (Graphics::YUVToRGBManager::instance()) + +namespace Graphics { + +#define PUT_PIXEL(s, d) \ + L = &lookup->_rgbToPix[(s)]; \ + if (dst->format.bytesPerPixel == 2) \ + *((uint16 *)(d)) = (L[cr_r] | L[crb_g] | L[cb_b]); \ + else \ + *((uint32 *)(d)) = (L[cr_r] | L[crb_g] | L[cb_b]) + +void convertYUV420ToRGB(Graphics::Surface *dst, const byte *ySrc, const byte *uSrc, const byte *vSrc, int yWidth, int yHeight, int yPitch, int uvPitch) { + // Sanity checks + assert(dst && dst->pixels); + assert(dst->format.bytesPerPixel == 2 || dst->format.bytesPerPixel == 4); + assert(ySrc && uSrc && vSrc); + assert((yWidth & 1) == 0); + assert((yHeight & 1) == 0); + + const YUVToRGBLookup *lookup = YUVToRGBMan.getLookup(dst->format); + + byte *dstPtr = (byte *)dst->pixels; + + int halfHeight = yHeight >> 1; + int halfWidth = yWidth >> 1; + + for (int h = 0; h < halfHeight; h++) { + for (int w = 0; w < halfWidth; w++) { + register uint32 *L; + + int16 cr_r = lookup->_colorTab[*vSrc + 0 * 256]; + int16 crb_g = lookup->_colorTab[*vSrc + 1 * 256] + lookup->_colorTab[*uSrc + 2 * 256]; + int16 cb_b = lookup->_colorTab[*uSrc + 3 * 256]; + ++uSrc; + ++vSrc; + + PUT_PIXEL(*ySrc, dstPtr); + PUT_PIXEL(*(ySrc + yPitch), dstPtr + dst->pitch); + ySrc++; + dstPtr += dst->format.bytesPerPixel; + PUT_PIXEL(*ySrc, dstPtr); + PUT_PIXEL(*(ySrc + yPitch), dstPtr + dst->pitch); + ySrc++; + dstPtr += dst->format.bytesPerPixel; + } + + dstPtr += dst->pitch; + ySrc += (yPitch << 1) - yWidth; + uSrc += uvPitch - halfWidth; + vSrc += uvPitch - halfWidth; + } +} + +} // End of namespace Graphics diff --git a/graphics/yuv_to_rgb.h b/graphics/yuv_to_rgb.h new file mode 100644 index 0000000000..9b561f2002 --- /dev/null +++ b/graphics/yuv_to_rgb.h @@ -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$ + * + */ + +/** + * @file + * YUV to RGB conversion used in engines: + * - sword25 + */ + +#ifndef GRAPHICS_YUV_TO_RGB_H +#define GRAPHICS_YUV_TO_RGB_H + +#include "common/scummsys.h" +#include "graphics/surface.h" + +namespace Graphics { + +struct Surface; + +/** + * Convert a YUV420 image to an RGB surface + * + * @param dst the destination surface + * @param ySrc the source of the y component + * @param uSrc the source of the u component + * @param vSrc the source of the v component + * @param yWidth the width of the y surface (must be divisible by 2) + * @param yHeight the height of the y surface (must be divisible by 2) + * @param yPitch the pitch of the y surface + * @param uvPitch the pitch of the u and v surfaces + */ +void convertYUV420ToRGB(Graphics::Surface *dst, const byte *ySrc, const byte *uSrc, const byte *vSrc, int yWidth, int yHeight, int yPitch, int uvPitch); + +} // End of namespace Graphics + +#endif |