Move Mohawk's QuickTime code to graphics/ (and QDM2 to sound, disabled when Mohawk is not enabled) so SCI can use the code.

svn-id: r49165
This commit is contained in:
Matthew Hoops 2010-05-23 18:33:55 +00:00
parent e2a388e2f5
commit 2f31b05651
34 changed files with 326 additions and 329 deletions

View File

@ -30,7 +30,7 @@
#include "mohawk/riven.h"
#include "mohawk/livingbooks.h"
#include "mohawk/sound.h"
#include "mohawk/video/video.h"
#include "mohawk/video.h"
namespace Mohawk {

View File

@ -78,8 +78,7 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : _vm(vm) {
error("Myst requires greater than 256 colors to run");
if (_vm->getFeatures() & GF_ME) {
// We want to delete our own JPEG surfaces, so don't free after use.
_jpegDecoder = new JPEGDecoder(false);
_jpegDecoder = new Graphics::JPEGDecoder();
_pictDecoder = new MystPICT(_jpegDecoder);
} else {
_jpegDecoder = NULL;
@ -152,9 +151,10 @@ void MystGraphics::copyImageSectionToScreen(uint16 image, Common::Rect src, Comm
if (_vm->getFeatures() & GF_ME && _vm->getPlatform() == Common::kPlatformMacintosh && _pictureFile.picFile.isOpen()) {
for (uint32 i = 0; i < _pictureFile.pictureCount; i++)
if (_pictureFile.entries[i].id == image) {
if (_pictureFile.entries[i].type == 0)
surface = _jpegDecoder->decodeImage(new Common::SeekableSubReadStream(&_pictureFile.picFile, _pictureFile.entries[i].offset, _pictureFile.entries[i].offset + _pictureFile.entries[i].size));
else if (_pictureFile.entries[i].type == 1)
if (_pictureFile.entries[i].type == 0) {
Graphics::Surface *jpegSurface = _jpegDecoder->decodeImage(new Common::SeekableSubReadStream(&_pictureFile.picFile, _pictureFile.entries[i].offset, _pictureFile.entries[i].offset + _pictureFile.entries[i].size));
surface->copyFrom(*jpegSurface);
} else if (_pictureFile.entries[i].type == 1)
surface = _pictDecoder->decodeImage(new Common::SeekableSubReadStream(&_pictureFile.picFile, _pictureFile.entries[i].offset, _pictureFile.entries[i].offset + _pictureFile.entries[i].size));
else
error ("Unknown Picture File type %d", _pictureFile.entries[i].type);

View File

@ -27,11 +27,11 @@
#define MOHAWK_GRAPHICS_H
#include "mohawk/bitmap.h"
#include "mohawk/jpeg.h"
#include "mohawk/livingbooks.h"
#include "mohawk/myst_pict.h"
#include "common/file.h"
#include "graphics/video/codecs/mjpeg.h"
namespace Mohawk {
@ -96,8 +96,8 @@ public:
void loadExternalPictureFile(uint16 stack);
void copyImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest);
void copyImageToScreen(uint16 image, Common::Rect dest);
void showCursor(void);
void hideCursor(void);
void showCursor();
void hideCursor();
void changeCursor(uint16);
void drawRect(Common::Rect rect, bool active);
@ -105,7 +105,7 @@ private:
MohawkEngine_Myst *_vm;
MystBitmap *_bmpDecoder;
MystPICT *_pictDecoder;
JPEGDecoder *_jpegDecoder;
Graphics::JPEGDecoder *_jpegDecoder;
Graphics::PixelFormat _pixelFormat;
struct PictureFile {

View File

@ -1,87 +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.
*
* $URL$
* $Id$
*
*/
#include "common/system.h"
#include "graphics/conversion.h" // For YUV2RGB
#include "mohawk/jpeg.h"
namespace Mohawk {
JPEGDecoder::JPEGDecoder(bool freeSurfaceAfterUse) : Graphics::Codec(), _freeSurfaceAfterUse(freeSurfaceAfterUse) {
_jpeg = new Graphics::JPEG();
_pixelFormat = g_system->getScreenFormat();
_surface = NULL;
}
JPEGDecoder::~JPEGDecoder() {
delete _jpeg;
if (_surface) {
_surface->free();
delete _surface;
}
}
Graphics::Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream* stream) {
_jpeg->read(stream);
Graphics::Surface *ySurface = _jpeg->getComponent(1);
Graphics::Surface *uSurface = _jpeg->getComponent(2);
Graphics::Surface *vSurface = _jpeg->getComponent(3);
Graphics::Surface *destSurface = NULL;
// If we should free the surface after use, use the internal _surface storage
// (this should be used when using as a Codec, as the Codecs should free their
// surfaces when deleting the Codec object). Otherwise, create a new Surface
// as the destination.
if (_freeSurfaceAfterUse) {
if (!_surface) {
_surface = new Graphics::Surface();
_surface->create(ySurface->w, ySurface->h, _pixelFormat.bytesPerPixel);
}
destSurface = _surface;
} else {
destSurface = new Graphics::Surface();
destSurface->create(ySurface->w, ySurface->h, _pixelFormat.bytesPerPixel);
}
assert(destSurface);
for (uint16 i = 0; i < destSurface->h; i++) {
for (uint16 j = 0; j < destSurface->w; j++) {
byte r = 0, g = 0, b = 0;
Graphics::YUV2RGB(*((byte *)ySurface->getBasePtr(j, i)), *((byte *)uSurface->getBasePtr(j, i)), *((byte *)vSurface->getBasePtr(j, i)), r, g, b);
if (_pixelFormat.bytesPerPixel == 2)
*((uint16 *)destSurface->getBasePtr(j, i)) = _pixelFormat.RGBToColor(r, g, b);
else
*((uint32 *)destSurface->getBasePtr(j, i)) = _pixelFormat.RGBToColor(r, g, b);
}
}
return destSurface;
}
} // End of namespace Mohawk

View File

@ -6,7 +6,6 @@ MODULE_OBJS = \
detection.o \
dialogs.o \
graphics.o \
jpeg.o \
livingbooks.o \
mohawk.o \
myst.o \
@ -22,13 +21,7 @@ MODULE_OBJS = \
riven_scripts.o \
riven_vars.o \
sound.o \
video/cinepak.o \
video/qdm2.o \
video/qtrle.o \
video/qt_player.o \
video/rpza.o \
video/smc.o \
video/video.o
video.o
# This module can be built as a plugin

View File

@ -35,7 +35,7 @@
#include "mohawk/mohawk.h"
#include "mohawk/dialogs.h"
#include "mohawk/sound.h"
#include "mohawk/video/video.h"
#include "mohawk/video.h"
#include "sound/mixer.h"

View File

@ -33,7 +33,7 @@
#include "mohawk/dialogs.h"
#include "mohawk/resource.h"
#include "mohawk/resource_cache.h"
#include "mohawk/video/video.h"
#include "mohawk/video.h"
namespace Mohawk {

View File

@ -32,7 +32,7 @@ namespace Mohawk {
// The PICT code is based off of the QuickDraw specs:
// http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-461.html
MystPICT::MystPICT(JPEGDecoder *jpegDecoder) {
MystPICT::MystPICT(Graphics::JPEGDecoder *jpegDecoder) {
_jpegDecoder = jpegDecoder;
_pixelFormat = g_system->getScreenFormat();
}
@ -264,9 +264,6 @@ void MystPICT::decodeCompressedQuickTime(Common::SeekableReadStream *stream, Gra
stream->seek(startPos + dataSize);
image->copyFrom(*jpegImage);
jpegImage->free();
delete jpegImage;
}
} // End of namespace Mohawk

View File

@ -32,18 +32,18 @@
#include "graphics/pixelformat.h"
#include "graphics/surface.h"
#include "mohawk/jpeg.h"
#include "graphics/video/codecs/mjpeg.h"
namespace Mohawk {
class MystPICT {
public:
MystPICT(JPEGDecoder *jpegDecoder);
MystPICT(Graphics::JPEGDecoder *jpegDecoder);
~MystPICT() {}
Graphics::Surface *decodeImage(Common::SeekableReadStream *stream);
private:
JPEGDecoder *_jpegDecoder;
Graphics::JPEGDecoder *_jpegDecoder;
Common::Rect _imageRect;
Graphics::PixelFormat _pixelFormat;

View File

@ -27,7 +27,7 @@
#include "mohawk/graphics.h"
#include "mohawk/myst_scripts.h"
#include "mohawk/sound.h"
#include "mohawk/video/video.h"
#include "mohawk/video.h"
#include "gui/message.h"

View File

@ -33,7 +33,7 @@
#include "mohawk/riven_external.h"
#include "mohawk/riven_saveload.h"
#include "mohawk/dialogs.h"
#include "mohawk/video/video.h"
#include "mohawk/video.h"
namespace Mohawk {

View File

@ -27,7 +27,7 @@
#include "mohawk/riven.h"
#include "mohawk/riven_external.h"
#include "mohawk/sound.h"
#include "mohawk/video/video.h"
#include "mohawk/video.h"
#include "gui/message.h"
#include "common/events.h"

View File

@ -28,7 +28,7 @@
#include "mohawk/riven_external.h"
#include "mohawk/riven_scripts.h"
#include "mohawk/sound.h"
#include "mohawk/video/video.h"
#include "mohawk/video.h"
#include "common/stream.h"
#include "graphics/cursorman.h"

View File

@ -24,10 +24,10 @@
*/
#include "mohawk/resource.h"
#include "mohawk/video/video.h"
#include "mohawk/video/qt_player.h"
#include "mohawk/video.h"
#include "common/events.h"
#include "graphics/video/qt_decoder.h"
namespace Mohawk {
@ -316,7 +316,7 @@ VideoHandle VideoManager::createVideoHandle(uint16 id, uint16 x, uint16 y, bool
// Otherwise, create a new entry
VideoEntry entry;
entry.video = new QTPlayer();
entry.video = new Graphics::QuickTimeDecoder();
entry.x = x;
entry.y = y;
entry.filename = "";
@ -346,7 +346,7 @@ VideoHandle VideoManager::createVideoHandle(Common::String filename, uint16 x, u
// Otherwise, create a new entry
VideoEntry entry;
entry.video = new QTPlayer();
entry.video = new Graphics::QuickTimeDecoder();
entry.x = x;
entry.y = y;
entry.filename = filename;

View File

@ -28,6 +28,10 @@
#include "graphics/pixelformat.h"
namespace Graphics {
class QuickTimeDecoder;
}
namespace Mohawk {
class MohawkEngine;
@ -44,10 +48,8 @@ struct MLSTRecord {
uint16 u1;
};
class QTPlayer;
struct VideoEntry {
QTPlayer *video;
Graphics::QuickTimeDecoder *video;
uint16 x;
uint16 y;
bool loop;
@ -55,7 +57,7 @@ struct VideoEntry {
uint16 id; // Riven only
bool enabled;
QTPlayer *operator->() const { assert(video); return video; }
Graphics::QuickTimeDecoder *operator->() const { assert(video); return video; }
};
typedef int32 VideoHandle;

View File

@ -45,13 +45,6 @@ inline static void RGB2YUV(byte r, byte g, byte b, byte &y, byte &u, byte &v) {
v = CLIP<int>( ((r * 512) >> 10) - ((g * 429) >> 10) - ((b * 83) >> 10) + 128, 0, 255);
}
/** Converting a color from YUV to RGB colorspace, Cinepak style. */
inline static void CPYUV2RGB(byte y, byte u, byte v, byte &r, byte &g, byte &b) {
r = CLIP<int>(y + 2 * (v - 128), 0, 255);
g = CLIP<int>(y - (u - 128) / 2 - (v - 128), 0, 255);
b = CLIP<int>(y + 2 * (u - 128), 0, 255);
}
// TODO: generic YUV to RGB blit
/**

View File

@ -25,10 +25,16 @@ MODULE_OBJS := \
video/dxa_decoder.o \
video/flic_decoder.o \
video/mpeg_player.o \
video/qt_decoder.o \
video/smk_decoder.o \
video/video_decoder.o \
video/codecs/cinepak.o \
video/codecs/mjpeg.o \
video/codecs/msrle.o \
video/codecs/msvideo1.o \
video/codecs/qtrle.o \
video/codecs/rpza.o \
video/codecs/smc.o \
video/coktelvideo/indeo3.o \
video/coktelvideo/coktelvideo.o

View File

@ -35,6 +35,7 @@
#include "graphics/video/avi_decoder.h"
// Codecs
#include "graphics/video/codecs/cinepak.h"
#include "graphics/video/codecs/msvideo1.h"
#include "graphics/video/codecs/msrle.h"
@ -379,6 +380,8 @@ Codec *AviDecoder::createCodec() {
return new MSVideo1Decoder(_bmInfo.width, _bmInfo.height, _bmInfo.bitCount);
case ID_RLE :
return new MSRLEDecoder(_bmInfo.width, _bmInfo.height, _bmInfo.bitCount);
case ID_CVID:
return new CinepakDecoder();
default:
warning ("Unknown/Unhandled compression format \'%s\'", tag2str(_vidsHeader.streamHandler));
}

View File

@ -23,32 +23,33 @@
*
*/
#include "mohawk/video/cinepak.h"
#include "graphics/video/codecs/cinepak.h"
#include "common/system.h"
#include "graphics/conversion.h" // For YUV2RGB
// Code here partially based off of ffmpeg ;)
namespace Mohawk {
namespace Graphics {
// Convert a color from YUV to RGB colorspace, Cinepak style.
inline static void CPYUV2RGB(byte y, byte u, byte v, byte &r, byte &g, byte &b) {
r = CLIP<int>(y + 2 * (v - 128), 0, 255);
g = CLIP<int>(y - (u - 128) / 2 - (v - 128), 0, 255);
b = CLIP<int>(y + 2 * (u - 128), 0, 255);
}
#define PUT_PIXEL(offset, lum, u, v) \
Graphics::CPYUV2RGB(lum, u, v, r, g, b); \
CPYUV2RGB(lum, u, v, r, g, b); \
if (_pixelFormat.bytesPerPixel == 2) \
*((uint16 *)_curFrame.surface->pixels + offset) = _pixelFormat.RGBToColor(r, g, b); \
else \
*((uint32 *)_curFrame.surface->pixels + offset) = _pixelFormat.RGBToColor(r, g, b)
CinepakDecoder::CinepakDecoder() : Graphics::Codec() {
CinepakDecoder::CinepakDecoder() : Codec() {
_curFrame.surface = NULL;
_curFrame.strips = NULL;
_y = 0;
_pixelFormat = g_system->getScreenFormat();
// We're going to have to dither if we're running in 8bpp.
// We'll take RGBA8888 for best color performance in this case.
if (_pixelFormat.bytesPerPixel == 1)
_pixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
}
CinepakDecoder::~CinepakDecoder() {
@ -57,7 +58,7 @@ CinepakDecoder::~CinepakDecoder() {
delete[] _curFrame.strips;
}
Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream *stream) {
Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream *stream) {
_curFrame.flags = stream->readByte();
_curFrame.length = (stream->readByte() << 16) + stream->readUint16BE();
_curFrame.width = stream->readUint16BE();
@ -79,7 +80,7 @@ Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream *strea
#endif
if (!_curFrame.surface) {
_curFrame.surface = new Graphics::Surface();
_curFrame.surface = new Surface();
_curFrame.surface->create(_curFrame.width, _curFrame.height, _pixelFormat.bytesPerPixel);
}
@ -283,4 +284,4 @@ void CinepakDecoder::decodeVectors(Common::SeekableReadStream *stream, uint16 st
}
}
} // End of namespace Mohawk
} // End of namespace Graphics

View File

@ -23,8 +23,8 @@
*
*/
#ifndef CINEPAK_H
#define CINEPAK_H
#ifndef GRAPHICS_CINEPAK_H
#define GRAPHICS_CINEPAK_H
#include "common/scummsys.h"
#include "common/stream.h"
@ -34,7 +34,7 @@
#include "graphics/video/codecs/codec.h"
namespace Mohawk {
namespace Graphics {
struct CinepakCodebook {
byte y[4];
@ -56,26 +56,26 @@ struct CinepakFrame {
uint16 stripCount;
CinepakStrip *strips;
Graphics::Surface *surface;
Surface *surface;
};
class CinepakDecoder : public Graphics::Codec {
class CinepakDecoder : public Codec {
public:
CinepakDecoder();
~CinepakDecoder();
Graphics::Surface *decodeImage(Common::SeekableReadStream *stream);
Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
Surface *decodeImage(Common::SeekableReadStream *stream);
PixelFormat getPixelFormat() const { return _pixelFormat; }
private:
CinepakFrame _curFrame;
int32 _y;
Graphics::PixelFormat _pixelFormat;
PixelFormat _pixelFormat;
void loadCodebook(Common::SeekableReadStream *stream, uint16 strip, byte codebookType, byte chunkID, uint32 chunkSize);
void decodeVectors(Common::SeekableReadStream *stream, uint16 strip, byte chunkID, uint32 chunkSize);
};
}
} // End of namespace Graphics
#endif

View File

@ -0,0 +1,73 @@
/* 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$
*
*/
#include "common/system.h"
#include "graphics/conversion.h" // For YUV2RGB
#include "graphics/video/codecs/mjpeg.h"
namespace Graphics {
JPEGDecoder::JPEGDecoder() : Codec() {
_jpeg = new JPEG();
_pixelFormat = g_system->getScreenFormat();
_surface = NULL;
}
JPEGDecoder::~JPEGDecoder() {
delete _jpeg;
if (_surface) {
_surface->free();
delete _surface;
}
}
Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream* stream) {
_jpeg->read(stream);
Surface *ySurface = _jpeg->getComponent(1);
Surface *uSurface = _jpeg->getComponent(2);
Surface *vSurface = _jpeg->getComponent(3);
if (!_surface) {
_surface = new Surface();
_surface->create(ySurface->w, ySurface->h, _pixelFormat.bytesPerPixel);
}
for (uint16 i = 0; i < _surface->h; i++) {
for (uint16 j = 0; j < _surface->w; j++) {
byte r = 0, g = 0, b = 0;
YUV2RGB(*((byte *)ySurface->getBasePtr(j, i)), *((byte *)uSurface->getBasePtr(j, i)), *((byte *)vSurface->getBasePtr(j, i)), r, g, b);
if (_pixelFormat.bytesPerPixel == 2)
*((uint16 *)_surface->getBasePtr(j, i)) = _pixelFormat.RGBToColor(r, g, b);
else
*((uint32 *)_surface->getBasePtr(j, i)) = _pixelFormat.RGBToColor(r, g, b);
}
}
return _surface;
}
} // End of namespace Graphics

View File

@ -23,8 +23,8 @@
*
*/
#ifndef MOHAWK_JPEG_H
#define MOHAWK_JPEG_H
#ifndef GRAPHICS_MJPEG_H
#define GRAPHICS_MJPEG_H
#include "common/scummsys.h"
#include "common/stream.h"
@ -33,27 +33,26 @@
#include "graphics/jpeg.h"
#include "graphics/pixelformat.h"
namespace Mohawk {
namespace Graphics {
// Mohawk's JPEG Decoder
// Motion JPEG Decoder
// Basically a wrapper around JPEG which converts to RGB and also functions
// as a Codec.
class JPEGDecoder : public Graphics::Codec {
class JPEGDecoder : public Codec {
public:
JPEGDecoder(bool freeSurfaceAfterUse);
JPEGDecoder();
~JPEGDecoder();
Graphics::Surface *decodeImage(Common::SeekableReadStream *stream);
Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
Surface *decodeImage(Common::SeekableReadStream *stream);
PixelFormat getPixelFormat() const { return _pixelFormat; }
private:
Graphics::PixelFormat _pixelFormat;
Graphics::JPEG *_jpeg;
Graphics::Surface *_surface;
bool _freeSurfaceAfterUse;
PixelFormat _pixelFormat;
JPEG *_jpeg;
Surface *_surface;
};
} // End of namespace Mohawk
} // End of namespace Graphics
#endif

View File

@ -26,7 +26,7 @@
// QuickTime RLE Decoder
// Based off ffmpeg's QuickTime RLE decoder (written by Mike Melanson)
#include "mohawk/video/qtrle.h"
#include "graphics/video/codecs/qtrle.h"
#include "common/scummsys.h"
#include "common/stream.h"
@ -34,9 +34,9 @@
#include "graphics/colormasks.h"
#include "graphics/surface.h"
namespace Mohawk {
namespace Graphics {
QTRLEDecoder::QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) : Graphics::Codec() {
QTRLEDecoder::QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) : Codec() {
_bitsPerPixel = bitsPerPixel;
_pixelFormat = g_system->getScreenFormat();
@ -47,7 +47,7 @@ QTRLEDecoder::QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) : Gra
debug(2, "QTRLE corrected width: %d", width);
_surface = new Graphics::Surface();
_surface = new Surface();
_surface->create(width, height, _bitsPerPixel <= 8 ? 1 : _pixelFormat.bytesPerPixel);
}
@ -239,7 +239,7 @@ void QTRLEDecoder::decode16(Common::SeekableReadStream *stream, uint32 rowPtr, u
while (rleCode--) {
// Convert from RGB555 to the format specified by the Overlay
byte r = 0, g = 0, b = 0;
Graphics::colorToRGB<Graphics::ColorMasks<555> >(rgb16, r, g, b);
colorToRGB<ColorMasks<555> >(rgb16, r, g, b);
rgb[pixelPtr++] = _pixelFormat.RGBToColor(r, g, b);
}
} else {
@ -252,7 +252,7 @@ void QTRLEDecoder::decode16(Common::SeekableReadStream *stream, uint32 rowPtr, u
// Convert from RGB555 to the format specified by the Overlay
byte r = 0, g = 0, b = 0;
Graphics::colorToRGB<Graphics::ColorMasks<555> >(rgb16, r, g, b);
colorToRGB<ColorMasks<555> >(rgb16, r, g, b);
rgb[pixelPtr++] = _pixelFormat.RGBToColor(r, g, b);
}
}
@ -354,7 +354,7 @@ void QTRLEDecoder::decode32(Common::SeekableReadStream *stream, uint32 rowPtr, u
}
}
Graphics::Surface *QTRLEDecoder::decodeImage(Common::SeekableReadStream *stream) {
Surface *QTRLEDecoder::decodeImage(Common::SeekableReadStream *stream) {
uint16 start_line = 0;
uint16 height = _surface->h;
@ -417,4 +417,4 @@ QTRLEDecoder::~QTRLEDecoder() {
_surface->free();
}
} // End of namespace Mohawk
} // End of namespace Graphics

View File

@ -23,27 +23,27 @@
*
*/
#ifndef MOHAWK_QTRLE_H
#define MOHAWK_QTRLE_H
#ifndef GRAPHICS_VIDEO_QTRLE_H
#define GRAPHICS_VIDEO_QTRLE_H
#include "graphics/pixelformat.h"
#include "graphics/video/codecs/codec.h"
namespace Mohawk {
namespace Graphics {
class QTRLEDecoder : public Graphics::Codec {
class QTRLEDecoder : public Codec {
public:
QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel);
~QTRLEDecoder();
Graphics::Surface *decodeImage(Common::SeekableReadStream *stream);
Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
Surface *decodeImage(Common::SeekableReadStream *stream);
PixelFormat getPixelFormat() const { return _pixelFormat; }
private:
byte _bitsPerPixel;
Graphics::Surface *_surface;
Graphics::PixelFormat _pixelFormat;
Surface *_surface;
PixelFormat _pixelFormat;
void decode1(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange);
void decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange, byte bpp);
@ -53,6 +53,6 @@ private:
void decode32(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange);
};
} // End of namespace Mohawk
} // End of namespace Graphics
#endif

View File

@ -25,14 +25,14 @@
// Based off ffmpeg's RPZA decoder
#include "mohawk/video/rpza.h"
#include "graphics/video/codecs/rpza.h"
#include "common/system.h"
#include "graphics/colormasks.h"
namespace Mohawk {
namespace Graphics {
RPZADecoder::RPZADecoder(uint16 width, uint16 height) : Graphics::Codec() {
RPZADecoder::RPZADecoder(uint16 width, uint16 height) : Codec() {
_pixelFormat = g_system->getScreenFormat();
// We need to increase the surface size to a multiple of 4
@ -42,7 +42,7 @@ RPZADecoder::RPZADecoder(uint16 width, uint16 height) : Graphics::Codec() {
debug(2, "RPZA corrected width: %d", width);
_surface = new Graphics::Surface();
_surface = new Surface();
_surface->create(width, height, _pixelFormat.bytesPerPixel);
}
@ -60,7 +60,7 @@ RPZADecoder::RPZADecoder(uint16 width, uint16 height) : Graphics::Codec() {
#define PUT_PIXEL(color) \
if ((int32)blockPtr < _surface->w * _surface->h) { \
byte r = 0, g = 0, b = 0; \
Graphics::colorToRGB<Graphics::ColorMasks<555> >(color, r, g, b); \
colorToRGB<ColorMasks<555> >(color, r, g, b); \
if (_pixelFormat.bytesPerPixel == 2) \
*((uint16 *)_surface->pixels + blockPtr) = _pixelFormat.RGBToColor(r, g, b); \
else \
@ -68,7 +68,7 @@ RPZADecoder::RPZADecoder(uint16 width, uint16 height) : Graphics::Codec() {
} \
blockPtr++
Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *stream) {
Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *stream) {
uint16 colorA = 0, colorB = 0;
uint16 color4[4];
@ -205,4 +205,4 @@ Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *stream)
return _surface;
}
} // End of namespace Mohawk
} // End of namespace Graphics

View File

@ -23,27 +23,27 @@
*
*/
#ifndef MOHAWK_RPZA_H
#define MOHAWK_RPZA_H
#ifndef GRAPHICS_VIDEO_RPZA_H
#define GRAPHICS_VIDEO_RPZA_H
#include "graphics/pixelformat.h"
#include "graphics/video/codecs/codec.h"
namespace Mohawk {
namespace Graphics {
class RPZADecoder : public Graphics::Codec {
class RPZADecoder : public Codec {
public:
RPZADecoder(uint16 width, uint16 height);
~RPZADecoder() { delete _surface; }
Graphics::Surface *decodeImage(Common::SeekableReadStream *stream);
Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
Surface *decodeImage(Common::SeekableReadStream *stream);
PixelFormat getPixelFormat() const { return _pixelFormat; }
private:
Graphics::Surface *_surface;
Graphics::PixelFormat _pixelFormat;
Surface *_surface;
PixelFormat _pixelFormat;
};
} // End of namespace Mohawk
} // End of namespace Graphics
#endif

View File

@ -25,9 +25,9 @@
// Based off ffmpeg's SMC decoder
#include "mohawk/video/smc.h"
#include "graphics/video/codecs/smc.h"
namespace Mohawk {
namespace Graphics {
#define GET_BLOCK_COUNT() \
(opcode & 0x10) ? (1 + stream->readByte()) : 1 + (opcode & 0x0F);
@ -382,4 +382,4 @@ Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *stream) {
return _surface;
}
} // End of namespace Mohawk
} // End of namespace Graphics

View File

@ -23,12 +23,12 @@
*
*/
#ifndef MOHAWK_VIDEO_SMC_H
#define MOHAWK_VIDEO_SMC_H
#ifndef GRAPHICS_VIDEO_SMC_H
#define GRAPHICS_VIDEO_SMC_H
#include "graphics/video/codecs/codec.h"
namespace Mohawk {
namespace Graphics {
enum {
CPAIR = 2,
@ -37,16 +37,16 @@ enum {
COLORS_PER_TABLE = 256
};
class SMCDecoder : public Graphics::Codec {
class SMCDecoder : public Codec {
public:
SMCDecoder(uint16 width, uint16 height);
~SMCDecoder() { delete _surface; }
Graphics::Surface *decodeImage(Common::SeekableReadStream *stream);
Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat::createFormatCLUT8(); }
Surface *decodeImage(Common::SeekableReadStream *stream);
PixelFormat getPixelFormat() const { return PixelFormat::createFormatCLUT8(); }
private:
Graphics::Surface *_surface;
Surface *_surface;
// SMC color tables
byte _colorPairs[COLORS_PER_TABLE * CPAIR];
@ -54,6 +54,6 @@ private:
byte _colorOctets[COLORS_PER_TABLE * COCTET];
};
} // End of namespace Mohawk
} // End of namespace Graphics
#endif

View File

@ -31,7 +31,7 @@
// Seek function by Gael Chardon gael.dev@4now.net
//
#include "mohawk/video/qt_player.h"
#include "graphics/video/qt_decoder.h"
#include "common/debug.h"
#include "common/endian.h"
@ -41,22 +41,22 @@
// Audio codecs
#include "sound/decoders/adpcm.h"
#include "sound/decoders/raw.h"
#include "mohawk/video/qdm2.h"
#include "sound/decoders/qdm2.h"
// Video codecs
#include "mohawk/jpeg.h"
#include "mohawk/video/cinepak.h"
#include "mohawk/video/qtrle.h"
#include "mohawk/video/rpza.h"
#include "mohawk/video/smc.h"
#include "graphics/video/codecs/cinepak.h"
#include "graphics/video/codecs/mjpeg.h"
#include "graphics/video/codecs/qtrle.h"
#include "graphics/video/codecs/rpza.h"
#include "graphics/video/codecs/smc.h"
namespace Mohawk {
namespace Graphics {
////////////////////////////////////////////
// QTPlayer
// QuickTimeDecoder
////////////////////////////////////////////
QTPlayer::QTPlayer() : Graphics::VideoDecoder() {
QuickTimeDecoder::QuickTimeDecoder() : VideoDecoder() {
_audStream = NULL;
_beginOffset = 0;
_videoCodec = NULL;
@ -69,53 +69,53 @@ QTPlayer::QTPlayer() : Graphics::VideoDecoder() {
_dirtyPalette = false;
}
QTPlayer::~QTPlayer() {
QuickTimeDecoder::~QuickTimeDecoder() {
close();
}
uint16 QTPlayer::getWidth() const {
uint16 QuickTimeDecoder::getWidth() const {
if (_videoStreamIndex < 0)
return 0;
return _streams[_videoStreamIndex]->width / getScaleMode();
}
uint16 QTPlayer::getHeight() const {
uint16 QuickTimeDecoder::getHeight() const {
if (_videoStreamIndex < 0)
return 0;
return _streams[_videoStreamIndex]->height / getScaleMode();
}
uint32 QTPlayer::getFrameCount() const {
uint32 QuickTimeDecoder::getFrameCount() const {
if (_videoStreamIndex < 0)
return 0;
return _streams[_videoStreamIndex]->nb_frames;
}
byte QTPlayer::getBitsPerPixel() {
byte QuickTimeDecoder::getBitsPerPixel() {
if (_videoStreamIndex < 0)
return 0;
return _streams[_videoStreamIndex]->bits_per_sample & 0x1F;
}
uint32 QTPlayer::getCodecTag() {
uint32 QuickTimeDecoder::getCodecTag() {
if (_videoStreamIndex < 0)
return 0;
return _streams[_videoStreamIndex]->codec_tag;
}
ScaleMode QTPlayer::getScaleMode() const {
ScaleMode QuickTimeDecoder::getScaleMode() const {
if (_videoStreamIndex < 0)
return kScaleNormal;
return (ScaleMode)(_scaleMode * _streams[_videoStreamIndex]->scaleMode);
}
uint32 QTPlayer::getFrameDuration() {
uint32 QuickTimeDecoder::getFrameDuration() {
if (_videoStreamIndex < 0)
return 0;
@ -133,14 +133,14 @@ uint32 QTPlayer::getFrameDuration() {
return 0;
}
Graphics::PixelFormat QTPlayer::getPixelFormat() const {
PixelFormat QuickTimeDecoder::getPixelFormat() const {
if (!_videoCodec)
return Graphics::PixelFormat::createFormatCLUT8();
return PixelFormat::createFormatCLUT8();
return _videoCodec->getPixelFormat();
}
void QTPlayer::rewind() {
void QuickTimeDecoder::rewind() {
delete _videoCodec; _videoCodec = NULL;
_curFrame = -1;
_startTime = _nextFrameStartTime = 0;
@ -154,7 +154,7 @@ void QTPlayer::rewind() {
startAudio();
}
Graphics::Codec *QTPlayer::createCodec(uint32 codecTag, byte bitsPerPixel) {
Codec *QuickTimeDecoder::createCodec(uint32 codecTag, byte bitsPerPixel) {
if (codecTag == MKID_BE('cvid')) {
// Cinepak: As used by most Myst and all Riven videos as well as some Myst ME videos. "The Chief" videos also use this.
return new CinepakDecoder();
@ -175,7 +175,7 @@ Graphics::Codec *QTPlayer::createCodec(uint32 codecTag, byte bitsPerPixel) {
warning ("Sorenson Video 3 not yet supported");
} else if (codecTag == MKID_BE('jpeg')) {
// Motion JPEG: Used by some Myst ME 10th Anniversary videos.
return new JPEGDecoder(true);
return new JPEGDecoder();
} else if (codecTag == MKID_BE('QkBk')) {
// CDToons: Used by most of the Broderbund games. This is an unknown format so far.
warning ("CDToons not yet supported");
@ -186,24 +186,24 @@ Graphics::Codec *QTPlayer::createCodec(uint32 codecTag, byte bitsPerPixel) {
return NULL;
}
void QTPlayer::startAudio() {
void QuickTimeDecoder::startAudio() {
if (_audStream) // No audio/audio not supported
g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_audHandle, _audStream);
}
void QTPlayer::stopAudio() {
void QuickTimeDecoder::stopAudio() {
if (_audStream) {
g_system->getMixer()->stopHandle(_audHandle);
_audStream = NULL; // the mixer automatically frees the stream
}
}
void QTPlayer::pauseVideoIntern(bool pause) {
void QuickTimeDecoder::pauseVideoIntern(bool pause) {
if (_audStream)
g_system->getMixer()->pauseHandle(_audHandle, pause);
}
Graphics::Surface *QTPlayer::decodeNextFrame() {
Surface *QuickTimeDecoder::decodeNextFrame() {
if (!_videoCodec || _curFrame >= (int32)getFrameCount() - 1)
return NULL;
@ -216,7 +216,7 @@ Graphics::Surface *QTPlayer::decodeNextFrame() {
Common::SeekableReadStream *frameData = getNextFramePacket();
if (frameData) {
Graphics::Surface *frame = _videoCodec->decodeImage(frameData);
Surface *frame = _videoCodec->decodeImage(frameData);
delete frameData;
return scaleSurface(frame);
}
@ -224,7 +224,7 @@ Graphics::Surface *QTPlayer::decodeNextFrame() {
return NULL;
}
Graphics::Surface *QTPlayer::scaleSurface(Graphics::Surface *frame) {
Surface *QuickTimeDecoder::scaleSurface(Surface *frame) {
if (getScaleMode() == kScaleNormal)
return frame;
@ -237,22 +237,22 @@ Graphics::Surface *QTPlayer::scaleSurface(Graphics::Surface *frame) {
return _scaledSurface;
}
bool QTPlayer::endOfVideo() const {
bool QuickTimeDecoder::endOfVideo() const {
return (!_audStream || _audStream->endOfData()) && (!_videoCodec || _curFrame >= (int32)getFrameCount() - 1);
}
bool QTPlayer::needsUpdate() const {
bool QuickTimeDecoder::needsUpdate() const {
return !endOfVideo() && getTimeToNextFrame() == 0;
}
uint32 QTPlayer::getElapsedTime() const {
uint32 QuickTimeDecoder::getElapsedTime() const {
if (_audStream)
return g_system->getMixer()->getSoundElapsedTime(_audHandle);
return g_system->getMillis() - _startTime;
}
uint32 QTPlayer::getTimeToNextFrame() const {
uint32 QuickTimeDecoder::getTimeToNextFrame() const {
if (endOfVideo() || _curFrame < 0)
return 0;
@ -266,7 +266,7 @@ uint32 QTPlayer::getTimeToNextFrame() const {
return nextFrameStartTime - elapsedTime;
}
bool QTPlayer::load(Common::SeekableReadStream &stream) {
bool QuickTimeDecoder::load(Common::SeekableReadStream &stream) {
_fd = &stream;
_foundMOOV = _foundMDAT = false;
_numStreams = 0;
@ -337,7 +337,7 @@ bool QTPlayer::load(Common::SeekableReadStream &stream) {
if (getScaleMode() != kScaleNormal) {
// We have to initialize the scaled surface
_scaledSurface = new Graphics::Surface();
_scaledSurface = new Surface();
_scaledSurface->create(getWidth(), getHeight(), getPixelFormat().bytesPerPixel);
}
}
@ -345,40 +345,40 @@ bool QTPlayer::load(Common::SeekableReadStream &stream) {
return true;
}
void QTPlayer::initParseTable() {
void QuickTimeDecoder::initParseTable() {
static const ParseTable p[] = {
{ MKID_BE('dinf'), &QTPlayer::readDefault },
{ MKID_BE('dref'), &QTPlayer::readLeaf },
{ MKID_BE('edts'), &QTPlayer::readDefault },
{ MKID_BE('elst'), &QTPlayer::readELST },
{ MKID_BE('hdlr'), &QTPlayer::readHDLR },
{ MKID_BE('mdat'), &QTPlayer::readMDAT },
{ MKID_BE('mdhd'), &QTPlayer::readMDHD },
{ MKID_BE('mdia'), &QTPlayer::readDefault },
{ MKID_BE('minf'), &QTPlayer::readDefault },
{ MKID_BE('moov'), &QTPlayer::readMOOV },
{ MKID_BE('mvhd'), &QTPlayer::readMVHD },
{ MKID_BE('smhd'), &QTPlayer::readLeaf },
{ MKID_BE('stbl'), &QTPlayer::readDefault },
{ MKID_BE('stco'), &QTPlayer::readSTCO },
{ MKID_BE('stsc'), &QTPlayer::readSTSC },
{ MKID_BE('stsd'), &QTPlayer::readSTSD },
{ MKID_BE('stss'), &QTPlayer::readSTSS },
{ MKID_BE('stsz'), &QTPlayer::readSTSZ },
{ MKID_BE('stts'), &QTPlayer::readSTTS },
{ MKID_BE('tkhd'), &QTPlayer::readTKHD },
{ MKID_BE('trak'), &QTPlayer::readTRAK },
{ MKID_BE('udta'), &QTPlayer::readLeaf },
{ MKID_BE('vmhd'), &QTPlayer::readLeaf },
{ MKID_BE('cmov'), &QTPlayer::readCMOV },
{ MKID_BE('wave'), &QTPlayer::readWAVE },
{ MKID_BE('dinf'), &QuickTimeDecoder::readDefault },
{ MKID_BE('dref'), &QuickTimeDecoder::readLeaf },
{ MKID_BE('edts'), &QuickTimeDecoder::readDefault },
{ MKID_BE('elst'), &QuickTimeDecoder::readELST },
{ MKID_BE('hdlr'), &QuickTimeDecoder::readHDLR },
{ MKID_BE('mdat'), &QuickTimeDecoder::readMDAT },
{ MKID_BE('mdhd'), &QuickTimeDecoder::readMDHD },
{ MKID_BE('mdia'), &QuickTimeDecoder::readDefault },
{ MKID_BE('minf'), &QuickTimeDecoder::readDefault },
{ MKID_BE('moov'), &QuickTimeDecoder::readMOOV },
{ MKID_BE('mvhd'), &QuickTimeDecoder::readMVHD },
{ MKID_BE('smhd'), &QuickTimeDecoder::readLeaf },
{ MKID_BE('stbl'), &QuickTimeDecoder::readDefault },
{ MKID_BE('stco'), &QuickTimeDecoder::readSTCO },
{ MKID_BE('stsc'), &QuickTimeDecoder::readSTSC },
{ MKID_BE('stsd'), &QuickTimeDecoder::readSTSD },
{ MKID_BE('stss'), &QuickTimeDecoder::readSTSS },
{ MKID_BE('stsz'), &QuickTimeDecoder::readSTSZ },
{ MKID_BE('stts'), &QuickTimeDecoder::readSTTS },
{ MKID_BE('tkhd'), &QuickTimeDecoder::readTKHD },
{ MKID_BE('trak'), &QuickTimeDecoder::readTRAK },
{ MKID_BE('udta'), &QuickTimeDecoder::readLeaf },
{ MKID_BE('vmhd'), &QuickTimeDecoder::readLeaf },
{ MKID_BE('cmov'), &QuickTimeDecoder::readCMOV },
{ MKID_BE('wave'), &QuickTimeDecoder::readWAVE },
{ 0, 0 }
};
_parseTable = p;
}
int QTPlayer::readDefault(MOVatom atom) {
int QuickTimeDecoder::readDefault(MOVatom atom) {
uint32 total_size = 0;
MOVatom a;
int err = 0;
@ -443,14 +443,14 @@ int QTPlayer::readDefault(MOVatom atom) {
return err;
}
int QTPlayer::readLeaf(MOVatom atom) {
int QuickTimeDecoder::readLeaf(MOVatom atom) {
if (atom.size > 1)
_fd->seek(atom.size, SEEK_SET);
return 0;
}
int QTPlayer::readMOOV(MOVatom atom) {
int QuickTimeDecoder::readMOOV(MOVatom atom) {
if (readDefault(atom) < 0)
return -1;
@ -464,7 +464,7 @@ int QTPlayer::readMOOV(MOVatom atom) {
return 0; // now go for mdat
}
int QTPlayer::readCMOV(MOVatom atom) {
int QuickTimeDecoder::readCMOV(MOVatom atom) {
#ifdef USE_ZLIB
// Read in the dcom atom
_fd->readUint32BE();
@ -515,7 +515,7 @@ int QTPlayer::readCMOV(MOVatom atom) {
#endif
}
int QTPlayer::readMVHD(MOVatom atom) {
int QuickTimeDecoder::readMVHD(MOVatom atom) {
byte version = _fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
@ -570,7 +570,7 @@ int QTPlayer::readMVHD(MOVatom atom) {
return 0;
}
int QTPlayer::readTRAK(MOVatom atom) {
int QuickTimeDecoder::readTRAK(MOVatom atom) {
MOVStreamContext *sc = new MOVStreamContext();
if (!sc)
@ -585,7 +585,7 @@ int QTPlayer::readTRAK(MOVatom atom) {
}
// this atom contains actual media data
int QTPlayer::readMDAT(MOVatom atom) {
int QuickTimeDecoder::readMDAT(MOVatom atom) {
if (atom.size == 0) // wrong one (MP4)
return 0;
@ -602,7 +602,7 @@ int QTPlayer::readMDAT(MOVatom atom) {
return 0; // now go for moov
}
int QTPlayer::readTKHD(MOVatom atom) {
int QuickTimeDecoder::readTKHD(MOVatom atom) {
MOVStreamContext *st = _streams[_numStreams - 1];
byte version = _fd->readByte();
@ -662,7 +662,7 @@ int QTPlayer::readTKHD(MOVatom atom) {
}
// edit list atom
int QTPlayer::readELST(MOVatom atom) {
int QuickTimeDecoder::readELST(MOVatom atom) {
_fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
uint32 editCount = _streams[_numStreams - 1]->edit_count = _fd->readUint32BE(); // entries
@ -681,7 +681,7 @@ int QTPlayer::readELST(MOVatom atom) {
return 0;
}
int QTPlayer::readHDLR(MOVatom atom) {
int QuickTimeDecoder::readHDLR(MOVatom atom) {
MOVStreamContext *st = _streams[_numStreams - 1];
_fd->readByte(); // version
@ -722,7 +722,7 @@ int QTPlayer::readHDLR(MOVatom atom) {
return 0;
}
int QTPlayer::readMDHD(MOVatom atom) {
int QuickTimeDecoder::readMDHD(MOVatom atom) {
MOVStreamContext *st = _streams[_numStreams - 1];
byte version = _fd->readByte();
@ -749,7 +749,7 @@ int QTPlayer::readMDHD(MOVatom atom) {
return 0;
}
int QTPlayer::readSTSD(MOVatom atom) {
int QuickTimeDecoder::readSTSD(MOVatom atom) {
MOVStreamContext *st = _streams[_numStreams - 1];
_fd->readByte(); // version
@ -934,7 +934,7 @@ int QTPlayer::readSTSD(MOVatom atom) {
return 0;
}
int QTPlayer::readSTSC(MOVatom atom) {
int QuickTimeDecoder::readSTSC(MOVatom atom) {
MOVStreamContext *st = _streams[_numStreams - 1];
_fd->readByte(); // version
@ -959,7 +959,7 @@ int QTPlayer::readSTSC(MOVatom atom) {
return 0;
}
int QTPlayer::readSTSS(MOVatom atom) {
int QuickTimeDecoder::readSTSS(MOVatom atom) {
MOVStreamContext *st = _streams[_numStreams - 1];
_fd->readByte(); // version
@ -982,7 +982,7 @@ int QTPlayer::readSTSS(MOVatom atom) {
return 0;
}
int QTPlayer::readSTSZ(MOVatom atom) {
int QuickTimeDecoder::readSTSZ(MOVatom atom) {
MOVStreamContext *st = _streams[_numStreams - 1];
_fd->readByte(); // version
@ -1014,7 +1014,7 @@ static uint32 ff_gcd(uint32 a, uint32 b) {
else return a;
}
int QTPlayer::readSTTS(MOVatom atom) {
int QuickTimeDecoder::readSTTS(MOVatom atom) {
MOVStreamContext *st = _streams[_numStreams - 1];
uint32 duration = 0;
uint32 total_sample_count = 0;
@ -1054,7 +1054,7 @@ int QTPlayer::readSTTS(MOVatom atom) {
return 0;
}
int QTPlayer::readSTCO(MOVatom atom) {
int QuickTimeDecoder::readSTCO(MOVatom atom) {
MOVStreamContext *st = _streams[_numStreams - 1];
_fd->readByte(); // version
@ -1088,7 +1088,7 @@ int QTPlayer::readSTCO(MOVatom atom) {
return 0;
}
int QTPlayer::readWAVE(MOVatom atom) {
int QuickTimeDecoder::readWAVE(MOVatom atom) {
if (_numStreams < 1)
return 0;
@ -1107,7 +1107,7 @@ int QTPlayer::readWAVE(MOVatom atom) {
return 0;
}
void QTPlayer::close() {
void QuickTimeDecoder::close() {
stopAudio();
delete _videoCodec; _videoCodec = 0;
@ -1126,10 +1126,10 @@ void QTPlayer::close() {
// The audio stream is deleted automatically
_audStream = NULL;
Graphics::VideoDecoder::reset();
VideoDecoder::reset();
}
Common::SeekableReadStream *QTPlayer::getNextFramePacket() {
Common::SeekableReadStream *QuickTimeDecoder::getNextFramePacket() {
if (_videoStreamIndex < 0)
return NULL;
@ -1182,17 +1182,22 @@ Common::SeekableReadStream *QTPlayer::getNextFramePacket() {
return _fd->readStream(_streams[_videoStreamIndex]->sample_sizes[getCurFrame()]);
}
bool QTPlayer::checkAudioCodecSupport(uint32 tag) {
bool QuickTimeDecoder::checkAudioCodecSupport(uint32 tag) {
// Check if the codec is a supported codec
if (tag == MKID_BE('twos') || tag == MKID_BE('raw ') || tag == MKID_BE('ima4') || tag == MKID_BE('QDM2'))
if (tag == MKID_BE('twos') || tag == MKID_BE('raw ') || tag == MKID_BE('ima4'))
return true;
#ifdef SOUND_QDM2_H
if (tag == MKID_BE('QDM2'))
return true;
#endif
warning("Audio Codec Not Supported: \'%s\'", tag2str(tag));
return false;
}
Audio::AudioStream *QTPlayer::createAudioStream(Common::SeekableReadStream *stream) {
Audio::AudioStream *QuickTimeDecoder::createAudioStream(Common::SeekableReadStream *stream) {
if (!stream || _audioStreamIndex < 0)
return NULL;
@ -1213,9 +1218,11 @@ Audio::AudioStream *QTPlayer::createAudioStream(Common::SeekableReadStream *stre
} else if (_streams[_audioStreamIndex]->codec_tag == MKID_BE('ima4')) {
// Riven uses this codec (as do some Myst ME videos)
return Audio::makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), Audio::kADPCMApple, _streams[_audioStreamIndex]->sample_rate, _streams[_audioStreamIndex]->channels, 34);
#ifdef SOUND_QDM2_H
} else if (_streams[_audioStreamIndex]->codec_tag == MKID_BE('QDM2')) {
// Several Myst ME videos use this codec
return new QDM2Stream(stream, _streams[_audioStreamIndex]->extradata);
return new Audio::QDM2Stream(stream, _streams[_audioStreamIndex]->extradata);
#endif
}
error("Unsupported audio codec");
@ -1223,12 +1230,12 @@ Audio::AudioStream *QTPlayer::createAudioStream(Common::SeekableReadStream *stre
return NULL;
}
void QTPlayer::updateAudioBuffer() {
void QuickTimeDecoder::updateAudioBuffer() {
if (!_audStream)
return;
// Keep two streams in buffer so that when the first ends, it goes right into the next
for (; _audStream->numQueuedStreams() < 2 && _curAudioChunk < _streams[_audioStreamIndex]->chunk_count; _curAudioChunk++) {
// Keep three streams in buffer so that if/when the first two end, it goes right into the next
for (; _audStream->numQueuedStreams() < 3 && _curAudioChunk < _streams[_audioStreamIndex]->chunk_count; _curAudioChunk++) {
Common::MemoryWriteStreamDynamic *wStream = new Common::MemoryWriteStreamDynamic();
_fd->seek(_streams[_audioStreamIndex]->chunk_offsets[_curAudioChunk]);
@ -1269,4 +1276,4 @@ void QTPlayer::updateAudioBuffer() {
}
}
} // End of namespace Mohawk
} // End of namespace Graphics

View File

@ -31,8 +31,8 @@
// Seek function by Gael Chardon gael.dev@4now.net
//
#ifndef MOHAWK_QT_PLAYER_H
#define MOHAWK_QT_PLAYER_H
#ifndef GRAPHICS_QT_DECODER_H
#define GRAPHICS_QT_DECODER_H
#include "common/scummsys.h"
#include "common/queue.h"
@ -47,7 +47,7 @@ namespace Common {
class File;
}
namespace Mohawk {
namespace Graphics {
enum ScaleMode {
kScaleNormal = 1,
@ -55,10 +55,10 @@ enum ScaleMode {
kScaleQuarter = 4
};
class QTPlayer : public Graphics::RewindableVideoDecoder {
class QuickTimeDecoder : public RewindableVideoDecoder {
public:
QTPlayer();
virtual ~QTPlayer();
QuickTimeDecoder();
virtual ~QuickTimeDecoder();
/**
* Returns the width of the video
@ -104,12 +104,12 @@ public:
void setChunkBeginOffset(uint32 offset) { _beginOffset = offset; }
bool isVideoLoaded() const { return _fd != 0; }
Graphics::Surface *decodeNextFrame();
Surface *decodeNextFrame();
bool needsUpdate() const;
bool endOfVideo() const;
uint32 getElapsedTime() const;
uint32 getTimeToNextFrame() const;
Graphics::PixelFormat getPixelFormat() const;
PixelFormat getPixelFormat() const;
// RewindableVideoDecoder API
void rewind();
@ -132,7 +132,7 @@ protected:
struct ParseTable {
uint32 type;
int (QTPlayer::*func)(MOVatom atom);
int (QuickTimeDecoder::*func)(MOVatom atom);
};
struct MOVstts {
@ -246,13 +246,13 @@ protected:
uint _curAudioChunk;
Audio::SoundHandle _audHandle;
Graphics::Codec *createCodec(uint32 codecTag, byte bitsPerPixel);
Graphics::Codec *_videoCodec;
Codec *createCodec(uint32 codecTag, byte bitsPerPixel);
Codec *_videoCodec;
uint32 _nextFrameStartTime;
int8 _videoStreamIndex;
Graphics::Surface *_scaledSurface;
Graphics::Surface *scaleSurface(Graphics::Surface *frame);
Surface *_scaledSurface;
Surface *scaleSurface(Surface *frame);
ScaleMode getScaleMode() const;
void pauseVideoIntern(bool pause);
@ -277,6 +277,6 @@ protected:
int readWAVE(MOVatom atom);
};
} // End of namespace Mohawk
} // End of namespace Graphics
#endif

View File

@ -25,12 +25,14 @@
// Based off ffmpeg's QDM2 decoder
#include "mohawk/video/qdm2.h"
#include "mohawk/video/qdm2data.h"
#include "sound/decoders/qdm2.h"
#ifdef SOUND_QDM2_H
#include "sound/decoders/qdm2data.h"
#include "common/system.h"
namespace Mohawk {
namespace Audio {
// Fix compilation for non C99-compliant compilers, like MSVC
#ifndef int64_t
@ -3060,4 +3062,6 @@ int QDM2Stream::readBuffer(int16 *buffer, const int numSamples) {
return decodedSamples;
}
} // End of namespace Mohawk
} // End of namespace Audio
#endif

View File

@ -23,14 +23,17 @@
*
*/
#ifndef MOHAWK_VIDEO_QDM2_H
#define MOHAWK_VIDEO_QDM2_H
// Only compile if Mohawk is enabled or if we're building dynamic modules
#if defined(ENABLE_MOHAWK) || defined(DYNAMIC_MODULES)
#ifndef SOUND_QDM2_H
#define SOUND_QDM2_H
#include "sound/audiostream.h"
#include "common/array.h"
#include "common/stream.h"
namespace Mohawk {
namespace Audio {
enum {
SOFTCLIP_THRESHOLD = 27600,
@ -284,6 +287,8 @@ private:
int qdm2_decodeFrame(Common::SeekableReadStream *in);
};
} // End of namespace Mohawk
} // End of namespace Audio
#endif
#endif // SOUND_QDM2_H
#endif // Mohawk/Plugins guard

View File

@ -23,12 +23,12 @@
*
*/
#ifndef MOHAWK_VIDEO_QDM2DATA_H
#define MOHAWK_VIDEO_QDM2DATA_H
#ifndef SOUND_QDM2DATA_H
#define SOUND_QDM2DATA_H
#include "common/scummsys.h"
namespace Mohawk {
namespace Audio {
/// VLC TABLES
@ -526,6 +526,6 @@ static const float type34_delta[10] = { // FIXME: covers 8 entries..
0.138071194291115f,0.333333343267441f,0.60947573184967f,1.0f,0.0f,
};
} // End of namespace Mohawk
} // End of namespace Audio
#endif

View File

@ -18,6 +18,7 @@ MODULE_OBJS := \
decoders/flac.o \
decoders/iff_sound.o \
decoders/mp3.o \
decoders/qdm2.o \
decoders/raw.o \
decoders/vag.o \
decoders/voc.o \