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
31namespace Audio {
32class QueuingAudioStream;
33}
34
35namespace Grim {
36
37class Codec48Decoder;
38class Blocky8;
39class Blocky16;
40
42public:
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
55protected:
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;
65 public:
66 SmushVideoTrack(int width, int height, int fps, int numFrames, bool is16Bit);
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();
88 const byte *getPalette() const override { _dirtyPalette = false; return _palette; }
89 bool hasDirtyPalette() const override { return _dirtyPalette; }
90
91 byte *getPal() { _dirtyPalette = true; return _palette; }
92 int _x, _y;
93 private:
94 void convertDemoFrame();
95 bool _is16Bit;
96 int32 _curFrame;
97 byte _palette[0x300];
98 int16 _deltaPal[0x300];
99 mutable bool _dirtyPalette;
100 int _width, _height;
101 Graphics::Surface _surface;
102 Graphics::PixelFormat _format;
103 Common::Rational _frameRate;
104 Blocky8 *_blocky8;
105 Blocky16 *_blocky16;
106 Codec48Decoder *_codec48;
107 int32 _nbframes;
108 int _frameStart;
109 };
110
112 public:
113 SmushAudioTrack(Audio::Mixer::SoundType soundType, bool isVima, int freq = 22050, int channels = -1);
115
116 Audio::AudioStream *getAudioStream() const override { return _queueStream; }
117 bool isSeekable() const override { return true; }
118 bool seek(const Audio::Timestamp &time) override;
119 void skipSamples(int samples);
120 inline int getRate() const { return _queueStream->getRate(); }
121
122 void handleVIMA(Common::SeekableReadStream *stream, uint32 size);
123 void handleIACT(Common::SeekableReadStream *stream, int32 size);
124 void init();
125 private:
126 bool _isVima;
127 byte _IACToutput[4096];
128 int32 _IACTpos;
129 int _channels;
130 int _freq;
131 Audio::QueuingAudioStream *_queueStream;
132 };
133private:
134 void initFrames();
135
136 SmushAudioTrack *_audioTrack;
137 SmushVideoTrack *_videoTrack;
138
140
141 uint32 _startPos;
142
143 bool _videoPause;
144 bool _videoLooping;
145 struct Frame {
146 int frame;
147 int pos;
148 bool keyframe;
149 };
150 Frame *_frames;
151 static bool _demo;
152};
153
154} // end of namespace Grim
155
156#endif
Definition: audiostream.h:50
virtual int getRate() const =0
SoundType
Definition: mixer.h:73
Definition: audiostream.h:370
Definition: timestamp.h:83
Definition: rational.h:40
Definition: stream.h:745
Definition: blocky16.h:29
Definition: blocky8.h:29
Definition: codec48.h:29
Definition: smush_decoder.h:111
Audio::AudioStream * getAudioStream() const override
Definition: smush_decoder.h:116
bool isSeekable() const override
Definition: smush_decoder.h:117
bool seek(const Audio::Timestamp &time) override
Definition: smush_decoder.h:64
Common::Rational getFrameRate() const override
Definition: smush_decoder.h:75
const byte * getPalette() const override
Definition: smush_decoder.h:88
int getCurFrame() const override
Definition: smush_decoder.h:72
uint16 getWidth() const override
Definition: smush_decoder.h:69
bool isSeekable() const override
Definition: smush_decoder.h:79
bool hasDirtyPalette() const override
Definition: smush_decoder.h:89
Graphics::PixelFormat getPixelFormat() const override
Definition: smush_decoder.h:71
Graphics::Surface * decodeNextFrame() override
int getFrameCount() const override
Definition: smush_decoder.h:74
uint16 getHeight() const override
Definition: smush_decoder.h:70
bool seek(const Audio::Timestamp &time) override
Definition: smush_decoder.h:80
Definition: smush_decoder.h:41
void close() override
bool isRewindable() const override
Definition: smush_decoder.h:49
bool loadStream(Common::SeekableReadStream *stream) override
bool seekIntern(const Audio::Timestamp &time) override
bool rewind() override
const Graphics::Surface * decodeNextFrame() override
bool isSeekable() const override
Definition: smush_decoder.h:50
Definition: video_decoder.h:759
Definition: video_decoder.h:734
Definition: video_decoder.h:53
Definition: system.h:39
Definition: pixelformat.h:138
Definition: surface.h:67