diff options
-rw-r--r-- | image/codecs/jpeg.cpp | 66 | ||||
-rw-r--r-- | image/codecs/jpeg.h | 60 | ||||
-rw-r--r-- | image/jpeg.cpp | 13 | ||||
-rw-r--r-- | image/jpeg.h | 17 | ||||
-rw-r--r-- | image/module.mk | 1 | ||||
-rw-r--r-- | video/qt_decoder.cpp | 4 |
6 files changed, 28 insertions, 133 deletions
diff --git a/image/codecs/jpeg.cpp b/image/codecs/jpeg.cpp deleted file mode 100644 index 9e8ba5a7d3..0000000000 --- a/image/codecs/jpeg.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "common/system.h" -#include "common/textconsole.h" -#include "graphics/surface.h" -#include "image/jpeg.h" - -#include "image/codecs/jpeg.h" - -namespace Common { -class SeekableReadStream; -} - -namespace Image { - -JPEGCodec::JPEGCodec() : Codec() { - _pixelFormat = g_system->getScreenFormat(); - _surface = NULL; -} - -JPEGCodec::~JPEGCodec() { - if (_surface) { - _surface->free(); - delete _surface; - } -} - -const Graphics::Surface *JPEGCodec::decodeImage(Common::SeekableReadStream *stream) { - JPEGDecoder jpeg; - - if (!jpeg.loadStream(*stream)) { - warning("Failed to decode JPEG frame"); - return 0; - } - - if (_surface) { - _surface->free(); - delete _surface; - } - - _surface = jpeg.getSurface()->convertTo(_pixelFormat); - - return _surface; -} - -} // End of namespace Image diff --git a/image/codecs/jpeg.h b/image/codecs/jpeg.h deleted file mode 100644 index d48604b067..0000000000 --- a/image/codecs/jpeg.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef IMAGE_CODECS_JPEG_H -#define IMAGE_CODECS_JPEG_H - -#include "image/codecs/codec.h" -#include "graphics/pixelformat.h" - -namespace Common { -class SeekableReadStream; -} - -namespace Graphics { -struct Surface; -} - -namespace Image { - -/** - * JPEG decoder. - * - * Used in video: - * - QuickTimeDecoder - */ -class JPEGCodec : public Codec { -public: - JPEGCodec(); - ~JPEGCodec(); - - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); - Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; } - -private: - Graphics::PixelFormat _pixelFormat; - Graphics::Surface *_surface; -}; - -} // End of namespace Image - -#endif diff --git a/image/jpeg.cpp b/image/jpeg.cpp index 9d4b0a7cfe..3602d501be 100644 --- a/image/jpeg.cpp +++ b/image/jpeg.cpp @@ -44,7 +44,7 @@ extern "C" { namespace Image { -JPEGDecoder::JPEGDecoder() : ImageDecoder(), _surface(), _colorSpace(kColorSpaceRGBA) { +JPEGDecoder::JPEGDecoder() : _surface(), _colorSpace(kColorSpaceRGBA) { } JPEGDecoder::~JPEGDecoder() { @@ -59,6 +59,17 @@ void JPEGDecoder::destroy() { _surface.free(); } +const Graphics::Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream *stream) { + if (!loadStream(*stream)) + return 0; + + return getSurface(); +} + +Graphics::PixelFormat JPEGDecoder::getPixelFormat() const { + return _surface.format; +} + #ifdef USE_JPEG namespace { diff --git a/image/jpeg.h b/image/jpeg.h index f578170517..1bf76ecfca 100644 --- a/image/jpeg.h +++ b/image/jpeg.h @@ -26,6 +26,12 @@ * - groovie * - mohawk * - wintermute + * + * Used in image: + * - PICTDecoder + * + * Used in video: + * - QuickTimeDecoder */ #ifndef IMAGE_JPEG_H @@ -33,6 +39,7 @@ #include "graphics/surface.h" #include "image/image_decoder.h" +#include "image/codecs/codec.h" namespace Common { class SeekableReadStream; @@ -40,7 +47,7 @@ class SeekableReadStream; namespace Image { -class JPEGDecoder : public ImageDecoder { +class JPEGDecoder : public ImageDecoder, public Codec { public: JPEGDecoder(); ~JPEGDecoder(); @@ -50,6 +57,10 @@ public: virtual bool loadStream(Common::SeekableReadStream &str); virtual const Graphics::Surface *getSurface() const; + // Codec API + const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + Graphics::PixelFormat getPixelFormat() const; + // Special API for JPEG enum ColorSpace { /** @@ -90,6 +101,6 @@ private: ColorSpace _colorSpace; }; -} // End of Graphics namespace +} // End of namespace Image -#endif // GRAPHICS_JPEG_H +#endif diff --git a/image/module.mk b/image/module.mk index 28d750358d..46129cbde4 100644 --- a/image/module.mk +++ b/image/module.mk @@ -11,7 +11,6 @@ MODULE_OBJS := \ codecs/cdtoons.o \ codecs/cinepak.o \ codecs/indeo3.o \ - codecs/jpeg.o \ codecs/mjpeg.o \ codecs/msrle.o \ codecs/msvideo1.o \ diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp index 25ac05c2b6..20c20d05b1 100644 --- a/video/qt_decoder.cpp +++ b/video/qt_decoder.cpp @@ -40,7 +40,7 @@ // Video codecs #include "image/codecs/cinepak.h" -#include "image/codecs/jpeg.h" +#include "image/jpeg.h" #include "image/codecs/qtrle.h" #include "image/codecs/rpza.h" #include "image/codecs/smc.h" @@ -297,7 +297,7 @@ void QuickTimeDecoder::VideoSampleDesc::initCodec() { break; case MKTAG('j','p','e','g'): // JPEG: Used by some Myst ME 10th Anniversary videos. - _videoCodec = new Image::JPEGCodec(); + _videoCodec = new Image::JPEGDecoder(); break; case MKTAG('Q','k','B','k'): // CDToons: Used by most of the Broderbund games. |