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 "video/video_decoder.h"
29 
30 namespace Common {
31 class SeekableReadStream;
32 }
33 
34 namespace Graphics {
35 struct PixelFormat;
36 struct Surface;
37 } // namespace Graphics
38 
39 namespace Video {
40 
47 class PacoDecoder : public VideoDecoder {
48 public:
49  PacoDecoder();
50  virtual ~PacoDecoder();
51  void close() override;
52 
53  virtual bool loadStream(Common::SeekableReadStream *stream) override;
54 
55  const Common::List<Common::Rect> *getDirtyRects() const;
56  void clearDirtyRects();
57  void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
58  const byte *getPalette();
59  virtual void readNextPacket() override;
60 
61 
62 protected:
64  public:
66  uint16 frameRate, uint16 frameCount, uint16 width, uint16 height);
67  ~PacoVideoTrack();
68 
69  bool endOfTrack() const override;
70  virtual bool isRewindable() const override { return false; }
71 
72  uint16 getWidth() const override;
73  uint16 getHeight() const override;
74  Graphics::PixelFormat getPixelFormat() const override;
75  int getCurFrame() const override { return _curFrame; }
76  int getFrameCount() const override { return _frameCount; }
77  virtual const Graphics::Surface *decodeNextFrame() override;
78  virtual void handleFrame(Common::SeekableReadStream *fileStream, uint32 chunkSize, int curFrame);
79  virtual void handleEOC() { _curFrame += 1; };
80  void handlePalette(Common::SeekableReadStream *fileStream);
81  const byte *getPalette() const override;
82  bool hasDirtyPalette() const override { return _dirtyPalette; }
83 
84  const Common::List<Common::Rect> *getDirtyRects() const { return &_dirtyRects; }
85  void clearDirtyRects() { _dirtyRects.clear(); }
86  void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
87  Common::Rational getFrameRate() const override { return Common::Rational(_frameRate, 1); }
88 
89  protected:
90  Graphics::Surface *_surface;
91 
92  byte *_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:686
Definition: pixelformat.h:138
Definition: video_decoder.h:711
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:206
Definition: paco_decoder.h:63
Definition: paco_decoder.h:47
Definition: avi_frames.h:36
Definition: paco_decoder.h:103