ScummVM API documentation
rlf_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 ZVISION_RLF_DECODER_H
23#define ZVISION_RLF_DECODER_H
24
25#include "common/file.h"
26#include "graphics/surface.h"
27#include "video/video_decoder.h"
28
29namespace ZVision {
30
32public:
33 RLFDecoder() {}
34 ~RLFDecoder() override;
35
36 bool loadStream(Common::SeekableReadStream *stream) override;
37
38private:
39 class RLFVideoTrack : public FixedRateVideoTrack {
40 public:
41 RLFVideoTrack(Common::SeekableReadStream *stream);
42 ~RLFVideoTrack() override;
43
44 uint16 getWidth() const override { return _width; }
45 uint16 getHeight() const override { return _height; }
46 Graphics::PixelFormat getPixelFormat() const override { return Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); /* RGB 555 */ }
47 int getCurFrame() const override { return _displayedFrame; }
48 int getFrameCount() const override { return _frameCount; }
49 const Graphics::Surface *decodeNextFrame() override;
50 bool isSeekable() const override { return true; }
51 bool seek(const Audio::Timestamp &time) override;
52
53 protected:
54 Common::Rational getFrameRate() const override { return Common::Rational(1000, _frameTime); }
55
56 private:
57 enum EncodingType {
58 Masked,
59 Simple
60 };
61
62 struct Frame {
63 EncodingType type;
64 int8 *encodedData;
65 uint32 encodedSize;
66 };
67
73 bool readHeader();
74
81 Frame readNextFrame();
82
90 void applyFrameToCurrent(uint frameNumber);
91
101 void decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
111 void decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const;
112
113 uint _lastFrameRead;
114
115 uint _frameCount;
116 uint _width;
117 uint _height;
118 uint32 _frameTime; // In milliseconds
119 Frame *_frames;
120 Common::Array<uint> _completeFrames;
121
122 int _displayedFrame;
123 Graphics::Surface _currentFrameBuffer;
124 uint32 _frameBufferByteSize;
125
126 Common::SeekableReadStream *_readStream;
127 }; // RLFVideoTrack
128};
129
130} // End of namespace ZVision
131
132#endif
Definition: timestamp.h:83
Definition: rational.h:40
Definition: stream.h:745
Definition: video_decoder.h:734
Definition: video_decoder.h:53
bool seek(const Audio::Timestamp &time)
Graphics::PixelFormat getPixelFormat() const
virtual uint16 getHeight() const
virtual bool isSeekable() const
virtual const Graphics::Surface * decodeNextFrame()
int getCurFrame() const
uint32 getFrameCount() const
virtual uint16 getWidth() const
Definition: rlf_decoder.h:31
bool loadStream(Common::SeekableReadStream *stream) override
Definition: focus_list.h:27
Definition: pixelformat.h:138
Definition: surface.h:67