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