ScummVM API documentation
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 class SafeSeekableSubReadStream;
34 }
35 
36 namespace Graphics {
37 struct PixelFormat;
38 struct Surface;
39 } // namespace Graphics
40 
41 namespace Video {
42 
49 class PacoDecoder : public VideoDecoder {
50 public:
51  PacoDecoder();
52  virtual ~PacoDecoder();
53  void close() override;
54 
55  virtual bool loadStream(Common::SeekableReadStream *stream) override;
56 
57  const Common::List<Common::Rect> *getDirtyRects() const;
58  void clearDirtyRects();
59  void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
60  const byte *getPalette();
61  virtual void readNextPacket() override;
62 
63 
64 protected:
66  public:
68  uint16 frameRate, uint16 frameCount, uint16 width, uint16 height);
69  ~PacoVideoTrack();
70 
71  bool endOfTrack() const override;
72  virtual bool isRewindable() const override { return false; }
73 
74  uint16 getWidth() const override;
75  uint16 getHeight() const override;
76  Graphics::PixelFormat getPixelFormat() const override;
77  int getCurFrame() const override { return _curFrame; }
78  int getFrameCount() const override { return _frameCount; }
79  virtual const Graphics::Surface *decodeNextFrame() override;
80  virtual void handleFrame(Common::SeekableReadStream *fileStream, uint32 chunkSize, int curFrame);
81  virtual void handleEOC() { _curFrame += 1; };
82  void handlePalette(Common::SeekableReadStream *fileStream);
83  const byte *getPalette() const override;
84  bool hasDirtyPalette() const override { return _dirtyPalette; }
85 
86  const Common::List<Common::Rect> *getDirtyRects() const { return &_dirtyRects; }
87  void clearDirtyRects() { _dirtyRects.clear(); }
88  void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
89  Common::Rational getFrameRate() const override { return Common::Rational(_frameRate, 1); }
90 
91  protected:
92  Graphics::Surface *_surface;
93  Graphics::Palette _palette;
94 
95  mutable bool _dirtyPalette;
96 
97  int _curFrame;
98  uint32 _frameCount;
99  uint16 _frameRate;
100 
101  Common::List<Common::Rect> _dirtyRects;
102  };
103 
104  class PacoAudioTrack : public AudioTrack {
105  public:
106  PacoAudioTrack(int samplingRate);
107  ~PacoAudioTrack();
108  void queueSound(Common::SeekableReadStream *fileStream, uint32 chunkSize);
109  bool needsAudio() const;
110 
111  protected:
112  Audio::AudioStream *getAudioStream() const { return _packetStream; }
113 
114  private:
116  int _samplingRate;
117  };
118 
119 private:
120  PacoVideoTrack *_videoTrack;
121  PacoAudioTrack *_audioTrack;
122  Common::SeekableReadStream *_fileStream;
123  Common::SafeSeekableSubReadStream *_videoStream;
124  Common::SafeSeekableSubReadStream *_audioStream;
125  int _curFrame = 0;
126  int _frameSizes[65536]; // can be done differently?
127  int getAudioSamplingRate();
128 };
129 
130 } // End of namespace Video
131 
132 #endif
Definition: surface.h:67
Definition: video_decoder.h:713
Definition: substream.h:104
Definition: pixelformat.h:138
Definition: video_decoder.h:738
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
void clear()
Definition: list.h:245
Definition: paco_decoder.h:65
Definition: audiostream.h:471
Definition: paco_decoder.h:49
Simple class for handling a palette data.
Definition: palette.h:61
Definition: animation.h:37
Definition: paco_decoder.h:104