ScummVM API documentation
flic_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_FLICDECODER_H
23 #define VIDEO_FLICDECODER_H
24 
25 #include "video/video_decoder.h"
26 #include "common/list.h"
27 #include "common/rect.h"
28 #include "graphics/palette.h"
29 
30 namespace Common {
31 class SeekableReadStream;
32 }
33 
34 namespace Graphics {
35 struct PixelFormat;
36 struct Surface;
37 }
38 
39 namespace Video {
40 
50 class FlicDecoder : public VideoDecoder {
51 public:
52  FlicDecoder();
53  virtual ~FlicDecoder();
54 
55  virtual bool loadStream(Common::SeekableReadStream *stream);
56 
57  const Common::List<Common::Rect> *getDirtyRects() const;
58  void clearDirtyRects();
59  void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
60 
61 protected:
62  class FlicVideoTrack : public VideoTrack {
63  public:
64  FlicVideoTrack(Common::SeekableReadStream *stream, uint16 frameCount, uint16 width, uint16 height, bool skipHeader = false);
65  ~FlicVideoTrack();
66 
67  virtual void readHeader();
68 
69  bool endOfTrack() const override;
70  virtual bool isRewindable() const override{ return true; }
71  virtual bool rewind() override;
72 
73  uint16 getWidth() const override;
74  uint16 getHeight() const override;
75  Graphics::PixelFormat getPixelFormat() const override;
76  int getCurFrame() const override { return _curFrame; }
77  int getCurFrameDelay() const override { return _frameDelay; }
78  int getFrameCount() const override { return _frameCount; }
79  uint32 getNextFrameStartTime() const override { return _nextFrameStartTime; }
80  virtual const Graphics::Surface *decodeNextFrame() override;
81  virtual void handleFrame();
82  const byte *getPalette() const override{ _dirtyPalette = false; return _palette.data(); }
83  bool hasDirtyPalette() const override { return _dirtyPalette; }
84 
85  const Common::List<Common::Rect> *getDirtyRects() const { return &_dirtyRects; }
86  void clearDirtyRects() { _dirtyRects.clear(); }
87  void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
88 
89  protected:
90  Common::SeekableReadStream *_fileStream;
91  Graphics::Surface *_surface;
92 
93  int _curFrame;
94  bool _atRingFrame;
95 
96  uint32 _offsetFrame1;
97  uint32 _offsetFrame2;
98  Graphics::Palette _palette;
99  mutable bool _dirtyPalette;
100 
101  uint32 _frameCount;
102  uint32 _frameDelay, _startFrameDelay;
103  uint32 _nextFrameStartTime;
104 
105  Common::List<Common::Rect> _dirtyRects;
106 
107  void copyFrame(uint8 *data);
108  void decodeByteRun(uint8 *data);
109  void decodeDeltaFLC(uint8 *data);
110  void unpackPalette(uint8 *mem);
111  };
112 };
113 
114 } // End of namespace Video
115 
116 #endif
Definition: flic_decoder.h:62
Definition: surface.h:67
bool hasDirtyPalette() const override
Definition: flic_decoder.h:83
Definition: pixelformat.h:138
int getCurFrame() const override
Definition: flic_decoder.h:76
Definition: stream.h:745
Definition: flic_decoder.h:50
const byte * getPalette() const override
Definition: flic_decoder.h:82
Definition: video_decoder.h:53
Definition: algorithm.h:29
uint32 getNextFrameStartTime() const override
Definition: flic_decoder.h:79
Definition: formatinfo.h:28
int getFrameCount() const override
Definition: flic_decoder.h:78
void clear()
Definition: list.h:245
int getCurFrameDelay() const override
Definition: flic_decoder.h:77
virtual bool isRewindable() const override
Definition: flic_decoder.h:70
Simple class for handling a palette data.
Definition: palette.h:55
Definition: animation.h:37
Definition: video_decoder.h:595