2009-12-29 23:18:24 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 01:34:27 +00:00
|
|
|
*
|
2009-12-29 23:18:24 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 01:34:27 +00:00
|
|
|
*
|
2009-12-29 23:18:24 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
2011-04-07 04:47:29 +00:00
|
|
|
// Partially based on ffmpeg code.
|
2009-12-29 23:18:24 +00:00
|
|
|
//
|
|
|
|
// Copyright (c) 2001 Fabrice Bellard.
|
|
|
|
// First version by Francois Revol revol@free.fr
|
|
|
|
// Seek function by Gael Chardon gael.dev@4now.net
|
|
|
|
//
|
|
|
|
|
2011-01-23 17:37:17 +00:00
|
|
|
#ifndef VIDEO_QT_DECODER_H
|
|
|
|
#define VIDEO_QT_DECODER_H
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2011-12-11 17:38:06 +00:00
|
|
|
#include "audio/decoders/quicktime_intern.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
#include "common/scummsys.h"
|
2010-05-18 14:59:20 +00:00
|
|
|
|
2011-01-23 17:37:17 +00:00
|
|
|
#include "video/video_decoder.h"
|
2010-05-18 14:59:20 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
namespace Common {
|
2012-07-27 15:32:51 +00:00
|
|
|
class Rational;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Graphics {
|
|
|
|
struct PixelFormat;
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 02:27:23 +00:00
|
|
|
namespace Image {
|
2011-04-24 08:34:27 +00:00
|
|
|
class Codec;
|
2014-02-28 02:27:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Video {
|
2011-04-24 08:34:27 +00:00
|
|
|
|
2011-01-23 01:27:40 +00:00
|
|
|
/**
|
|
|
|
* Decoder for QuickTime videos.
|
|
|
|
*
|
|
|
|
* Video decoder used in engines:
|
|
|
|
* - mohawk
|
2012-09-01 02:26:02 +00:00
|
|
|
* - pegasus
|
2011-01-23 01:27:40 +00:00
|
|
|
* - sci
|
|
|
|
*/
|
2012-08-16 18:00:14 +00:00
|
|
|
class QuickTimeDecoder : public VideoDecoder, public Audio::QuickTimeAudioDecoder {
|
2009-12-29 23:18:24 +00:00
|
|
|
public:
|
2010-05-23 18:33:55 +00:00
|
|
|
QuickTimeDecoder();
|
|
|
|
virtual ~QuickTimeDecoder();
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-05-23 23:26:28 +00:00
|
|
|
bool loadFile(const Common::String &filename);
|
2011-02-07 17:54:16 +00:00
|
|
|
bool loadStream(Common::SeekableReadStream *stream);
|
2010-05-18 14:59:20 +00:00
|
|
|
void close();
|
2012-07-27 15:32:51 +00:00
|
|
|
uint16 getWidth() const { return _width; }
|
|
|
|
uint16 getHeight() const { return _height; }
|
|
|
|
const Graphics::Surface *decodeNextFrame();
|
|
|
|
Audio::Timestamp getDuration() const { return Audio::Timestamp(0, _duration, _timeScale); }
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2012-07-27 15:32:51 +00:00
|
|
|
protected:
|
2012-09-09 17:47:40 +00:00
|
|
|
Common::QuickTimeParser::SampleDesc *readSampleDesc(Common::QuickTimeParser::Track *track, uint32 format, uint32 descSize);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2012-07-27 15:32:51 +00:00
|
|
|
private:
|
|
|
|
void init();
|
2011-12-11 17:38:06 +00:00
|
|
|
|
2012-07-27 15:32:51 +00:00
|
|
|
void updateAudioBuffer();
|
2010-05-18 14:59:20 +00:00
|
|
|
|
2012-07-27 15:32:51 +00:00
|
|
|
uint16 _width, _height;
|
|
|
|
|
|
|
|
Graphics::Surface *_scaledSurface;
|
|
|
|
void scaleSurface(const Graphics::Surface *src, Graphics::Surface *dst,
|
|
|
|
const Common::Rational &scaleFactorX, const Common::Rational &scaleFactorY);
|
2010-05-18 14:59:20 +00:00
|
|
|
|
2011-06-02 22:40:49 +00:00
|
|
|
class VideoSampleDesc : public Common::QuickTimeParser::SampleDesc {
|
|
|
|
public:
|
2011-06-03 04:54:30 +00:00
|
|
|
VideoSampleDesc(Common::QuickTimeParser::Track *parentTrack, uint32 codecTag);
|
2011-04-07 03:06:44 +00:00
|
|
|
~VideoSampleDesc();
|
2010-12-09 19:59:26 +00:00
|
|
|
|
2011-06-02 22:40:49 +00:00
|
|
|
void initCodec();
|
|
|
|
|
|
|
|
// TODO: Make private in the long run
|
|
|
|
uint16 _bitsPerSample;
|
|
|
|
char _codecName[32];
|
|
|
|
uint16 _colorTableId;
|
|
|
|
byte *_palette;
|
2014-02-28 02:27:23 +00:00
|
|
|
Image::Codec *_videoCodec;
|
2011-04-07 03:06:44 +00:00
|
|
|
};
|
|
|
|
|
2011-12-11 17:38:06 +00:00
|
|
|
// The AudioTrackHandler is currently just a wrapper around some
|
2012-03-17 22:15:06 +00:00
|
|
|
// QuickTimeDecoder functions.
|
2012-07-27 15:32:51 +00:00
|
|
|
class AudioTrackHandler : public SeekableAudioTrack {
|
2011-12-11 17:38:06 +00:00
|
|
|
public:
|
2012-03-17 22:15:06 +00:00
|
|
|
AudioTrackHandler(QuickTimeDecoder *decoder, QuickTimeAudioTrack *audioTrack);
|
2011-12-11 17:38:06 +00:00
|
|
|
|
|
|
|
void updateBuffer();
|
2012-07-27 15:32:51 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Audio::SeekableAudioStream *getSeekableAudioStream() const;
|
2012-03-17 22:15:06 +00:00
|
|
|
|
|
|
|
private:
|
2012-07-27 15:32:51 +00:00
|
|
|
QuickTimeDecoder *_decoder;
|
2012-03-17 22:15:06 +00:00
|
|
|
QuickTimeAudioTrack *_audioTrack;
|
2011-12-11 17:38:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// The VideoTrackHandler is the bridge between the time of playback
|
|
|
|
// and the media for the given track. It calculates when to start
|
|
|
|
// tracks and at what rate to play the media using the edit list.
|
2012-07-27 15:32:51 +00:00
|
|
|
class VideoTrackHandler : public VideoTrack {
|
2011-12-11 17:38:06 +00:00
|
|
|
public:
|
2012-07-27 15:32:51 +00:00
|
|
|
VideoTrackHandler(QuickTimeDecoder *decoder, Common::QuickTimeParser::Track *parent);
|
2011-12-11 17:38:06 +00:00
|
|
|
~VideoTrackHandler();
|
|
|
|
|
2012-07-27 15:32:51 +00:00
|
|
|
bool endOfTrack() const;
|
|
|
|
bool isSeekable() const { return true; }
|
|
|
|
bool seek(const Audio::Timestamp &time);
|
|
|
|
Audio::Timestamp getDuration() const;
|
2011-12-11 17:38:06 +00:00
|
|
|
|
2012-07-27 15:32:51 +00:00
|
|
|
uint16 getWidth() const;
|
|
|
|
uint16 getHeight() const;
|
2011-12-11 17:38:06 +00:00
|
|
|
Graphics::PixelFormat getPixelFormat() const;
|
2012-07-27 15:32:51 +00:00
|
|
|
int getCurFrame() const { return _curFrame; }
|
|
|
|
int getFrameCount() const;
|
|
|
|
uint32 getNextFrameStartTime() const;
|
|
|
|
const Graphics::Surface *decodeNextFrame();
|
2015-04-13 00:12:38 +00:00
|
|
|
const byte *getPalette() const;
|
2012-07-27 15:32:51 +00:00
|
|
|
bool hasDirtyPalette() const { return _curPalette; }
|
2012-12-16 01:43:43 +00:00
|
|
|
bool setReverse(bool reverse);
|
|
|
|
bool isReversed() const { return _reversed; }
|
2014-09-06 01:03:52 +00:00
|
|
|
bool canDither() const;
|
|
|
|
void setDither(const byte *palette);
|
2011-12-11 17:38:06 +00:00
|
|
|
|
2012-07-27 15:32:51 +00:00
|
|
|
Common::Rational getScaledWidth() const;
|
|
|
|
Common::Rational getScaledHeight() const;
|
2011-12-11 17:38:06 +00:00
|
|
|
|
|
|
|
private:
|
2012-07-27 15:32:51 +00:00
|
|
|
QuickTimeDecoder *_decoder;
|
|
|
|
Common::QuickTimeParser::Track *_parent;
|
|
|
|
uint32 _curEdit;
|
2011-12-11 17:38:06 +00:00
|
|
|
int32 _curFrame;
|
|
|
|
uint32 _nextFrameStartTime;
|
|
|
|
Graphics::Surface *_scaledSurface;
|
|
|
|
int32 _durationOverride;
|
2012-07-27 15:32:51 +00:00
|
|
|
const byte *_curPalette;
|
|
|
|
mutable bool _dirtyPalette;
|
2012-12-16 01:43:43 +00:00
|
|
|
bool _reversed;
|
2011-12-11 17:38:06 +00:00
|
|
|
|
2015-04-13 00:12:38 +00:00
|
|
|
// Forced dithering of frames
|
|
|
|
byte *_forcedDitherPalette;
|
|
|
|
byte *_ditherTable;
|
|
|
|
Graphics::Surface *_ditherFrame;
|
|
|
|
const Graphics::Surface *forceDither(const Graphics::Surface &frame);
|
|
|
|
|
2011-12-11 17:38:06 +00:00
|
|
|
Common::SeekableReadStream *getNextFramePacket(uint32 &descId);
|
|
|
|
uint32 getFrameDuration();
|
|
|
|
uint32 findKeyFrame(uint32 frame) const;
|
|
|
|
void enterNewEditList(bool bufferFrames);
|
|
|
|
const Graphics::Surface *bufferNextFrame();
|
|
|
|
uint32 getRateAdjustedFrameTime() const;
|
|
|
|
uint32 getCurEditTimeOffset() const;
|
|
|
|
uint32 getCurEditTrackDuration() const;
|
2012-12-16 01:43:43 +00:00
|
|
|
bool atLastEdit() const;
|
2015-01-16 06:51:31 +00:00
|
|
|
bool endOfCurEdit() const;
|
2011-12-11 17:38:06 +00:00
|
|
|
};
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
2011-01-23 19:08:09 +00:00
|
|
|
} // End of namespace Video
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
#endif
|