ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

smush_decoder.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRIM_SMUSH_DECODER_H
00024 #define GRIM_SMUSH_DECODER_H
00025 
00026 #include "audio/audiostream.h"
00027 
00028 #include "video/video_decoder.h"
00029 
00030 #include "graphics/surface.h"
00031 
00032 namespace Audio {
00033 class QueuingAudioStream;
00034 }
00035 
00036 namespace Grim {
00037 
00038 class Codec48Decoder;
00039 class Blocky8;
00040 class Blocky16;
00041 
00042 class SmushDecoder : public Video::VideoDecoder {
00043 public:
00044     SmushDecoder();
00045     ~SmushDecoder();
00046 
00047     int getX() const { return _videoTrack->_x; }
00048     int getY() const { return _videoTrack->_y; }
00049     void setLooping(bool l);
00050     bool isRewindable() const override { return true; }
00051     bool isSeekable() const override { return true; }
00052     bool rewind() override;
00053     bool seekIntern(const Audio::Timestamp &time) override;
00054     bool loadStream(Common::SeekableReadStream *stream) override;
00055 
00056 protected:
00057     bool readHeader();
00058     void handleFrameDemo();
00059     void handleFrame();
00060     bool handleFramesHeader();
00061     void handleFRME(Common::SeekableReadStream *stream, uint32 size);
00062     void init();
00063     void close() override;
00064     const Graphics::Surface *decodeNextFrame() override;
00065     class SmushVideoTrack : public FixedRateVideoTrack {
00066     public:
00067         SmushVideoTrack(int width, int height, int fps, int numFrames, bool is16Bit);
00068         ~SmushVideoTrack();
00069 
00070         uint16 getWidth() const override { return _width; }
00071         uint16 getHeight() const override { return _height; }
00072         Graphics::PixelFormat getPixelFormat() const override { return _format; }
00073         int getCurFrame() const override { return _curFrame; }
00074         void setCurFrame(int frame) { _curFrame = frame; }
00075         int getFrameCount() const override {    return _nbframes; }
00076         Common::Rational getFrameRate() const override { return _frameRate; }
00077         void setMsPerFrame(int ms);
00078 
00079         void finishFrame();
00080         bool isSeekable() const override { return true; }
00081         bool seek(const Audio::Timestamp &time) override { return true; }
00082         void setFrameStart(int frame);
00083 
00084         void handleBlocky16(Common::SeekableReadStream *stream, uint32 size);
00085         void handleFrameObject(Common::SeekableReadStream *stream, uint32 size);
00086         void handleDeltaPalette(Common::SeekableReadStream *stream, int32 size);
00087         void init();
00088         Graphics::Surface *decodeNextFrame() override;
00089 
00090         byte *getPal() { return _pal; }
00091         int _x, _y;
00092     private:
00093         void convertDemoFrame();
00094         bool _is16Bit;
00095         int32 _curFrame;
00096         byte _pal[0x300];
00097         int16 _deltaPal[0x300];
00098         int _width, _height;
00099         Graphics::Surface _surface;
00100         Graphics::PixelFormat _format;
00101         Common::Rational _frameRate;
00102         Blocky8 *_blocky8;
00103         Blocky16 *_blocky16;
00104         Codec48Decoder *_codec48;
00105         int32 _nbframes;
00106         int _frameStart;
00107     };
00108 
00109     class SmushAudioTrack : public AudioTrack {
00110     public:
00111         SmushAudioTrack(Audio::Mixer::SoundType soundType, bool isVima, int freq = 22050, int channels = -1);
00112         ~SmushAudioTrack();
00113 
00114         Audio::AudioStream *getAudioStream() const override { return _queueStream; }
00115         bool isSeekable() const override { return true; }
00116         bool seek(const Audio::Timestamp &time) override;
00117         void skipSamples(int samples);
00118         inline int getRate() const { return _queueStream->getRate(); }
00119 
00120         void handleVIMA(Common::SeekableReadStream *stream, uint32 size);
00121         void handleIACT(Common::SeekableReadStream *stream, int32 size);
00122         void init();
00123     private:
00124         bool _isVima;
00125         byte _IACToutput[4096];
00126         int32 _IACTpos;
00127         int _channels;
00128         int _freq;
00129         Audio::QueuingAudioStream *_queueStream;
00130     };
00131 private:
00132     void initFrames();
00133 
00134     SmushAudioTrack *_audioTrack;
00135     SmushVideoTrack *_videoTrack;
00136 
00137     Common::SeekableReadStream *_file;
00138 
00139     uint32 _startPos;
00140 
00141     bool _videoPause;
00142     bool _videoLooping;
00143     struct Frame {
00144         int frame;
00145         int pos;
00146         bool keyframe;
00147     };
00148     Frame *_frames;
00149     static bool _demo;
00150 };
00151 
00152 } // end of namespace Grim
00153 
00154 #endif


Generated on Sat Feb 16 2019 05:01:04 for ResidualVM by doxygen 1.7.1
curved edge   curved edge