ScummVM API documentation
animation.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef VOYEUR_ANIMATION_H
23#define VOYEUR_ANIMATION_H
24
25#include "video/video_decoder.h"
26#include "audio/audiostream.h"
27#include "audio/mixer.h"
28#include "common/array.h"
29#include "common/list.h"
30#include "common/rect.h"
31#include "common/stream.h"
32#include "voyeur/files.h"
33
34namespace Audio {
35class Timestamp;
36}
37
38namespace Voyeur {
39
40class VoyeurEngine;
41
49private:
50 class RL2FileHeader {
51 public:
52 RL2FileHeader();
53 ~RL2FileHeader();
54
55 int _channels;
56 int _colorCount;
57 int _numFrames;
58 int _rate;
59 int _soundRate;
60 int _videoBase;
61 int *_frameSoundSizes;
62
63 uint32 _backSize;
64 uint32 _signature;
65 uint32 *_frameOffsets;
66
67 byte _palette[768];
68
69 void load(Common::SeekableReadStream *stream);
70 Common::Rational getFrameRate() const;
71 bool isValid() const;
72
73 private:
74 uint32 _form; // Unused variable
75 uint32 _dataSize; // Unused variable
76 int _method; // Unused variable
77 int _defSoundSize;
78 };
79
80 class SoundFrame {
81 public:
82 int _offset;
83 int _size;
84
85 SoundFrame(int offset, int size);
86 };
87
88 class RL2AudioTrack : public AudioTrack {
89 private:
90 const RL2FileHeader &_header;
91 Audio::QueuingAudioStream *_audStream;
92 protected:
93 Audio::AudioStream *getAudioStream() const override;
94 public:
95 RL2AudioTrack(const RL2FileHeader &header, Common::SeekableReadStream *stream,
96 Audio::Mixer::SoundType soundType);
97 ~RL2AudioTrack() override;
98
99 int numQueuedStreams() const { return _audStream->numQueuedStreams(); }
100 bool isSeekable() const override { return true; }
101 bool seek(const Audio::Timestamp &time) override { return true; }
102
103 void queueSound(Common::SeekableReadStream *stream, int size);
104 };
105
106 class RL2VideoTrack : public FixedRateVideoTrack {
107 public:
108 RL2VideoTrack(const RL2FileHeader &header, RL2AudioTrack *audioTrack,
110 ~RL2VideoTrack() override;
111
112 uint16 getWidth() const override;
113 uint16 getHeight() const override;
114 Graphics::Surface *getSurface() { return _surface; }
115 Graphics::Surface *getBackSurface();
116 Graphics::PixelFormat getPixelFormat() const override;
117 int getCurFrame() const override { return _curFrame; }
118 int getFrameCount() const override { return _header._numFrames; }
119 const Graphics::Surface *decodeNextFrame() override;
120 const byte *getPalette() const override { _dirtyPalette = false; return _header._palette; }
121 int getPaletteCount() const { return _header._colorCount; }
122 bool hasDirtyPalette() const override { return _dirtyPalette; }
123 const Common::List<Common::Rect> *getDirtyRects() const { return &_dirtyRects; }
124 void clearDirtyRects() { _dirtyRects.clear(); }
125 void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
126
127 Common::Rational getFrameRate() const override { return _header.getFrameRate(); }
128 bool isSeekable() const override { return true; }
129 bool seek(const Audio::Timestamp &time) override;
130 private:
131 Common::SeekableReadStream *_fileStream;
132 const RL2FileHeader &_header;
133 Graphics::Surface *_surface;
134 Graphics::Surface *_backSurface;
135 bool _hasBackFrame;
136
137 mutable bool _dirtyPalette;
138
139 bool _initialFrame;
140 int _curFrame;
141 uint32 _videoBase;
142 uint32 *_frameOffsets;
143
144 Common::List<Common::Rect> _dirtyRects;
145
146 void copyFrame(uint8 *data);
147 void rl2DecodeFrameWithTransparency(int screenOffset);
148 void rl2DecodeFrameWithoutTransparency(int screenOffset = -1);
149 void initBackSurface();
150 };
151
152private:
153 RL2AudioTrack *_audioTrack;
154 RL2VideoTrack *_videoTrack;
155 Common::SeekableReadStream *_fileStream;
156 RL2FileHeader _header;
157 int _paletteStart;
158 Common::Array<SoundFrame> _soundFrames;
159 int _soundFrameNumber;
160 const Common::List<Common::Rect> *getDirtyRects() const;
161
162 void clearDirtyRects();
163 void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
164 int getPaletteStart() const { return _paletteStart; }
165 const RL2FileHeader &getHeader() { return _header; }
166 void readNextPacket() override;
167 bool seekIntern(const Audio::Timestamp &time) override;
168
169public:
170 RL2Decoder();
171 ~RL2Decoder() override;
172
173 void close() override;
174
176 bool loadRL2File(const Common::Path &file, bool palFlag);
177 bool loadVideo(int videoId);
178 int getPaletteCount() const { return _header._colorCount; }
179
187 void play(VoyeurEngine *vm, int resourceOffset = 0, byte *frames = nullptr, byte *imgPos = nullptr);
188 RL2VideoTrack *getRL2VideoTrack() { return _videoTrack; }
189 RL2AudioTrack *getRL2AudioTrack() { return _audioTrack; }
190};
191
192} // End of namespace Voyeur
193
194#endif /* VOYEUR_ANIMATION_H */
Definition: audiostream.h:50
SoundType
Definition: mixer.h:73
Definition: audiostream.h:370
virtual uint32 numQueuedStreams() const =0
Definition: timestamp.h:83
void clear()
Definition: list.h:245
Definition: path.h:52
Definition: rational.h:40
Definition: stream.h:745
Definition: video_decoder.h:759
Definition: video_decoder.h:734
Definition: video_decoder.h:53
bool seek(const Audio::Timestamp &time)
Graphics::PixelFormat getPixelFormat() const
bool hasDirtyPalette() const
Definition: video_decoder.h:337
virtual uint16 getHeight() const
const byte * getPalette()
virtual bool isSeekable() const
virtual const Graphics::Surface * decodeNextFrame()
int getCurFrame() const
uint32 getFrameCount() const
virtual uint16 getWidth() const
Definition: animation.h:48
void close() override
bool loadStream(Common::SeekableReadStream *stream) override
void play(VoyeurEngine *vm, int resourceOffset=0, byte *frames=nullptr, byte *imgPos=nullptr)
Definition: voyeur.h:78
Definition: system.h:39
Definition: animation.h:38
Definition: pixelformat.h:138
Definition: surface.h:67