ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
33 namespace Common {
34 class SeekableReadStream;
35 }
36 
37 namespace Graphics {
38 struct PixelFormat;
39 }
40 
41 class PaletteManager;
42 
43 namespace Video {
44 
52 class 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;
106 
107  uint16 getWidth() const;
108  uint16 getHeight() const;
109 
110  Graphics::PixelFormat getPixelFormat() const;
111 
112  int getCurFrame() const;
113  // int getFrameCount() const;
114 
115  const Graphics::Surface *decodeNextFrame();
116  const byte *getPalette() const;
117  bool hasDirtyPalette() const;
118 
119  protected:
120  Common::Rational getFrameRate() const;
121  };
122 
123  class MveAudioTrack : public AudioTrack {
124  MveDecoder *_decoder;
125  public:
126  MveAudioTrack(MveDecoder *decoder);
127 
128  Audio::AudioStream *getAudioStream() const;
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 
155 public:
156  MveDecoder();
157  virtual ~MveDecoder();
158 
159  bool loadStream(Common::SeekableReadStream *stream);
160  void setAudioTrack(int track);
161  void applyPalette(PaletteManager *paletteManager);
162 
163  // const Common::List<Common::Rect> *getDirtyRects() const;
164  // void clearDirtyRects();
165  // void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
166 
167  Common::Rational getFrameRate() { return _frameRate; }
168  void readNextPacket();
169 };
170 
171 } // End of namespace Video
172 
173 #endif
uint16 readUint16LE()
Definition: stream.h:459
Definition: surface.h:67
Definition: video_decoder.h:698
Definition: pixelformat.h:138
Definition: mve_decoder.h:52
Definition: video_decoder.h:723
Definition: stream.h:745
Definition: rational.h:40
Definition: video_decoder.h:53
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: audiostream.h:50
Definition: memstream.h:43
Definition: audiostream.h:370
bool seek(int64 offs, int whence=SEEK_SET)
Simple class for handling a palette data.
Definition: palette.h:51
Definition: avi_frames.h:36
Definition: paletteman.h:47