ScummVM API documentation
mve_decoder.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 VIDEO_MVEDECODER_H
23#define VIDEO_MVEDECODER_H
24
25#include "audio/audiostream.h"
26#include "video/video_decoder.h"
27#include "graphics/palette.h"
28#include "graphics/surface.h"
29#include "common/list.h"
30#include "common/rect.h"
31#include "common/memstream.h"
32
33namespace Common {
34class SeekableReadStream;
35}
36
37namespace Graphics {
38struct PixelFormat;
39}
40
41class PaletteManager;
42
43namespace Video {
44
52class MveDecoder : public VideoDecoder {
53 bool _done;
55
56 uint16 _packetLen;
57 uint16 _packetKind;
58
59 Graphics::Surface _decodeSurface0;
60 Graphics::Surface _decodeSurface1;
61 Graphics::Surface _frameSurface;
62
63 uint16 _widthInBlocks;
64 uint16 _heightInBlocks;
65
66 uint16 _width;
67 uint16 _height;
68
69 Common::Rational _frameRate;
70
71 bool _trueColor;
72 Graphics::PixelFormat _pixelFormat;
73 bool _dirtyPalette;
74 uint16 _palStart;
75 uint16 _palCount;
76 Graphics::Palette _palette;
77
78 uint16 _skipMapSize;
79 byte *_skipMap;
80
81 uint16 _decodingMapSize;
82 byte *_decodingMap;
83
84 int _frameNumber;
85 uint16 _frameSize;
86 byte *_frameData;
87
88 int _audioTrack;
89 Audio::QueuingAudioStream *_audioStream;
90
91 void readPacketHeader();
92 void copyBlock_8bit(Graphics::Surface &dst, Common::MemoryReadStream &s, int block);
93 void copyBlock_16bit(Graphics::Surface &dst, Common::MemoryReadStream &s, int block);
94 void copyBlock(Graphics::Surface &dst, Graphics::Surface &src, int block, int offset = 0);
95 void copyBlock(Graphics::Surface &dst, Graphics::Surface &src, int dx, int dy, int off_x, int off_y);
96
97 void decodeFormat6();
98 void decodeFormat10();
99
100 class MveVideoTrack : public FixedRateVideoTrack {
101 MveDecoder *_decoder;
102 public:
103 MveVideoTrack(MveDecoder *decoder);
104
105 bool endOfTrack() const override;
106
107 uint16 getWidth() const override;
108 uint16 getHeight() const override;
109
110 Graphics::PixelFormat getPixelFormat() const override;
111
112 int getCurFrame() const override;
113 // int getFrameCount() const;
114
115 const Graphics::Surface *decodeNextFrame() override;
116 const byte *getPalette() const override;
117 bool hasDirtyPalette() const override;
118
119 protected:
120 Common::Rational getFrameRate() const override;
121 };
122
123 class MveAudioTrack : public AudioTrack {
124 MveDecoder *_decoder;
125 public:
126 MveAudioTrack(MveDecoder *decoder);
127
128 Audio::AudioStream *getAudioStream() const override;
129 };
130
131 class MveSkipStream {
133 uint16 queue;
134 public:
135 MveSkipStream(byte *p, size_t sz)
136 : s(p, sz), queue(0x8000)
137 {}
138
139 void reset() {
140 s.seek(0);
141 queue = 0x8000;
142 }
143
144 bool skip() {
145 if (queue == 0x8000) {
146 queue = s.readUint16LE();
147 assert(queue != 0);
148 }
149 bool r = (queue & 0x8000) == 0;
150 queue <<= 1;
151 return r;
152 }
153 };
154
155public:
156 MveDecoder();
157 virtual ~MveDecoder();
158
159 void close() override;
161 void setAudioTrack(int track);
162 void applyPalette(PaletteManager *paletteManager);
163
164 // const Common::List<Common::Rect> *getDirtyRects() const;
165 // void clearDirtyRects();
166 // void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
167
168 Common::Rational getFrameRate() { return _frameRate; }
169 void readNextPacket() override;
170};
171
172} // End of namespace Video
173
174#endif
Definition: audiostream.h:50
Definition: audiostream.h:370
Definition: memstream.h:43
bool seek(int64 offs, int whence=SEEK_SET) override
Definition: rational.h:40
uint16 readUint16LE()
Definition: stream.h:459
Definition: stream.h:745
Simple class for handling a palette data.
Definition: palette.h:61
Definition: paletteman.h:47
Definition: mve_decoder.h:52
void readNextPacket() override
bool loadStream(Common::SeekableReadStream *stream) override
void close() override
Definition: video_decoder.h:759
Definition: video_decoder.h:734
Definition: video_decoder.h:53
Graphics::PixelFormat getPixelFormat() const
bool hasDirtyPalette() const
Definition: video_decoder.h:337
virtual uint16 getHeight() const
const byte * getPalette()
virtual const Graphics::Surface * decodeNextFrame()
int getCurFrame() const
virtual uint16 getWidth() const
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: pixelformat.h:138
Definition: surface.h:67