diff options
author | Matthew Hoops | 2011-05-31 14:16:29 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-05-31 14:16:29 -0400 |
commit | aa49b38c5a8032586cb94fc4ca07149eecabe64a (patch) | |
tree | ea5c7617f8c482c8cf4141b728b3ccff5a7f84c7 /graphics | |
parent | d3ea9ab2a9334747eb445c1b45aa30cb17ffdf1b (diff) | |
parent | c86a6c466fabe31fbf36363aa8d0ac8ea6001b9f (diff) | |
download | scummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.tar.gz scummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.tar.bz2 scummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.zip |
Merge remote branch 'upstream/master' into t7g-ios
Conflicts:
engines/groovie/script.cpp
Diffstat (limited to 'graphics')
59 files changed, 433 insertions, 245 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..cdf9090625 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" @@ -33,23 +30,23 @@ namespace Graphics { -void free_font(NewFontData* pf); +void free_font(NewFontData *pf); NewFont::~NewFont() { - if (font) { - free_font(font); + if (_font) { + free_font(_font); } } int NewFont::getCharWidth(byte chr) const { // If no width table is specified, return the maximum width - if (!desc.width) - return desc.maxwidth; + if (!_desc.width) + return _desc.maxwidth; // If this character is not included in the font, use the default char. - if (chr < desc.firstchar || desc.firstchar + desc.size < chr) { - chr = desc.defaultchar; + if (chr < _desc.firstchar || _desc.firstchar + _desc.size < chr) { + chr = _desc.defaultchar; } - return desc.width[chr - desc.firstchar]; + return _desc.width[chr - _desc.firstchar]; } @@ -77,38 +74,38 @@ void drawCharIntern(byte *ptr, uint pitch, const bitmap_t *src, int h, int minX, void NewFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const uint32 color) const { assert(dst != 0); - assert(desc.bits != 0 && desc.maxwidth <= 16); + assert(_desc.bits != 0 && _desc.maxwidth <= 16); assert(dst->format.bytesPerPixel == 1 || dst->format.bytesPerPixel == 2); // If this character is not included in the font, use the default char. - if (chr < desc.firstchar || chr >= desc.firstchar + desc.size) { - chr = desc.defaultchar; + if (chr < _desc.firstchar || chr >= _desc.firstchar + _desc.size) { + chr = _desc.defaultchar; } - chr -= desc.firstchar; + chr -= _desc.firstchar; int bbw, bbh, bbx, bby; // Get the bounding box of the character - if (!desc.bbx) { - bbw = desc.fbbw; - bbh = desc.fbbh; - bbx = desc.fbbx; - bby = desc.fbby; + if (!_desc.bbx) { + bbw = _desc.fbbw; + bbh = _desc.fbbh; + bbx = _desc.fbbx; + bby = _desc.fbby; } else { - bbw = desc.bbx[chr].w; - bbh = desc.bbx[chr].h; - bbx = desc.bbx[chr].x; - bby = desc.bbx[chr].y; + bbw = _desc.bbx[chr].w; + bbh = _desc.bbx[chr].h; + bbx = _desc.bbx[chr].x; + bby = _desc.bbx[chr].y; } - byte *ptr = (byte *)dst->getBasePtr(tx + bbx, ty + desc.ascent - bby - bbh); + byte *ptr = (byte *)dst->getBasePtr(tx + bbx, ty + _desc.ascent - bby - bbh); - const bitmap_t *tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * desc.fbbh)); + const bitmap_t *tmp = _desc.bits + (_desc.offset ? _desc.offset[chr] : (chr * _desc.fbbh)); - int y = MIN(bbh, ty + desc.ascent - bby); + int y = MIN(bbh, ty + _desc.ascent - bby); tmp += bbh - y; - y -= MAX(0, ty + desc.ascent - bby - dst->h); + y -= MAX(0, ty + _desc.ascent - bby - dst->h); if (dst->format.bytesPerPixel == 1) drawCharIntern<byte>(ptr, dst->pitch, tmp, y, MAX(0, -(tx + bbx)), MIN(bbw, dst->w - tx - bbx), color); @@ -618,47 +615,47 @@ bool NewFont::cacheFontData(const NewFont &font, const Common::String &filename) return false; } - cacheFile.writeUint16BE(font.desc.maxwidth); - cacheFile.writeUint16BE(font.desc.height); - cacheFile.writeUint16BE(font.desc.fbbw); - cacheFile.writeUint16BE(font.desc.fbbh); - cacheFile.writeSint16BE(font.desc.fbbx); - cacheFile.writeSint16BE(font.desc.fbby); - cacheFile.writeUint16BE(font.desc.ascent); - cacheFile.writeUint16BE(font.desc.firstchar); - cacheFile.writeUint16BE(font.desc.size); - cacheFile.writeUint16BE(font.desc.defaultchar); - cacheFile.writeUint32BE(font.desc.bits_size); + cacheFile.writeUint16BE(font._desc.maxwidth); + cacheFile.writeUint16BE(font._desc.height); + cacheFile.writeUint16BE(font._desc.fbbw); + cacheFile.writeUint16BE(font._desc.fbbh); + cacheFile.writeSint16BE(font._desc.fbbx); + cacheFile.writeSint16BE(font._desc.fbby); + cacheFile.writeUint16BE(font._desc.ascent); + cacheFile.writeUint16BE(font._desc.firstchar); + cacheFile.writeUint16BE(font._desc.size); + cacheFile.writeUint16BE(font._desc.defaultchar); + cacheFile.writeUint32BE(font._desc.bits_size); - for (long i = 0; i < font.desc.bits_size; ++i) { - cacheFile.writeUint16BE(font.desc.bits[i]); + for (long i = 0; i < font._desc.bits_size; ++i) { + cacheFile.writeUint16BE(font._desc.bits[i]); } - if (font.desc.offset) { + if (font._desc.offset) { cacheFile.writeByte(1); - for (int i = 0; i < font.desc.size; ++i) { - cacheFile.writeUint32BE(font.desc.offset[i]); + for (int i = 0; i < font._desc.size; ++i) { + cacheFile.writeUint32BE(font._desc.offset[i]); } } else { cacheFile.writeByte(0); } - if (font.desc.width) { + if (font._desc.width) { cacheFile.writeByte(1); - for (int i = 0; i < font.desc.size; ++i) { - cacheFile.writeByte(font.desc.width[i]); + for (int i = 0; i < font._desc.size; ++i) { + cacheFile.writeByte(font._desc.width[i]); } } else { cacheFile.writeByte(0); } - if (font.desc.bbx) { + if (font._desc.bbx) { cacheFile.writeByte(1); - for (int i = 0; i < font.desc.size; ++i) { - cacheFile.writeByte(font.desc.bbx[i].w); - cacheFile.writeByte(font.desc.bbx[i].h); - cacheFile.writeByte(font.desc.bbx[i].x); - cacheFile.writeByte(font.desc.bbx[i].y); + for (int i = 0; i < font._desc.size; ++i) { + cacheFile.writeByte(font._desc.bbx[i].w); + cacheFile.writeByte(font._desc.bbx[i].h); + cacheFile.writeByte(font._desc.bbx[i].x); + cacheFile.writeByte(font._desc.bbx[i].y); } } else { cacheFile.writeByte(0); diff --git a/graphics/font.h b/graphics/font.h index 9e6e180ec3..7a992674d2 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 @@ -160,15 +157,15 @@ struct NewFontData; class NewFont : public Font { protected: - FontDesc desc; - NewFontData *font; + FontDesc _desc; + NewFontData *_font; public: - NewFont(const FontDesc &d, NewFontData *font_ = 0) : desc(d), font(font_) {} + NewFont(const FontDesc &desc, NewFontData *font = 0) : _desc(desc), _font(font) {} ~NewFont(); - virtual int getFontHeight() const { return desc.height; } - virtual int getMaxCharWidth() const { return desc.maxwidth; } + virtual int getFontHeight() const { return _desc.height; } + virtual int getMaxCharWidth() const { return _desc.maxwidth; } virtual int getCharWidth(byte chr) const; virtual void drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const; 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..4d88148372 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$ */ /* @@ -114,7 +111,7 @@ void decodePBM(Common::ReadStream &input, Surface &surface, byte *colors); * Decode a given PackBits encoded stream. * * PackBits is an RLE compression algorithm introduced by Apple. It is also - * used to encode ILBM and PBM subtypes of IFF files, and some flavours of + * used to encode ILBM and PBM subtypes of IFF files, and some flavors of * TIFF. * * As there is no compression across row boundaries in the above formats, 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 index e086e22fca..8ad6c95961 100644 --- a/graphics/maccursor.cpp +++ b/graphics/maccursor.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/maccursor.h b/graphics/maccursor.h index fac78d97a4..cca7f3456b 100644 --- a/graphics/maccursor.h +++ b/graphics/maccursor.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$ - * */ /** diff --git a/graphics/module.mk b/graphics/module.mk index 59621dc525..a9051c868a 100644 --- a/graphics/module.mk +++ b/graphics/module.mk @@ -25,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..77891c3fdc 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 @@ -58,7 +55,7 @@ public: * @param start the first palette entry to be updated * @param num the number of palette entries to be updated * - * @note It is an error if start+num exceeds 256, behaviour is undefined + * @note It is an error if start+num exceeds 256, behavior is undefined * in that case (the backend may ignore it silently or assert). * @note It is an error if this function gets called when the pixel format * in use (the return value of getScreenFormat) has more than one diff --git a/graphics/pict.cpp b/graphics/pict.cpp index acade48515..80bcb7a71e 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" @@ -327,8 +324,8 @@ void PictDecoder::outputPixelBuffer(byte *&out, byte value, byte bitsPerPixel) { } // Compressed QuickTime details can be found here: -// http://developer.apple.com/documentation/QuickTime/Rm/CompressDecompress/ImageComprMgr/B-Chapter/2TheImageCompression.html -// http://developer.apple.com/documentation/QuickTime/Rm/CompressDecompress/ImageComprMgr/F-Chapter/6WorkingwiththeImage.html +// http://developer.apple.com/legacy/mac/library/#documentation/QuickTime/Rm/CompressDecompress/ImageComprMgr/B-Chapter/2TheImageCompression.html +// http://developer.apple.com/legacy/mac/library/#documentation/QuickTime/Rm/CompressDecompress/ImageComprMgr/F-Chapter/6WorkingwiththeImage.html // I'm just ignoring that because Myst ME uses none of that extra stuff. The offset is always the same. void PictDecoder::decodeCompressedQuickTime(Common::SeekableReadStream *stream) { 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..a35fb9046e 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" @@ -199,7 +196,7 @@ void Normal2x(const uint8 *srcPtr, #else /** - * Trivial nearest-neighbour 2x scaler. + * Trivial nearest-neighbor 2x scaler. */ void Normal2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { @@ -224,7 +221,7 @@ void Normal2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPit #endif /** - * Trivial nearest-neighbour 3x scaler. + * Trivial nearest-neighbor 3x scaler. */ void Normal3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { @@ -257,7 +254,7 @@ void Normal3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPit #define interpolate_1_1_1_1 interpolate16_1_1_1_1<ColorMask> /** - * Trivial nearest-neighbour 1.5x scaler. + * Trivial nearest-neighbor 1.5x scaler. */ template<typename ColorMask> void Normal1o5xTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, 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 85b79ab6cd..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" 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 7317745e62..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 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..cee8e61438 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" @@ -45,8 +42,10 @@ void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) { Graphics::drawLine(x0, y0, x1, y1, color, plotPoint<byte>, this); else if (format.bytesPerPixel == 2) Graphics::drawLine(x0, y0, x1, y1, color, plotPoint<uint16>, this); + else if (format.bytesPerPixel == 4) + Graphics::drawLine(x0, y0, x1, y1, color, plotPoint<uint32>, this); else - error("Surface::drawLine: bytesPerPixel must be 1 or 2"); + error("Surface::drawLine: bytesPerPixel must be 1, 2, or 4"); } void Surface::create(uint16 width, uint16 height, const PixelFormat &f) { @@ -91,12 +90,15 @@ void Surface::hLine(int x, int y, int x2, uint32 color) { if (format.bytesPerPixel == 1) { byte *ptr = (byte *)getBasePtr(x, y); - memset(ptr, (byte)color, x2-x+1); + memset(ptr, (byte)color, x2 - x + 1); } else if (format.bytesPerPixel == 2) { uint16 *ptr = (uint16 *)getBasePtr(x, y); - Common::set_to(ptr, ptr + (x2-x+1), (uint16)color); + Common::set_to(ptr, ptr + (x2 - x + 1), (uint16)color); + } else if (format.bytesPerPixel == 4) { + uint32 *ptr = (uint32 *)getBasePtr(x, y); + Common::set_to(ptr, ptr + (x2 - x + 1), color); } else { - error("Surface::hLine: bytesPerPixel must be 1 or 2"); + error("Surface::hLine: bytesPerPixel must be 1, 2, or 4"); } } @@ -123,10 +125,17 @@ void Surface::vLine(int x, int y, int y2, uint32 color) { uint16 *ptr = (uint16 *)getBasePtr(x, y); while (y++ <= y2) { *ptr = (uint16)color; - ptr += pitch/2; + ptr += pitch / 2; + } + + } else if (format.bytesPerPixel == 4) { + uint32 *ptr = (uint32 *)getBasePtr(x, y); + while (y++ <= y2) { + *ptr = color; + ptr += pitch / 4; } } else { - error("Surface::vLine: bytesPerPixel must be 1 or 2"); + error("Surface::vLine: bytesPerPixel must be 1, 2, or 4"); } } @@ -148,7 +157,7 @@ void Surface::fillRect(Common::Rect r, uint32 color) { } else if (format.bytesPerPixel == 4) { useMemset = false; } else if (format.bytesPerPixel != 1) { - error("Surface::fillRect: bytesPerPixel must be 1, 2 or 4"); + error("Surface::fillRect: bytesPerPixel must be 1, 2, or 4"); } if (useMemset) { @@ -162,7 +171,7 @@ void Surface::fillRect(Common::Rect r, uint32 color) { uint16 *ptr = (uint16 *)getBasePtr(r.left, r.top); while (height--) { Common::set_to(ptr, ptr + width, (uint16)color); - ptr += pitch/2; + ptr += pitch / 2; } } else { uint32 *ptr = (uint32 *)getBasePtr(r.left, r.top); @@ -175,10 +184,10 @@ void Surface::fillRect(Common::Rect r, uint32 color) { } void Surface::frameRect(const Common::Rect &r, uint32 color) { - hLine(r.left, r.top, r.right-1, color); - hLine(r.left, r.bottom-1, r.right-1, color); - vLine(r.left, r.top, r.bottom-1, color); - vLine(r.right-1, r.top, r.bottom-1, color); + hLine(r.left, r.top, r.right - 1, color); + hLine(r.left, r.bottom - 1, r.right - 1, color); + vLine(r.left, r.top, r.bottom - 1, color); + vLine(r.right - 1, r.top, r.bottom - 1, color); } void Surface::move(int dx, int dy, int height) { @@ -186,8 +195,8 @@ void Surface::move(int dx, int dy, int height) { if ((dx == 0 && dy == 0) || height <= 0) return; - if (format.bytesPerPixel != 1 && format.bytesPerPixel != 2) - error("Surface::move: bytesPerPixel must be 1 or 2"); + if (format.bytesPerPixel != 1 && format.bytesPerPixel != 2 && format.bytesPerPixel != 4) + error("Surface::move: bytesPerPixel must be 1, 2, or 4"); byte *src, *dst; int x, y; @@ -226,6 +235,10 @@ void Surface::move(int dx, int dy, int height) { *(uint16 *)dst = *(const uint16 *)src; src -= 2; dst -= 2; + } else if (format.bytesPerPixel == 4) { + *(uint32 *)dst = *(const uint32 *)src; + src -= 4; + dst -= 4; } } src += pitch + (pitch - dx * format.bytesPerPixel); @@ -243,6 +256,10 @@ void Surface::move(int dx, int dy, int height) { *(uint16 *)dst = *(const uint16 *)src; src += 2; dst += 2; + } else if (format.bytesPerPixel == 4) { + *(uint32 *)dst = *(const uint32 *)src; + src += 4; + dst += 4; } } src += pitch - (pitch + dx * format.bytesPerPixel); 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..037ea9a007 --- /dev/null +++ b/graphics/yuv_to_rgb.cpp @@ -0,0 +1,258 @@ +/* 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 = &rgbToPix[(s)]; \ + *((PixelInt *)(d)) = (L[cr_r] | L[crb_g] | L[cb_b]) + +template<typename PixelInt> +void convertYUV420ToRGB(byte *dstPtr, int dstPitch, const YUVToRGBLookup *lookup, const byte *ySrc, const byte *uSrc, const byte *vSrc, int yWidth, int yHeight, int yPitch, int uvPitch) { + int halfHeight = yHeight >> 1; + int halfWidth = yWidth >> 1; + + // Keep the tables in pointers here to avoid a dereference on each pixel + const int16 *Cr_r_tab = lookup->_colorTab; + const int16 *Cr_g_tab = Cr_r_tab + 256; + const int16 *Cb_g_tab = Cr_g_tab + 256; + const int16 *Cb_b_tab = Cb_g_tab + 256; + const uint32 *rgbToPix = lookup->_rgbToPix; + + for (int h = 0; h < halfHeight; h++) { + for (int w = 0; w < halfWidth; w++) { + register const uint32 *L; + + int16 cr_r = Cr_r_tab[*vSrc]; + int16 crb_g = Cr_g_tab[*vSrc] + Cb_g_tab[*uSrc]; + int16 cb_b = Cb_b_tab[*uSrc]; + ++uSrc; + ++vSrc; + + PUT_PIXEL(*ySrc, dstPtr); + PUT_PIXEL(*(ySrc + yPitch), dstPtr + dstPitch); + ySrc++; + dstPtr += sizeof(PixelInt); + PUT_PIXEL(*ySrc, dstPtr); + PUT_PIXEL(*(ySrc + yPitch), dstPtr + dstPitch); + ySrc++; + dstPtr += sizeof(PixelInt); + } + + dstPtr += dstPitch; + ySrc += (yPitch << 1) - yWidth; + uSrc += uvPitch - halfWidth; + vSrc += uvPitch - halfWidth; + } +} + +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); + + // Use a templated function to avoid an if check on every pixel + if (dst->format.bytesPerPixel == 2) + convertYUV420ToRGB<uint16>((byte *)dst->pixels, dst->pitch, lookup, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch); + else + convertYUV420ToRGB<uint32>((byte *)dst->pixels, dst->pitch, lookup, ySrc, uSrc, vSrc, yWidth, yHeight, yPitch, uvPitch); +} + +} // 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 |