mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 07:53:36 +00:00
IMAGE: Merge the JPEG codec into the ImageDecoder
This commit is contained in:
parent
b568ac73b9
commit
c432b96cf6
@ -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
|
@ -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
|
@ -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 {
|
||||
|
||||
|
17
image/jpeg.h
17
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
|
||||
|
@ -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 \
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user