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

qt_decoder.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM 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 //
00024 // Partially based on ffmpeg code.
00025 //
00026 // Copyright (c) 2001 Fabrice Bellard.
00027 // First version by Francois Revol revol@free.fr
00028 // Seek function by Gael Chardon gael.dev@4now.net
00029 //
00030 
00031 #ifndef VIDEO_QT_DECODER_H
00032 #define VIDEO_QT_DECODER_H
00033 
00034 #include "audio/decoders/quicktime_intern.h"
00035 #include "common/scummsys.h"
00036 
00037 #include "video/video_decoder.h"
00038 
00039 namespace Common {
00040 class Rational;
00041 }
00042 
00043 namespace Graphics {
00044 struct PixelFormat;
00045 }
00046 
00047 namespace Image {
00048 class Codec;
00049 }
00050 
00051 namespace Video {
00052 
00061 class QuickTimeDecoder : public VideoDecoder, public Audio::QuickTimeAudioDecoder {
00062 public:
00063     QuickTimeDecoder();
00064     virtual ~QuickTimeDecoder();
00065 
00066     bool loadFile(const Common::String &filename);
00067     bool loadStream(Common::SeekableReadStream *stream);
00068     void close();
00069     uint16 getWidth() const { return _width; }
00070     uint16 getHeight() const { return _height; }
00071     const Graphics::Surface *decodeNextFrame();
00072     Audio::Timestamp getDuration() const { return Audio::Timestamp(0, _duration, _timeScale); }
00073 
00074 protected:
00075     Common::QuickTimeParser::SampleDesc *readSampleDesc(Common::QuickTimeParser::Track *track, uint32 format, uint32 descSize);
00076 
00077 private:
00078     void init();
00079 
00080     void updateAudioBuffer();
00081 
00082     uint16 _width, _height;
00083 
00084     Graphics::Surface *_scaledSurface;
00085     void scaleSurface(const Graphics::Surface *src, Graphics::Surface *dst,
00086             const Common::Rational &scaleFactorX, const Common::Rational &scaleFactorY);
00087 
00088     class VideoSampleDesc : public Common::QuickTimeParser::SampleDesc {
00089     public:
00090         VideoSampleDesc(Common::QuickTimeParser::Track *parentTrack, uint32 codecTag);
00091         ~VideoSampleDesc();
00092 
00093         void initCodec();
00094 
00095         // TODO: Make private in the long run
00096         uint16 _bitsPerSample;
00097         char _codecName[32];
00098         uint16 _colorTableId;
00099         byte *_palette;
00100         Image::Codec *_videoCodec;
00101     };
00102 
00103     // The AudioTrackHandler is currently just a wrapper around some
00104     // QuickTimeDecoder functions.
00105     class AudioTrackHandler : public SeekableAudioTrack {
00106     public:
00107         AudioTrackHandler(QuickTimeDecoder *decoder, QuickTimeAudioTrack *audioTrack);
00108 
00109         void updateBuffer();
00110 
00111     protected:
00112         Audio::SeekableAudioStream *getSeekableAudioStream() const;
00113 
00114     private:
00115         QuickTimeDecoder *_decoder;
00116         QuickTimeAudioTrack *_audioTrack;
00117     };
00118 
00119     // The VideoTrackHandler is the bridge between the time of playback
00120     // and the media for the given track. It calculates when to start
00121     // tracks and at what rate to play the media using the edit list.
00122     class VideoTrackHandler : public VideoTrack {
00123     public:
00124         VideoTrackHandler(QuickTimeDecoder *decoder, Common::QuickTimeParser::Track *parent);
00125         ~VideoTrackHandler();
00126 
00127         bool endOfTrack() const;
00128         bool isSeekable() const { return true; }
00129         bool seek(const Audio::Timestamp &time);
00130         Audio::Timestamp getDuration() const;
00131 
00132         uint16 getWidth() const;
00133         uint16 getHeight() const;
00134         Graphics::PixelFormat getPixelFormat() const;
00135         int getCurFrame() const { return _curFrame; }
00136         int getFrameCount() const;
00137         uint32 getNextFrameStartTime() const;
00138         const Graphics::Surface *decodeNextFrame();
00139         const byte *getPalette() const;
00140         bool hasDirtyPalette() const { return _curPalette; }
00141         bool setReverse(bool reverse);
00142         bool isReversed() const { return _reversed; }
00143         bool canDither() const;
00144         void setDither(const byte *palette);
00145 
00146         Common::Rational getScaledWidth() const;
00147         Common::Rational getScaledHeight() const;
00148 
00149     private:
00150         QuickTimeDecoder *_decoder;
00151         Common::QuickTimeParser::Track *_parent;
00152         uint32 _curEdit;
00153         int32 _curFrame;
00154         uint32 _nextFrameStartTime;
00155         Graphics::Surface *_scaledSurface;
00156         int32 _durationOverride;
00157         const byte *_curPalette;
00158         mutable bool _dirtyPalette;
00159         bool _reversed;
00160 
00161         // Forced dithering of frames
00162         byte *_forcedDitherPalette;
00163         byte *_ditherTable;
00164         Graphics::Surface *_ditherFrame;
00165         const Graphics::Surface *forceDither(const Graphics::Surface &frame);
00166 
00167         Common::SeekableReadStream *getNextFramePacket(uint32 &descId);
00168         uint32 getFrameDuration();
00169         uint32 findKeyFrame(uint32 frame) const;
00170         void enterNewEditList(bool bufferFrames);
00171         const Graphics::Surface *bufferNextFrame();
00172         uint32 getRateAdjustedFrameTime() const;
00173         uint32 getCurEditTimeOffset() const;
00174         uint32 getCurEditTrackDuration() const;
00175         bool atLastEdit() const;
00176         bool endOfCurEdit() const;
00177         void checkEditListBounds();
00178     };
00179 };
00180 
00181 } // End of namespace Video
00182 
00183 #endif


Generated on Sat Oct 19 2019 05:01:27 for ResidualVM by doxygen 1.7.1
curved edge   curved edge