ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
paco_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_PACODECODER_H
23 #define VIDEO_PACODECODER_H
24 
25 #include "audio/audiostream.h"
26 #include "common/list.h"
27 #include "common/rect.h"
28 #include "graphics/palette.h"
29 #include "video/video_decoder.h"
30 
31 namespace Common {
32 class SeekableReadStream;
33 }
34 
35 namespace Graphics {
36 struct PixelFormat;
37 struct Surface;
38 } // namespace Graphics
39 
40 namespace Video {
41 
48 class PacoDecoder : public VideoDecoder {
49 public:
50  PacoDecoder();
51  virtual ~PacoDecoder();
52  void close() override;
53 
54  virtual bool loadStream(Common::SeekableReadStream *stream) override;
55 
56  const Common::List<Common::Rect> *getDirtyRects() const;
57  void clearDirtyRects();
58  void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
59  const byte *getPalette();
60  virtual void readNextPacket() override;
61 
62 
63 protected:
65  public:
67  uint16 frameRate, uint16 frameCount, uint16 width, uint16 height);
68  ~PacoVideoTrack();
69 
70  bool endOfTrack() const override;
71  virtual bool isRewindable() const override { return false; }
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 getFrameCount() const override { return _frameCount; }
78  virtual const Graphics::Surface *decodeNextFrame() override;
79  virtual void handleFrame(Common::SeekableReadStream *fileStream, uint32 chunkSize, int curFrame);
80  virtual void handleEOC() { _curFrame += 1; };
81  void handlePalette(Common::SeekableReadStream *fileStream);
82  const byte *getPalette() const override;
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  Common::Rational getFrameRate() const override { return Common::Rational(_frameRate, 1); }
89 
90  protected:
91  Graphics::Surface *_surface;
92  Graphics::Palette _palette;
93 
94  mutable bool _dirtyPalette;
95 
96  int _curFrame;
97  uint32 _frameCount;
98  uint16 _frameRate;
99 
100  Common::List<Common::Rect> _dirtyRects;
101  };
102 
103  class PacoAudioTrack : public AudioTrack {
104  public:
105  PacoAudioTrack(int samplingRate);
106  ~PacoAudioTrack();
107  void queueSound(Common::SeekableReadStream *fileStream, uint32 chunkSize);
108 
109  protected:
110  Audio::AudioStream *getAudioStream() const { return _packetStream; }
111 
112  private:
113  Audio::PacketizedAudioStream *_packetStream;
114  int _samplingRate;
115  };
116 
117 private:
118  PacoVideoTrack *_videoTrack;
119  PacoAudioTrack *_audioTrack;
120  Common::SeekableReadStream *_fileStream;
121  int _curFrame = 0;
122  int _frameSizes[65536]; // can be done differently?
123  int getAudioSamplingRate();
124 };
125 
126 } // End of namespace Video
127 
128 #endif
Definition: surface.h:67
Definition: video_decoder.h:698
Definition: pixelformat.h:138
Definition: video_decoder.h:723
Definition: stream.h:745
Definition: audiostream.h:446
Definition: rational.h:40
Definition: video_decoder.h:53
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: audiostream.h:50
void clear()
Definition: list.h:245
Definition: paco_decoder.h:64
Definition: paco_decoder.h:48
Simple class for handling a palette data.
Definition: palette.h:51
Definition: avi_frames.h:36
Definition: paco_decoder.h:103