ScummVM API documentation
smush_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 GRIM_SMUSH_DECODER_H
23 #define GRIM_SMUSH_DECODER_H
24 
25 #include "audio/audiostream.h"
26 
27 #include "video/video_decoder.h"
28 
29 #include "graphics/surface.h"
30 
31 namespace Audio {
32 class QueuingAudioStream;
33 }
34 
35 namespace Grim {
36 
37 class Codec48Decoder;
38 class Blocky8;
39 class Blocky16;
40 
42 public:
43  SmushDecoder();
44  ~SmushDecoder();
45 
46  int getX() const { return _videoTrack->_x; }
47  int getY() const { return _videoTrack->_y; }
48  void setLooping(bool l);
49  bool isRewindable() const override { return true; }
50  bool isSeekable() const override { return true; }
51  bool rewind() override;
52  bool seekIntern(const Audio::Timestamp &time) override;
53  bool loadStream(Common::SeekableReadStream *stream) override;
54 
55 protected:
56  bool readHeader();
57  void handleFrameDemo();
58  void handleFrame();
59  bool handleFramesHeader();
60  void handleFRME(Common::SeekableReadStream *stream, uint32 size);
61  void init();
62  void close() override;
63  const Graphics::Surface *decodeNextFrame() override;
65  public:
66  SmushVideoTrack(int width, int height, int fps, int numFrames, bool is16Bit);
67  ~SmushVideoTrack();
68 
69  uint16 getWidth() const override { return _width; }
70  uint16 getHeight() const override { return _height; }
71  Graphics::PixelFormat getPixelFormat() const override { return _format; }
72  int getCurFrame() const override { return _curFrame; }
73  void setCurFrame(int frame) { _curFrame = frame; }
74  int getFrameCount() const override { return _nbframes; }
75  Common::Rational getFrameRate() const override { return _frameRate; }
76  void setMsPerFrame(int ms);
77 
78  void finishFrame();
79  bool isSeekable() const override { return true; }
80  bool seek(const Audio::Timestamp &time) override { return true; }
81  void setFrameStart(int frame);
82 
83  void handleBlocky16(Common::SeekableReadStream *stream, uint32 size);
84  void handleFrameObject(Common::SeekableReadStream *stream, uint32 size);
85  void handleDeltaPalette(Common::SeekableReadStream *stream, int32 size);
86  void init();
87  Graphics::Surface *decodeNextFrame() override;
88 
89  byte *getPal() { return _pal; }
90  int _x, _y;
91  private:
92  void convertDemoFrame();
93  bool _is16Bit;
94  int32 _curFrame;
95  byte _pal[0x300];
96  int16 _deltaPal[0x300];
97  int _width, _height;
98  Graphics::Surface _surface;
99  Graphics::PixelFormat _format;
100  Common::Rational _frameRate;
101  Blocky8 *_blocky8;
102  Blocky16 *_blocky16;
103  Codec48Decoder *_codec48;
104  int32 _nbframes;
105  int _frameStart;
106  };
107 
108  class SmushAudioTrack : public AudioTrack {
109  public:
110  SmushAudioTrack(Audio::Mixer::SoundType soundType, bool isVima, int freq = 22050, int channels = -1);
111  ~SmushAudioTrack();
112 
113  Audio::AudioStream *getAudioStream() const override { return _queueStream; }
114  bool isSeekable() const override { return true; }
115  bool seek(const Audio::Timestamp &time) override;
116  void skipSamples(int samples);
117  inline int getRate() const { return _queueStream->getRate(); }
118 
119  void handleVIMA(Common::SeekableReadStream *stream, uint32 size);
120  void handleIACT(Common::SeekableReadStream *stream, int32 size);
121  void init();
122  private:
123  bool _isVima;
124  byte _IACToutput[4096];
125  int32 _IACTpos;
126  int _channels;
127  int _freq;
128  Audio::QueuingAudioStream *_queueStream;
129  };
130 private:
131  void initFrames();
132 
133  SmushAudioTrack *_audioTrack;
134  SmushVideoTrack *_videoTrack;
135 
137 
138  uint32 _startPos;
139 
140  bool _videoPause;
141  bool _videoLooping;
142  struct Frame {
143  int frame;
144  int pos;
145  bool keyframe;
146  };
147  Frame *_frames;
148  static bool _demo;
149 };
150 
151 } // end of namespace Grim
152 
153 #endif
Definition: surface.h:67
Definition: smush_decoder.h:41
Definition: codec48.h:29
Definition: blocky8.h:29
Definition: video_decoder.h:675
Definition: smush_decoder.h:64
Definition: pixelformat.h:138
Definition: smush_decoder.h:108
Definition: video_decoder.h:700
Definition: timestamp.h:83
Definition: stream.h:745
bool isRewindable() const override
Definition: smush_decoder.h:49
Definition: rational.h:40
Definition: actor.h:33
SoundType
Definition: mixer.h:62
Definition: video_decoder.h:52
Definition: audiostream.h:50
Definition: blocky16.h:29
Definition: audiostream.h:370
bool isSeekable() const override
Definition: smush_decoder.h:50
Definition: system.h:38