2010-08-08 00:33:59 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Currently, only GOB and SCI32 games play IMDs and VMDs, so skip compiling if GOB and SCI32 is disabled.
|
|
|
|
#if !(defined(ENABLE_GOB) || defined(ENABLE_SCI32) || defined(DYNAMIC_MODULES))
|
|
|
|
|
|
|
|
// Do not compile the CoktelDecoder code
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2011-01-23 17:37:17 +00:00
|
|
|
#ifndef VIDEO_COKTELDECODER_H
|
|
|
|
#define VIDEO_COKTELDECODER_H
|
2010-08-08 00:33:59 +00:00
|
|
|
|
2010-08-08 00:39:03 +00:00
|
|
|
#include "common/list.h"
|
2010-08-08 00:56:58 +00:00
|
|
|
#include "common/array.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/rational.h"
|
|
|
|
#include "common/str.h"
|
|
|
|
|
|
|
|
#include "graphics/surface.h"
|
2010-08-08 00:39:03 +00:00
|
|
|
|
2011-01-23 17:37:17 +00:00
|
|
|
#include "video/video_decoder.h"
|
2010-08-08 00:33:59 +00:00
|
|
|
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/mixer.h"
|
2010-08-08 00:33:59 +00:00
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
namespace Common {
|
|
|
|
struct Rect;
|
|
|
|
class SeekableReadStream;
|
|
|
|
}
|
2010-08-08 00:41:56 +00:00
|
|
|
namespace Audio {
|
2011-04-25 19:29:26 +00:00
|
|
|
class QueuingAudioStream;
|
2010-08-08 00:41:56 +00:00
|
|
|
}
|
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
namespace Graphics {
|
|
|
|
struct PixelFormat;
|
|
|
|
}
|
|
|
|
|
2011-01-23 19:08:09 +00:00
|
|
|
namespace Video {
|
2010-08-08 00:33:59 +00:00
|
|
|
|
2010-08-08 00:56:58 +00:00
|
|
|
class Codec;
|
|
|
|
|
2011-01-23 01:27:40 +00:00
|
|
|
/**
|
|
|
|
* Decoder for Coktel videos.
|
|
|
|
*
|
|
|
|
* Video decoder used in engines:
|
|
|
|
* - gob
|
|
|
|
* - sci
|
|
|
|
*/
|
2012-08-16 16:17:23 +00:00
|
|
|
class CoktelDecoder {
|
2010-08-08 00:33:59 +00:00
|
|
|
public:
|
|
|
|
struct State {
|
|
|
|
/** Set accordingly to what was done. */
|
|
|
|
uint32 flags;
|
|
|
|
/** The id of the spoken words. */
|
|
|
|
uint16 speechId;
|
|
|
|
|
|
|
|
State();
|
|
|
|
};
|
|
|
|
|
2010-08-08 01:07:17 +00:00
|
|
|
CoktelDecoder(Audio::Mixer *mixer,
|
2010-08-08 00:33:59 +00:00
|
|
|
Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
|
2012-08-16 16:17:23 +00:00
|
|
|
virtual ~CoktelDecoder();
|
2010-08-08 00:33:59 +00:00
|
|
|
|
GOB: Add a way to reopen currently opened IMD/VMD videos
This is a workaround for how Lost in Time behaves in combination
with changes I made to the DataIO code for running Urban Runner
on low-memory devices.
Urban Runner's intro are far to big to have them copied into
memory for these devices, so I made the DataIO code return a
SafeSeekableSubReadStream into the opened archive stream instead.
Unfortunately, Lost in Time might not close a video file when it
closes the data file which it was originally in, especially when
loading a saved game. Since the video player needs to be able to
gaplessly continue a video and there does not, by itself, close
the video if not requested by the scripts, this leads to reading
out of an already closed stream in certain cases.
So, to worka round this issues, the video player tries to reopen
each currently opened video after a data archive was closed, to
make sure that that video is still available. If not, the video
is closed.
2012-06-06 22:21:54 +00:00
|
|
|
/** Replace the current video stream with this identical one. */
|
|
|
|
virtual bool reloadStream(Common::SeekableReadStream *stream) = 0;
|
|
|
|
|
2010-08-08 00:36:19 +00:00
|
|
|
virtual bool seek(int32 frame, int whence = SEEK_SET, bool restart = false) = 0;
|
2010-08-08 00:33:59 +00:00
|
|
|
|
2010-08-08 00:37:52 +00:00
|
|
|
/** Draw directly onto the specified video memory. */
|
|
|
|
void setSurfaceMemory(void *mem, uint16 width, uint16 height, uint8 bpp);
|
|
|
|
/** Reset the video memory. */
|
|
|
|
void setSurfaceMemory();
|
|
|
|
|
2011-01-23 19:08:09 +00:00
|
|
|
const Graphics::Surface *getSurface() const;
|
2010-08-08 00:53:55 +00:00
|
|
|
|
2010-08-08 00:38:26 +00:00
|
|
|
/** Draw the video starting at this position within the video memory. */
|
2010-08-08 00:41:56 +00:00
|
|
|
virtual void setXY(uint16 x, uint16 y);
|
|
|
|
/** Draw the video at the default position. */
|
|
|
|
void setXY();
|
2010-08-08 00:38:26 +00:00
|
|
|
|
2010-08-08 00:39:32 +00:00
|
|
|
/** Override the video's frame rate. */
|
|
|
|
void setFrameRate(Common::Rational frameRate);
|
2012-08-27 00:30:32 +00:00
|
|
|
/** Get the video's frame rate. */
|
|
|
|
Common::Rational getFrameRate() const;
|
2010-08-08 00:39:32 +00:00
|
|
|
|
2010-08-08 00:41:56 +00:00
|
|
|
/** Get the video's default X position. */
|
|
|
|
uint16 getDefaultX() const;
|
|
|
|
/** Get the video's default Y position. */
|
|
|
|
uint16 getDefaultY() const;
|
|
|
|
|
2010-08-08 00:39:03 +00:00
|
|
|
/** Return a list of rectangles that changed in the last frame. */
|
|
|
|
const Common::List<Common::Rect> &getDirtyRects() const;
|
|
|
|
|
2010-08-08 00:42:59 +00:00
|
|
|
bool hasPalette() const;
|
2011-01-20 12:28:22 +00:00
|
|
|
virtual bool hasVideo() const;
|
2010-08-08 00:42:59 +00:00
|
|
|
|
2010-08-08 00:41:56 +00:00
|
|
|
bool hasSound() const;
|
|
|
|
bool isSoundEnabled() const;
|
|
|
|
bool isSoundPlaying() const;
|
|
|
|
|
|
|
|
void enableSound();
|
|
|
|
void disableSound();
|
2011-01-24 14:09:47 +00:00
|
|
|
void finishSound();
|
2010-08-08 00:41:56 +00:00
|
|
|
|
2011-01-16 16:27:52 +00:00
|
|
|
virtual void colorModeChanged();
|
|
|
|
|
2010-08-08 01:02:19 +00:00
|
|
|
/** Return the coordinates of the specified frame. */
|
2010-08-08 01:06:15 +00:00
|
|
|
virtual bool getFrameCoords(int16 frame, int16 &x, int16 &y, int16 &width, int16 &height);
|
2010-08-08 01:02:19 +00:00
|
|
|
|
2010-08-08 00:57:27 +00:00
|
|
|
/** Return whether that video has any embedded files. */
|
|
|
|
virtual bool hasEmbeddedFiles() const;
|
|
|
|
|
2010-08-08 00:46:34 +00:00
|
|
|
/** Return whether that embedded file exists. */
|
|
|
|
virtual bool hasEmbeddedFile(const Common::String &fileName) const;
|
|
|
|
|
|
|
|
/** Return that embedded file. */
|
2010-11-19 01:37:04 +00:00
|
|
|
virtual Common::SeekableReadStream *getEmbeddedFile(const Common::String &fileName) const;
|
2010-08-08 00:45:58 +00:00
|
|
|
|
2010-08-08 01:05:16 +00:00
|
|
|
/** Return the current subtitle index. */
|
|
|
|
virtual int32 getSubtitleIndex() const;
|
|
|
|
|
2011-01-16 16:27:52 +00:00
|
|
|
/** Is the video paletted or true color? */
|
|
|
|
virtual bool isPaletted() const;
|
|
|
|
|
2012-08-16 16:17:23 +00:00
|
|
|
/**
|
|
|
|
* Get the current frame
|
|
|
|
* @see VideoDecoder::getCurFrame()
|
|
|
|
*/
|
|
|
|
int getCurFrame() const;
|
2010-08-08 00:52:30 +00:00
|
|
|
|
2012-08-16 16:17:23 +00:00
|
|
|
/**
|
|
|
|
* Decode the next frame
|
|
|
|
* @see VideoDecoder::decodeNextFrame()
|
|
|
|
*/
|
|
|
|
virtual const Graphics::Surface *decodeNextFrame() = 0;
|
2010-08-08 00:33:59 +00:00
|
|
|
|
2012-08-16 16:17:23 +00:00
|
|
|
/**
|
|
|
|
* Load a video from a stream
|
|
|
|
* @see VideoDecoder::loadStream()
|
|
|
|
*/
|
|
|
|
virtual bool loadStream(Common::SeekableReadStream *stream) = 0;
|
|
|
|
|
|
|
|
/** Has a video been loaded? */
|
|
|
|
virtual bool isVideoLoaded() const = 0;
|
|
|
|
|
|
|
|
/** Has the end of the video been reached? */
|
|
|
|
bool endOfVideo() const;
|
|
|
|
|
|
|
|
/** Close the video. */
|
2010-08-08 00:37:52 +00:00
|
|
|
void close();
|
|
|
|
|
2012-08-27 00:30:32 +00:00
|
|
|
/** Get the Mixer SoundType audio is being played with. */
|
|
|
|
Audio::Mixer::SoundType getSoundType() const;
|
|
|
|
/** Get the AudioStream for the audio. */
|
|
|
|
Audio::AudioStream *getAudioStream() const;
|
|
|
|
|
2010-08-08 00:33:59 +00:00
|
|
|
uint16 getWidth() const;
|
|
|
|
uint16 getHeight() const;
|
2012-08-16 16:17:23 +00:00
|
|
|
virtual Graphics::PixelFormat getPixelFormat() const = 0;
|
2010-08-08 00:33:59 +00:00
|
|
|
|
|
|
|
uint32 getFrameCount() const;
|
|
|
|
|
2010-12-16 01:41:11 +00:00
|
|
|
const byte *getPalette();
|
2010-08-08 00:33:59 +00:00
|
|
|
bool hasDirtyPalette() const;
|
|
|
|
|
2012-08-16 16:17:23 +00:00
|
|
|
uint32 getTimeToNextFrame() const;
|
2011-01-20 03:22:43 +00:00
|
|
|
uint32 getStaticTimeToNextFrame() const;
|
2010-08-08 00:45:58 +00:00
|
|
|
|
2012-08-16 16:17:23 +00:00
|
|
|
void pauseVideo(bool pause);
|
|
|
|
|
2010-08-08 00:33:59 +00:00
|
|
|
protected:
|
2010-08-08 00:41:56 +00:00
|
|
|
enum SoundStage {
|
2011-01-20 17:07:17 +00:00
|
|
|
kSoundNone = 0, ///< No sound.
|
|
|
|
kSoundLoaded = 1, ///< Sound loaded.
|
|
|
|
kSoundPlaying = 2, ///< Sound is playing.
|
|
|
|
kSoundFinished = 3 ///< No more new sound data.
|
2010-08-08 00:41:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum Features {
|
|
|
|
kFeaturesNone = 0x0000,
|
|
|
|
kFeaturesPalette = 0x0008, ///< Has an own palette.
|
|
|
|
kFeaturesDataSize = 0x0020, ///< Suggests a data size.
|
|
|
|
kFeaturesSound = 0x0040, ///< Has sound.
|
|
|
|
kFeaturesFrameCoords = 0x0080, ///< Has specific frame coordinates.
|
|
|
|
kFeaturesStdCoords = 0x0100, ///< Has general standard coordinates.
|
|
|
|
kFeaturesFramePos = 0x0200, ///< Has a frame positions table.
|
|
|
|
kFeaturesVideo = 0x0400 ///< Has video.
|
|
|
|
};
|
|
|
|
|
2010-08-08 00:33:59 +00:00
|
|
|
Audio::Mixer *_mixer;
|
|
|
|
Audio::Mixer::SoundType _soundType;
|
|
|
|
|
|
|
|
uint16 _width;
|
|
|
|
uint16 _height;
|
|
|
|
|
2010-08-08 00:38:26 +00:00
|
|
|
uint16 _x;
|
|
|
|
uint16 _y;
|
|
|
|
|
2010-08-08 00:41:56 +00:00
|
|
|
uint16 _defaultX;
|
|
|
|
uint16 _defaultY;
|
|
|
|
|
|
|
|
uint32 _features;
|
|
|
|
|
2012-08-16 16:17:23 +00:00
|
|
|
int32 _curFrame;
|
2010-08-08 00:33:59 +00:00
|
|
|
uint32 _frameCount;
|
|
|
|
|
2012-08-16 16:17:23 +00:00
|
|
|
uint32 _startTime;
|
|
|
|
|
2010-08-08 00:33:59 +00:00
|
|
|
byte _palette[768];
|
|
|
|
bool _paletteDirty;
|
|
|
|
|
2010-08-08 00:37:52 +00:00
|
|
|
bool _ownSurface;
|
2011-01-23 19:08:09 +00:00
|
|
|
Graphics::Surface _surface;
|
2010-08-08 00:37:52 +00:00
|
|
|
|
2010-08-08 00:39:03 +00:00
|
|
|
Common::List<Common::Rect> _dirtyRects;
|
|
|
|
|
2010-08-08 00:33:59 +00:00
|
|
|
Common::Rational _frameRate;
|
|
|
|
|
2010-08-08 00:41:56 +00:00
|
|
|
// Current sound state
|
|
|
|
bool _hasSound;
|
|
|
|
bool _soundEnabled;
|
|
|
|
SoundStage _soundStage;
|
|
|
|
|
|
|
|
Audio::QueuingAudioStream *_audioStream;
|
|
|
|
Audio::SoundHandle _audioHandle;
|
|
|
|
|
2010-08-08 00:56:29 +00:00
|
|
|
bool evaluateSeekFrame(int32 &frame, int whence) const;
|
|
|
|
|
2010-08-08 00:52:30 +00:00
|
|
|
// Surface management
|
2010-08-08 00:37:52 +00:00
|
|
|
bool hasSurface();
|
|
|
|
void createSurface();
|
|
|
|
void freeSurface();
|
|
|
|
|
2010-08-08 00:52:30 +00:00
|
|
|
// Decompression
|
2011-01-16 16:27:22 +00:00
|
|
|
uint32 deLZ77(byte *dest, const byte *src, uint32 srcSize, uint32 destSize);
|
2010-08-08 01:01:17 +00:00
|
|
|
void deRLE(byte *&destPtr, const byte *&srcPtr, int16 destLen, int16 srcLen);
|
2010-08-08 00:42:59 +00:00
|
|
|
|
2010-08-08 00:52:30 +00:00
|
|
|
// Block rendering
|
2011-01-23 19:08:09 +00:00
|
|
|
void renderBlockWhole (Graphics::Surface &dstSurf, const byte *src, Common::Rect &rect);
|
|
|
|
void renderBlockWhole4X (Graphics::Surface &dstSurf, const byte *src, Common::Rect &rect);
|
|
|
|
void renderBlockWhole2Y (Graphics::Surface &dstSurf, const byte *src, Common::Rect &rect);
|
|
|
|
void renderBlockSparse (Graphics::Surface &dstSurf, const byte *src, Common::Rect &rect);
|
|
|
|
void renderBlockSparse2Y(Graphics::Surface &dstSurf, const byte *src, Common::Rect &rect);
|
|
|
|
void renderBlockRLE (Graphics::Surface &dstSurf, const byte *src, Common::Rect &rect);
|
2010-08-08 00:42:59 +00:00
|
|
|
|
2010-08-08 00:52:30 +00:00
|
|
|
// Sound helper functions
|
2010-08-08 00:42:30 +00:00
|
|
|
inline void unsignedToSigned(byte *buffer, int length);
|
|
|
|
|
2012-08-16 16:17:23 +00:00
|
|
|
private:
|
|
|
|
uint32 _pauseStartTime;
|
|
|
|
bool _isPaused;
|
2010-08-08 00:33:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PreIMDDecoder : public CoktelDecoder {
|
|
|
|
public:
|
2010-08-08 01:07:17 +00:00
|
|
|
PreIMDDecoder(uint16 width, uint16 height, Audio::Mixer *mixer,
|
2010-08-08 00:33:59 +00:00
|
|
|
Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
|
|
|
|
~PreIMDDecoder();
|
|
|
|
|
GOB: Add a way to reopen currently opened IMD/VMD videos
This is a workaround for how Lost in Time behaves in combination
with changes I made to the DataIO code for running Urban Runner
on low-memory devices.
Urban Runner's intro are far to big to have them copied into
memory for these devices, so I made the DataIO code return a
SafeSeekableSubReadStream into the opened archive stream instead.
Unfortunately, Lost in Time might not close a video file when it
closes the data file which it was originally in, especially when
loading a saved game. Since the video player needs to be able to
gaplessly continue a video and there does not, by itself, close
the video if not requested by the scripts, this leads to reading
out of an already closed stream in certain cases.
So, to worka round this issues, the video player tries to reopen
each currently opened video after a data archive was closed, to
make sure that that video is still available. If not, the video
is closed.
2012-06-06 22:21:54 +00:00
|
|
|
bool reloadStream(Common::SeekableReadStream *stream);
|
|
|
|
|
2010-08-08 00:36:19 +00:00
|
|
|
bool seek(int32 frame, int whence = SEEK_SET, bool restart = false);
|
2010-08-08 00:33:59 +00:00
|
|
|
|
2011-02-07 17:54:16 +00:00
|
|
|
bool loadStream(Common::SeekableReadStream *stream);
|
2010-08-08 00:33:59 +00:00
|
|
|
void close();
|
|
|
|
|
|
|
|
bool isVideoLoaded() const;
|
|
|
|
|
2011-01-23 19:08:09 +00:00
|
|
|
const Graphics::Surface *decodeNextFrame();
|
2010-08-08 00:33:59 +00:00
|
|
|
|
2011-01-23 19:08:09 +00:00
|
|
|
Graphics::PixelFormat getPixelFormat() const;
|
2010-08-08 00:36:19 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Common::SeekableReadStream *_stream;
|
|
|
|
|
2010-08-08 00:41:56 +00:00
|
|
|
// Buffer for processed frame data
|
2010-08-08 00:36:19 +00:00
|
|
|
byte *_videoBuffer;
|
|
|
|
uint32 _videoBufferSize;
|
|
|
|
|
2010-08-08 00:52:30 +00:00
|
|
|
// Frame decoding
|
2010-08-08 00:36:19 +00:00
|
|
|
void processFrame();
|
|
|
|
void renderFrame();
|
2010-08-08 00:33:59 +00:00
|
|
|
};
|
|
|
|
|
2010-08-08 00:40:24 +00:00
|
|
|
class IMDDecoder : public CoktelDecoder {
|
|
|
|
public:
|
2010-08-08 01:07:17 +00:00
|
|
|
IMDDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
|
2010-08-08 00:40:24 +00:00
|
|
|
~IMDDecoder();
|
|
|
|
|
GOB: Add a way to reopen currently opened IMD/VMD videos
This is a workaround for how Lost in Time behaves in combination
with changes I made to the DataIO code for running Urban Runner
on low-memory devices.
Urban Runner's intro are far to big to have them copied into
memory for these devices, so I made the DataIO code return a
SafeSeekableSubReadStream into the opened archive stream instead.
Unfortunately, Lost in Time might not close a video file when it
closes the data file which it was originally in, especially when
loading a saved game. Since the video player needs to be able to
gaplessly continue a video and there does not, by itself, close
the video if not requested by the scripts, this leads to reading
out of an already closed stream in certain cases.
So, to worka round this issues, the video player tries to reopen
each currently opened video after a data archive was closed, to
make sure that that video is still available. If not, the video
is closed.
2012-06-06 22:21:54 +00:00
|
|
|
bool reloadStream(Common::SeekableReadStream *stream);
|
|
|
|
|
2010-08-08 00:40:24 +00:00
|
|
|
bool seek(int32 frame, int whence = SEEK_SET, bool restart = false);
|
|
|
|
|
2010-08-08 00:42:59 +00:00
|
|
|
void setXY(uint16 x, uint16 y);
|
|
|
|
|
2011-02-07 17:54:16 +00:00
|
|
|
bool loadStream(Common::SeekableReadStream *stream);
|
2010-08-08 00:40:24 +00:00
|
|
|
void close();
|
|
|
|
|
|
|
|
bool isVideoLoaded() const;
|
|
|
|
|
2011-01-23 19:08:09 +00:00
|
|
|
const Graphics::Surface *decodeNextFrame();
|
2010-08-08 00:40:24 +00:00
|
|
|
|
2011-01-23 19:08:09 +00:00
|
|
|
Graphics::PixelFormat getPixelFormat() const;
|
2010-08-08 00:40:24 +00:00
|
|
|
|
|
|
|
private:
|
2010-08-08 00:41:56 +00:00
|
|
|
enum Command {
|
|
|
|
kCommandNextSound = 0xFF00,
|
|
|
|
kCommandStartSound = 0xFF01,
|
|
|
|
|
|
|
|
kCommandBreak = 0xFFF0,
|
|
|
|
kCommandBreakSkip0 = 0xFFF1,
|
|
|
|
kCommandBreakSkip16 = 0xFFF2,
|
|
|
|
kCommandBreakSkip32 = 0xFFF3,
|
|
|
|
kCommandBreakMask = 0xFFF8,
|
|
|
|
|
|
|
|
kCommandPalette = 0xFFF4,
|
|
|
|
kCommandVideoData = 0xFFFC,
|
|
|
|
|
|
|
|
kCommandJump = 0xFFFD
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Coord {
|
|
|
|
int16 left;
|
|
|
|
int16 top;
|
|
|
|
int16 right;
|
|
|
|
int16 bottom;
|
|
|
|
};
|
|
|
|
|
2010-08-08 00:40:24 +00:00
|
|
|
Common::SeekableReadStream *_stream;
|
|
|
|
|
2010-08-08 00:41:56 +00:00
|
|
|
byte _version;
|
|
|
|
|
|
|
|
// Standard coordinates gives by the header
|
|
|
|
int16 _stdX;
|
|
|
|
int16 _stdY;
|
|
|
|
int16 _stdWidth;
|
|
|
|
int16 _stdHeight;
|
|
|
|
|
|
|
|
uint32 _flags;
|
|
|
|
|
|
|
|
uint32 _firstFramePos; ///< Position of the first frame's data within the stream.
|
|
|
|
uint32 *_framePos; ///< Positions of all frames.
|
|
|
|
Coord *_frameCoords; ///< Coordinates of all frames.
|
|
|
|
|
2011-01-16 16:26:52 +00:00
|
|
|
uint32 _videoBufferSize; ///< Size of the video buffers.
|
|
|
|
byte *_videoBuffer[2]; ///< Video buffers.
|
|
|
|
uint32 _videoBufferLen[2]; ///< Size of the video buffers filled.
|
2010-08-08 00:40:24 +00:00
|
|
|
|
2010-08-08 00:41:56 +00:00
|
|
|
// Sound properties
|
|
|
|
uint16 _soundFlags;
|
|
|
|
int16 _soundFreq;
|
|
|
|
int16 _soundSliceSize;
|
|
|
|
int16 _soundSlicesCount;
|
|
|
|
|
2010-08-08 00:52:30 +00:00
|
|
|
// Loading helper functions
|
2010-08-08 00:41:56 +00:00
|
|
|
bool loadCoordinates();
|
|
|
|
bool loadFrameTableOffsets(uint32 &framePosPos, uint32 &frameCoordsPos);
|
|
|
|
bool assessVideoProperties();
|
|
|
|
bool assessAudioProperties();
|
|
|
|
bool loadFrameTables(uint32 framePosPos, uint32 frameCoordsPos);
|
|
|
|
|
2010-08-08 00:52:30 +00:00
|
|
|
// Frame decoding
|
2010-08-08 00:40:24 +00:00
|
|
|
void processFrame();
|
2010-08-08 00:59:58 +00:00
|
|
|
Common::Rect calcFrameCoords(uint32 frame);
|
2010-08-08 00:42:30 +00:00
|
|
|
|
2010-08-08 00:52:30 +00:00
|
|
|
// Video
|
2010-08-08 00:59:58 +00:00
|
|
|
bool renderFrame(Common::Rect &rect);
|
2010-08-08 00:42:30 +00:00
|
|
|
|
2010-08-08 00:52:30 +00:00
|
|
|
// Sound
|
2010-08-08 00:42:30 +00:00
|
|
|
void nextSoundSlice(bool hasNextCmd);
|
|
|
|
bool initialSoundSlice(bool hasNextCmd);
|
|
|
|
void emptySoundSlice(bool hasNextCmd);
|
2010-08-08 00:40:24 +00:00
|
|
|
};
|
|
|
|
|
2010-08-08 00:56:04 +00:00
|
|
|
class VMDDecoder : public CoktelDecoder {
|
2012-08-16 16:17:23 +00:00
|
|
|
friend class AdvancedVMDDecoder;
|
|
|
|
|
2010-08-08 00:56:04 +00:00
|
|
|
public:
|
2010-08-08 01:07:17 +00:00
|
|
|
VMDDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
|
2010-08-08 00:56:04 +00:00
|
|
|
~VMDDecoder();
|
|
|
|
|
GOB: Add a way to reopen currently opened IMD/VMD videos
This is a workaround for how Lost in Time behaves in combination
with changes I made to the DataIO code for running Urban Runner
on low-memory devices.
Urban Runner's intro are far to big to have them copied into
memory for these devices, so I made the DataIO code return a
SafeSeekableSubReadStream into the opened archive stream instead.
Unfortunately, Lost in Time might not close a video file when it
closes the data file which it was originally in, especially when
loading a saved game. Since the video player needs to be able to
gaplessly continue a video and there does not, by itself, close
the video if not requested by the scripts, this leads to reading
out of an already closed stream in certain cases.
So, to worka round this issues, the video player tries to reopen
each currently opened video after a data archive was closed, to
make sure that that video is still available. If not, the video
is closed.
2012-06-06 22:21:54 +00:00
|
|
|
bool reloadStream(Common::SeekableReadStream *stream);
|
|
|
|
|
2010-08-08 00:56:04 +00:00
|
|
|
bool seek(int32 frame, int whence = SEEK_SET, bool restart = false);
|
|
|
|
|
2010-08-08 01:03:50 +00:00
|
|
|
void setXY(uint16 x, uint16 y);
|
|
|
|
|
2011-01-16 16:27:52 +00:00
|
|
|
void colorModeChanged();
|
|
|
|
|
2010-08-08 01:02:19 +00:00
|
|
|
bool getFrameCoords(int16 frame, int16 &x, int16 &y, int16 &width, int16 &height);
|
|
|
|
|
2010-08-08 00:57:27 +00:00
|
|
|
bool hasEmbeddedFiles() const;
|
|
|
|
bool hasEmbeddedFile(const Common::String &fileName) const;
|
2010-11-19 01:37:04 +00:00
|
|
|
Common::SeekableReadStream *getEmbeddedFile(const Common::String &fileName) const;
|
2010-08-08 00:57:27 +00:00
|
|
|
|
2010-08-08 01:05:16 +00:00
|
|
|
int32 getSubtitleIndex() const;
|
|
|
|
|
2011-01-20 12:28:22 +00:00
|
|
|
bool hasVideo() const;
|
|
|
|
bool isPaletted() const;
|
2011-01-16 16:27:52 +00:00
|
|
|
|
2011-02-07 17:54:16 +00:00
|
|
|
bool loadStream(Common::SeekableReadStream *stream);
|
2010-08-08 00:56:04 +00:00
|
|
|
void close();
|
|
|
|
|
|
|
|
bool isVideoLoaded() const;
|
|
|
|
|
2011-01-23 19:08:09 +00:00
|
|
|
const Graphics::Surface *decodeNextFrame();
|
2010-08-08 00:56:04 +00:00
|
|
|
|
2011-01-23 19:08:09 +00:00
|
|
|
Graphics::PixelFormat getPixelFormat() const;
|
2010-08-08 00:56:04 +00:00
|
|
|
|
2012-05-28 01:18:32 +00:00
|
|
|
protected:
|
2012-08-16 16:17:23 +00:00
|
|
|
void setAutoStartSound(bool autoStartSound);
|
2012-05-28 01:18:32 +00:00
|
|
|
|
2010-08-08 00:56:04 +00:00
|
|
|
private:
|
2010-08-08 00:56:58 +00:00
|
|
|
enum PartType {
|
|
|
|
kPartTypeSeparator = 0,
|
|
|
|
kPartTypeAudio = 1,
|
|
|
|
kPartTypeVideo = 2,
|
|
|
|
kPartTypeFile = 3,
|
|
|
|
kPartType4 = 4,
|
2010-08-08 00:58:59 +00:00
|
|
|
kPartTypeSubtitle = 5
|
2010-08-08 00:56:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum AudioFormat {
|
|
|
|
kAudioFormat8bitRaw = 0,
|
|
|
|
kAudioFormat16bitDPCM = 1,
|
|
|
|
kAudioFormat16bitADPCM = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
struct File {
|
|
|
|
Common::String name;
|
|
|
|
|
|
|
|
uint32 offset;
|
|
|
|
uint32 size;
|
|
|
|
uint32 realSize;
|
|
|
|
|
|
|
|
File();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Part {
|
|
|
|
PartType type;
|
|
|
|
byte field_1;
|
|
|
|
byte field_E;
|
|
|
|
uint32 size;
|
|
|
|
int16 left;
|
|
|
|
int16 top;
|
|
|
|
int16 right;
|
|
|
|
int16 bottom;
|
|
|
|
uint16 id;
|
|
|
|
byte flags;
|
|
|
|
|
|
|
|
Part();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Frame {
|
|
|
|
uint32 offset;
|
|
|
|
Part *parts;
|
|
|
|
|
|
|
|
Frame();
|
|
|
|
~Frame();
|
|
|
|
};
|
|
|
|
|
2010-08-08 00:56:04 +00:00
|
|
|
Common::SeekableReadStream *_stream;
|
|
|
|
|
2010-08-08 00:56:58 +00:00
|
|
|
byte _version;
|
|
|
|
uint32 _flags;
|
|
|
|
|
|
|
|
uint32 _frameInfoOffset;
|
|
|
|
uint16 _partsPerFrame;
|
|
|
|
Frame *_frames;
|
|
|
|
|
|
|
|
Common::Array<File> _files;
|
|
|
|
|
|
|
|
// Sound properties
|
|
|
|
uint16 _soundFlags;
|
|
|
|
int16 _soundFreq;
|
|
|
|
int16 _soundSliceSize;
|
|
|
|
int16 _soundSlicesCount;
|
|
|
|
byte _soundBytesPerSample;
|
|
|
|
byte _soundStereo; // (0: mono, 1: old-style stereo, 2: new-style stereo)
|
|
|
|
uint32 _soundHeaderSize;
|
|
|
|
uint32 _soundDataSize;
|
2011-01-24 14:09:47 +00:00
|
|
|
uint32 _soundLastFilledFrame;
|
2010-08-08 00:56:58 +00:00
|
|
|
AudioFormat _audioFormat;
|
2012-08-16 16:17:23 +00:00
|
|
|
bool _autoStartSound;
|
2010-08-08 00:56:58 +00:00
|
|
|
|
|
|
|
// Video properties
|
|
|
|
bool _hasVideo;
|
|
|
|
uint32 _videoCodec;
|
|
|
|
byte _blitMode;
|
|
|
|
byte _bytesPerPixel;
|
|
|
|
|
|
|
|
uint32 _firstFramePos; ///< Position of the first frame's data within the stream.
|
|
|
|
|
2011-01-16 16:26:52 +00:00
|
|
|
uint32 _videoBufferSize; ///< Size of the video buffers.
|
2011-01-16 16:29:43 +00:00
|
|
|
byte *_videoBuffer[3]; ///< Video buffers.
|
|
|
|
uint32 _videoBufferLen[3]; ///< Size of the video buffers filled.
|
|
|
|
|
2011-01-23 19:08:09 +00:00
|
|
|
Graphics::Surface _8bppSurface[3]; ///< Fake 8bpp surfaces over the video buffers.
|
2010-08-08 00:56:04 +00:00
|
|
|
|
2010-08-08 00:56:58 +00:00
|
|
|
bool _externalCodec;
|
|
|
|
Codec *_codec;
|
|
|
|
|
2010-08-08 01:05:16 +00:00
|
|
|
int32 _subtitle;
|
|
|
|
|
2011-01-16 16:27:52 +00:00
|
|
|
bool _isPaletted;
|
|
|
|
|
2010-08-08 00:56:58 +00:00
|
|
|
// Loading helper functions
|
|
|
|
bool assessVideoProperties();
|
|
|
|
bool assessAudioProperties();
|
2011-01-16 16:27:52 +00:00
|
|
|
bool openExternalCodec();
|
2010-08-08 00:56:58 +00:00
|
|
|
bool readFrameTable(int &numFiles);
|
|
|
|
bool readFiles();
|
|
|
|
|
2010-08-08 00:56:04 +00:00
|
|
|
// Frame decoding
|
|
|
|
void processFrame();
|
2010-08-08 00:58:59 +00:00
|
|
|
|
|
|
|
// Video
|
2010-08-08 00:59:58 +00:00
|
|
|
bool renderFrame(Common::Rect &rect);
|
2011-01-22 07:20:16 +00:00
|
|
|
bool getRenderRects(const Common::Rect &rect,
|
|
|
|
Common::Rect &realRect, Common::Rect &fakeRect);
|
2011-01-23 19:08:09 +00:00
|
|
|
void blit16(const Graphics::Surface &srcSurf, Common::Rect &rect);
|
|
|
|
void blit24(const Graphics::Surface &srcSurf, Common::Rect &rect);
|
2010-08-08 00:58:59 +00:00
|
|
|
|
|
|
|
// Sound
|
2010-08-08 00:59:28 +00:00
|
|
|
void emptySoundSlice (uint32 size);
|
|
|
|
void filledSoundSlice (uint32 size);
|
2010-08-08 00:58:59 +00:00
|
|
|
void filledSoundSlices(uint32 size, uint32 mask);
|
|
|
|
|
2010-08-08 00:59:28 +00:00
|
|
|
uint8 evaluateMask(uint32 mask, bool *fillInfo, uint8 &max);
|
|
|
|
|
2011-04-25 16:45:33 +00:00
|
|
|
// Generating audio streams
|
|
|
|
Audio::AudioStream *create8bitRaw (Common::SeekableReadStream *stream);
|
|
|
|
Audio::AudioStream *create16bitDPCM (Common::SeekableReadStream *stream);
|
|
|
|
Audio::AudioStream *create16bitADPCM(Common::SeekableReadStream *stream);
|
2010-08-08 01:02:19 +00:00
|
|
|
|
|
|
|
bool getPartCoords(int16 frame, PartType type, int16 &x, int16 &y, int16 &width, int16 &height);
|
2010-08-08 00:56:04 +00:00
|
|
|
};
|
|
|
|
|
2012-08-16 16:17:23 +00:00
|
|
|
/**
|
2012-08-16 18:00:14 +00:00
|
|
|
* A wrapper around the VMD code that implements the VideoDecoder
|
2012-08-16 16:17:23 +00:00
|
|
|
* API.
|
|
|
|
*/
|
2012-08-16 18:00:14 +00:00
|
|
|
class AdvancedVMDDecoder : public VideoDecoder {
|
2012-08-16 16:17:23 +00:00
|
|
|
public:
|
|
|
|
AdvancedVMDDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
|
|
|
|
~AdvancedVMDDecoder();
|
|
|
|
|
|
|
|
bool loadStream(Common::SeekableReadStream *stream);
|
|
|
|
void close();
|
|
|
|
|
|
|
|
private:
|
|
|
|
class VMDVideoTrack : public FixedRateVideoTrack {
|
|
|
|
public:
|
|
|
|
VMDVideoTrack(VMDDecoder *decoder);
|
|
|
|
|
|
|
|
uint16 getWidth() const;
|
|
|
|
uint16 getHeight() const;
|
|
|
|
Graphics::PixelFormat getPixelFormat() const;
|
|
|
|
int getCurFrame() const;
|
|
|
|
int getFrameCount() const;
|
|
|
|
const Graphics::Surface *decodeNextFrame();
|
|
|
|
const byte *getPalette() const;
|
|
|
|
bool hasDirtyPalette() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Common::Rational getFrameRate() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
VMDDecoder *_decoder;
|
|
|
|
};
|
|
|
|
|
|
|
|
class VMDAudioTrack : public AudioTrack {
|
|
|
|
public:
|
|
|
|
VMDAudioTrack(VMDDecoder *decoder);
|
|
|
|
|
|
|
|
Audio::Mixer::SoundType getSoundType() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual Audio::AudioStream *getAudioStream() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
VMDDecoder *_decoder;
|
|
|
|
};
|
|
|
|
|
|
|
|
VMDDecoder *_decoder;
|
|
|
|
VMDVideoTrack *_videoTrack;
|
|
|
|
VMDAudioTrack *_audioTrack;
|
|
|
|
};
|
|
|
|
|
2011-01-23 19:08:09 +00:00
|
|
|
} // End of namespace Video
|
2010-08-08 00:33:59 +00:00
|
|
|
|
2011-01-23 17:37:17 +00:00
|
|
|
#endif // VIDEO_COKTELDECODER_H
|
2010-08-08 00:33:59 +00:00
|
|
|
|
|
|
|
#endif // Engine and dynamic plugins guard
|