aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/agos/animation.cpp2
-rw-r--r--engines/mohawk/video.h4
-rw-r--r--engines/sci/console.cpp2
-rw-r--r--engines/sci/engine/kvideo.cpp2
-rw-r--r--engines/sci/video/robot_decoder.cpp2
-rw-r--r--engines/sci/video/robot_decoder.h2
-rw-r--r--engines/sci/video/seq_decoder.h2
-rw-r--r--engines/scumm/he/animation_he.cpp4
-rw-r--r--engines/sword1/animation.cpp6
-rw-r--r--engines/sword2/animation.cpp6
-rw-r--r--video/avi_decoder.cpp2
-rw-r--r--video/avi_decoder.h2
-rw-r--r--video/bink_decoder.cpp2
-rw-r--r--video/bink_decoder.h2
-rw-r--r--video/coktel_decoder.cpp2
-rw-r--r--video/coktel_decoder.h4
-rw-r--r--video/dxa_decoder.h2
-rw-r--r--video/flic_decoder.h2
-rw-r--r--video/psx_decoder.cpp2
-rw-r--r--video/psx_decoder.h2
-rw-r--r--video/qt_decoder.cpp6
-rw-r--r--video/qt_decoder.h2
-rw-r--r--video/smk_decoder.cpp4
-rw-r--r--video/smk_decoder.h2
-rw-r--r--video/theora_decoder.cpp2
-rw-r--r--video/theora_decoder.h2
-rw-r--r--video/video_decoder.cpp219
-rw-r--r--video/video_decoder.h123
28 files changed, 164 insertions, 250 deletions
diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp
index 8fc93e4153..10f274b37f 100644
--- a/engines/agos/animation.cpp
+++ b/engines/agos/animation.cpp
@@ -342,7 +342,7 @@ bool MoviePlayerDXA::processFrame() {
_vm->_system->unlockScreen();
uint32 soundTime = _mixer->getSoundElapsedTime(_bgSound);
- uint32 nextFrameStartTime = ((Video::AdvancedVideoDecoder::VideoTrack *)getTrack(0))->getNextFrameStartTime();
+ uint32 nextFrameStartTime = ((Video::VideoDecoder::VideoTrack *)getTrack(0))->getNextFrameStartTime();
if ((_bgSoundStream == NULL) || soundTime < nextFrameStartTime) {
diff --git a/engines/mohawk/video.h b/engines/mohawk/video.h
index 4e34604bfd..9dddcde09b 100644
--- a/engines/mohawk/video.h
+++ b/engines/mohawk/video.h
@@ -45,7 +45,7 @@ struct MLSTRecord {
struct VideoEntry {
// Playback variables
- Video::AdvancedVideoDecoder *video;
+ Video::VideoDecoder *video;
uint16 x;
uint16 y;
bool loop;
@@ -57,7 +57,7 @@ struct VideoEntry {
int id; // Internal Mohawk files
// Helper functions
- Video::AdvancedVideoDecoder *operator->() const { assert(video); return video; } // TODO: Remove this eventually
+ Video::VideoDecoder *operator->() const { assert(video); return video; } // TODO: Remove this eventually
void clear();
bool endOfVideo();
};
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index de852ca9c0..1889d53480 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -267,8 +267,6 @@ void Console::postEnter() {
}
if (videoDecoder && videoDecoder->loadFile(_videoFile)) {
- ((Video::AdvancedVideoDecoder *)videoDecoder)->start();
-
_engine->_gfxCursor->kernelHide();
#ifdef ENABLE_SCI32
diff --git a/engines/sci/engine/kvideo.cpp b/engines/sci/engine/kvideo.cpp
index 3e0f35c037..6bf9aff2fe 100644
--- a/engines/sci/engine/kvideo.cpp
+++ b/engines/sci/engine/kvideo.cpp
@@ -50,7 +50,7 @@ void playVideo(Video::VideoDecoder *videoDecoder, VideoState videoState) {
if (!videoDecoder)
return;
- ((Video::AdvancedVideoDecoder *)videoDecoder)->start();
+ videoDecoder->start();
byte *scaleBuffer = 0;
byte bytesPerPixel = videoDecoder->getPixelFormat().bytesPerPixel;
diff --git a/engines/sci/video/robot_decoder.cpp b/engines/sci/video/robot_decoder.cpp
index 6fe4c645f4..608c77136f 100644
--- a/engines/sci/video/robot_decoder.cpp
+++ b/engines/sci/video/robot_decoder.cpp
@@ -132,7 +132,7 @@ bool RobotDecoder::load(GuiResourceId id) {
}
void RobotDecoder::close() {
- AdvancedVideoDecoder::close();
+ VideoDecoder::close();
delete _fileStream;
_fileStream = 0;
diff --git a/engines/sci/video/robot_decoder.h b/engines/sci/video/robot_decoder.h
index de5b669ab8..ebc3262939 100644
--- a/engines/sci/video/robot_decoder.h
+++ b/engines/sci/video/robot_decoder.h
@@ -37,7 +37,7 @@ class SeekableSubReadStreamEndian;
namespace Sci {
-class RobotDecoder : public Video::AdvancedVideoDecoder {
+class RobotDecoder : public Video::VideoDecoder {
public:
RobotDecoder(bool isBigEndian);
virtual ~RobotDecoder();
diff --git a/engines/sci/video/seq_decoder.h b/engines/sci/video/seq_decoder.h
index 82254990d6..890f349feb 100644
--- a/engines/sci/video/seq_decoder.h
+++ b/engines/sci/video/seq_decoder.h
@@ -40,7 +40,7 @@ namespace Sci {
/**
* Implementation of the Sierra SEQ decoder, used in KQ6 DOS floppy/CD and GK1 DOS
*/
-class SEQDecoder : public Video::AdvancedVideoDecoder {
+class SEQDecoder : public Video::VideoDecoder {
public:
SEQDecoder(uint frameDelay);
virtual ~SEQDecoder();
diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp
index 8329511c14..be17a3b305 100644
--- a/engines/scumm/he/animation_he.cpp
+++ b/engines/scumm/he/animation_he.cpp
@@ -62,14 +62,14 @@ int MoviePlayer::load(const char *filename, int flags, int image) {
_video->close();
// Ensure that Bink will use our PixelFormat
- ((Video::AdvancedVideoDecoder *)_video)->setDefaultHighColorFormat(g_system->getScreenFormat());
+ _video->setDefaultHighColorFormat(g_system->getScreenFormat());
if (!_video->loadFile(filename)) {
warning("Failed to load video file %s", filename);
return -1;
}
- ((Video::AdvancedVideoDecoder *)_video)->start();
+ _video->start();
debug(1, "Playing video %s", filename);
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index 98725a302a..f7add4eed2 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -183,7 +183,7 @@ bool MoviePlayer::load(uint32 id) {
// Need to load here in case it fails in which case we'd need
// to go back to paletted mode
if (_decoder->loadFile(filename)) {
- ((Video::AdvancedVideoDecoder *)_decoder)->start(); // TODO: Remove after new API is complete
+ _decoder->start();
return true;
} else {
initGraphics(g_system->getWidth(), g_system->getHeight(), true);
@@ -197,9 +197,9 @@ bool MoviePlayer::load(uint32 id) {
// For DXA, also add the external sound file
if (_decoderType == kVideoDecoderDXA)
- ((Video::AdvancedVideoDecoder *)_decoder)->addStreamFileTrack(sequenceList[id]);
+ _decoder->addStreamFileTrack(sequenceList[id]);
- ((Video::AdvancedVideoDecoder *)_decoder)->start(); // TODO: Remove after new API is complete
+ _decoder->start();
return true;
}
diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp
index 24b52cd85a..00260f789a 100644
--- a/engines/sword2/animation.cpp
+++ b/engines/sword2/animation.cpp
@@ -95,7 +95,7 @@ bool MoviePlayer::load(const char *name) {
// Need to load here in case it fails in which case we'd need
// to go back to paletted mode
if (_decoder->loadFile(filename)) {
- ((Video::AdvancedVideoDecoder *)_decoder)->start(); // TODO: Remove after new API is complete
+ _decoder->start();
return true;
} else {
initGraphics(640, 480, true);
@@ -108,9 +108,9 @@ bool MoviePlayer::load(const char *name) {
// For DXA, also add the external sound file
if (_decoderType == kVideoDecoderDXA)
- ((Video::AdvancedVideoDecoder *)_decoder)->addStreamFileTrack(name);
+ _decoder->addStreamFileTrack(name);
- ((Video::AdvancedVideoDecoder *)_decoder)->start(); // TODO: Remove after new API is complete
+ _decoder->start();
return true;
}
diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp
index 375cc6f0f3..0850d5656a 100644
--- a/video/avi_decoder.cpp
+++ b/video/avi_decoder.cpp
@@ -289,7 +289,7 @@ bool AVIDecoder::loadStream(Common::SeekableReadStream *stream) {
}
void AVIDecoder::close() {
- AdvancedVideoDecoder::close();
+ VideoDecoder::close();
delete _fileStream;
_fileStream = 0;
diff --git a/video/avi_decoder.h b/video/avi_decoder.h
index 010702cce3..a3a262db36 100644
--- a/video/avi_decoder.h
+++ b/video/avi_decoder.h
@@ -53,7 +53,7 @@ class Codec;
* Video decoder used in engines:
* - sci
*/
-class AVIDecoder : public AdvancedVideoDecoder {
+class AVIDecoder : public VideoDecoder {
public:
AVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
virtual ~AVIDecoder();
diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp
index cac0b356c5..620316806f 100644
--- a/video/bink_decoder.cpp
+++ b/video/bink_decoder.cpp
@@ -147,7 +147,7 @@ bool BinkDecoder::loadStream(Common::SeekableReadStream *stream) {
}
void BinkDecoder::close() {
- AdvancedVideoDecoder::close();
+ VideoDecoder::close();
delete _bink;
_bink = 0;
diff --git a/video/bink_decoder.h b/video/bink_decoder.h
index 836238ce99..150e91aab7 100644
--- a/video/bink_decoder.h
+++ b/video/bink_decoder.h
@@ -62,7 +62,7 @@ namespace Video {
* Video decoder used in engines:
* - scumm (he)
*/
-class BinkDecoder : public AdvancedVideoDecoder {
+class BinkDecoder : public VideoDecoder {
public:
BinkDecoder();
~BinkDecoder();
diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp
index 42033fb01f..6a60b0e7d7 100644
--- a/video/coktel_decoder.cpp
+++ b/video/coktel_decoder.cpp
@@ -2800,7 +2800,7 @@ bool AdvancedVMDDecoder::loadStream(Common::SeekableReadStream *stream) {
}
void AdvancedVMDDecoder::close() {
- AdvancedVideoDecoder::close();
+ VideoDecoder::close();
_decoder->close();
}
diff --git a/video/coktel_decoder.h b/video/coktel_decoder.h
index 117a55658f..2a97eadf00 100644
--- a/video/coktel_decoder.h
+++ b/video/coktel_decoder.h
@@ -550,10 +550,10 @@ private:
};
/**
- * A wrapper around the VMD code that implements the AdvancedVideoDecoder
+ * A wrapper around the VMD code that implements the VideoDecoder
* API.
*/
-class AdvancedVMDDecoder : public AdvancedVideoDecoder {
+class AdvancedVMDDecoder : public VideoDecoder {
public:
AdvancedVMDDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
~AdvancedVMDDecoder();
diff --git a/video/dxa_decoder.h b/video/dxa_decoder.h
index a0caca4b95..b3f2eca5e2 100644
--- a/video/dxa_decoder.h
+++ b/video/dxa_decoder.h
@@ -41,7 +41,7 @@ namespace Video {
* - sword1
* - sword2
*/
-class DXADecoder : public AdvancedVideoDecoder {
+class DXADecoder : public VideoDecoder {
public:
DXADecoder();
virtual ~DXADecoder();
diff --git a/video/flic_decoder.h b/video/flic_decoder.h
index 9b82161ca5..9037af05d6 100644
--- a/video/flic_decoder.h
+++ b/video/flic_decoder.h
@@ -44,7 +44,7 @@ namespace Video {
* Video decoder used in engines:
* - tucker
*/
-class FlicDecoder : public AdvancedVideoDecoder {
+class FlicDecoder : public VideoDecoder {
public:
FlicDecoder();
virtual ~FlicDecoder();
diff --git a/video/psx_decoder.cpp b/video/psx_decoder.cpp
index 93bf711c25..fa7f1e8cfe 100644
--- a/video/psx_decoder.cpp
+++ b/video/psx_decoder.cpp
@@ -174,7 +174,7 @@ bool PSXStreamDecoder::loadStream(Common::SeekableReadStream *stream) {
}
void PSXStreamDecoder::close() {
- AdvancedVideoDecoder::close();
+ VideoDecoder::close();
_audioTrack = 0;
_videoTrack = 0;
_frameCount = 0;
diff --git a/video/psx_decoder.h b/video/psx_decoder.h
index 2a9dedf77f..11f311594d 100644
--- a/video/psx_decoder.h
+++ b/video/psx_decoder.h
@@ -56,7 +56,7 @@ namespace Video {
* - sword1 (psx)
* - sword2 (psx)
*/
-class PSXStreamDecoder : public AdvancedVideoDecoder {
+class PSXStreamDecoder : public VideoDecoder {
public:
// CD speed in sectors/second
// Calling code should use these enum values instead of the constants
diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp
index 70dcdff9c6..87c530dba0 100644
--- a/video/qt_decoder.cpp
+++ b/video/qt_decoder.cpp
@@ -79,7 +79,7 @@ bool QuickTimeDecoder::loadStream(Common::SeekableReadStream *stream) {
}
void QuickTimeDecoder::close() {
- AdvancedVideoDecoder::close();
+ VideoDecoder::close();
Common::QuickTimeParser::close();
if (_scaledSurface) {
@@ -90,7 +90,7 @@ void QuickTimeDecoder::close() {
}
const Graphics::Surface *QuickTimeDecoder::decodeNextFrame() {
- const Graphics::Surface *frame = AdvancedVideoDecoder::decodeNextFrame();
+ const Graphics::Surface *frame = VideoDecoder::decodeNextFrame();
// Update audio buffers too
// (needs to be done after we find the next track)
@@ -244,7 +244,7 @@ void QuickTimeDecoder::init() {
void QuickTimeDecoder::updateAudioBuffer() {
// Updates the audio buffers for all audio tracks
for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++)
- if ((*it)->getTrackType() == AdvancedVideoDecoder::Track::kTrackTypeAudio)
+ if ((*it)->getTrackType() == VideoDecoder::Track::kTrackTypeAudio)
((AudioTrackHandler *)*it)->updateBuffer();
}
diff --git a/video/qt_decoder.h b/video/qt_decoder.h
index 7a251b8580..71d33711a6 100644
--- a/video/qt_decoder.h
+++ b/video/qt_decoder.h
@@ -55,7 +55,7 @@ class Codec;
* - mohawk
* - sci
*/
-class QuickTimeDecoder : public AdvancedVideoDecoder, public Audio::QuickTimeAudioDecoder {
+class QuickTimeDecoder : public VideoDecoder, public Audio::QuickTimeAudioDecoder {
public:
QuickTimeDecoder();
virtual ~QuickTimeDecoder();
diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp
index d707ad519f..d01ec730f4 100644
--- a/video/smk_decoder.cpp
+++ b/video/smk_decoder.cpp
@@ -396,7 +396,7 @@ bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
}
void SmackerDecoder::close() {
- AdvancedVideoDecoder::close();
+ VideoDecoder::close();
delete _fileStream;
_fileStream = 0;
@@ -411,7 +411,7 @@ void SmackerDecoder::close() {
bool SmackerDecoder::rewind() {
// Call the parent method to rewind the tracks first
// In particular, only videos without sound can be rewound
- if (!AdvancedVideoDecoder::rewind())
+ if (!VideoDecoder::rewind())
return false;
// And seek back to where the first frame begins
diff --git a/video/smk_decoder.h b/video/smk_decoder.h
index 78a4ded0fc..6bded64a37 100644
--- a/video/smk_decoder.h
+++ b/video/smk_decoder.h
@@ -57,7 +57,7 @@ class BigHuffmanTree;
* - sword2
* - toon
*/
-class SmackerDecoder : public AdvancedVideoDecoder {
+class SmackerDecoder : public VideoDecoder {
public:
SmackerDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kSFXSoundType);
virtual ~SmackerDecoder();
diff --git a/video/theora_decoder.cpp b/video/theora_decoder.cpp
index 76007eadff..d7260469e6 100644
--- a/video/theora_decoder.cpp
+++ b/video/theora_decoder.cpp
@@ -198,7 +198,7 @@ bool TheoraDecoder::loadStream(Common::SeekableReadStream *stream) {
}
void TheoraDecoder::close() {
- AdvancedVideoDecoder::close();
+ VideoDecoder::close();
if (!_fileStream)
return;
diff --git a/video/theora_decoder.h b/video/theora_decoder.h
index 2244f7550d..7e36d829e7 100644
--- a/video/theora_decoder.h
+++ b/video/theora_decoder.h
@@ -52,7 +52,7 @@ namespace Video {
* Video decoder used in engines:
* - sword25
*/
-class TheoraDecoder : public AdvancedVideoDecoder {
+class TheoraDecoder : public VideoDecoder {
public:
TheoraDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType);
virtual ~TheoraDecoder();
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index fc4d7e1ae7..cf11649c10 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -35,9 +35,44 @@ namespace Video {
VideoDecoder::VideoDecoder() {
_startTime = 0;
+ _needsRewind = false;
+ _dirtyPalette = false;
+ _palette = 0;
+ _isPlaying = false;
+ _audioVolume = Audio::Mixer::kMaxChannelVolume;
+ _audioBalance = 0;
_pauseLevel = 0;
+ _needsUpdate = false;
+ _lastTimeChange = 0;
+ _endTime = 0;
+ _endTimeSet = false;
+
+ // Find the best format for output
+ _defaultHighColorFormat = g_system->getScreenFormat();
+
+ if (_defaultHighColorFormat.bytesPerPixel == 1)
+ _defaultHighColorFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0);
+}
+
+void VideoDecoder::close() {
+ if (isPlaying())
+ stop();
+
+ for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
+ delete *it;
+
+ _tracks.clear();
+ _needsRewind = false;
+ _dirtyPalette = false;
+ _palette = 0;
+ _startTime = 0;
_audioVolume = Audio::Mixer::kMaxChannelVolume;
_audioBalance = 0;
+ _pauseLevel = 0;
+ _needsUpdate = false;
+ _lastTimeChange = 0;
+ _endTime = 0;
+ _endTimeSet = false;
}
bool VideoDecoder::loadFile(const Common::String &filename) {
@@ -51,10 +86,6 @@ bool VideoDecoder::loadFile(const Common::String &filename) {
return loadStream(file);
}
-uint32 VideoDecoder::getTime() const {
- return g_system->getMillis() - _startTime;
-}
-
bool VideoDecoder::needsUpdate() const {
return !endOfVideo() && getTimeToNextFrame() == 0;
}
@@ -74,9 +105,13 @@ void VideoDecoder::pauseVideo(bool pause) {
if (_pauseLevel == 1 && pause) {
_pauseStartTime = g_system->getMillis(); // Store the starting time from pausing to keep it for later
- pauseVideoIntern(true);
+
+ for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
+ (*it)->pause(true);
} else if (_pauseLevel == 0) {
- pauseVideoIntern(false);
+ for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
+ (*it)->pause(false);
+
_startTime += (g_system->getMillis() - _pauseStartTime);
}
}
@@ -88,60 +123,25 @@ void VideoDecoder::resetPauseStartTime() {
void VideoDecoder::setVolume(byte volume) {
_audioVolume = volume;
- updateVolume();
+
+ for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
+ if ((*it)->getTrackType() == Track::kTrackTypeAudio)
+ ((AudioTrack *)*it)->setVolume(_audioVolume);
}
void VideoDecoder::setBalance(int8 balance) {
_audioBalance = balance;
- updateBalance();
-}
-
-AdvancedVideoDecoder::AdvancedVideoDecoder() {
- _needsRewind = false;
- _dirtyPalette = false;
- _palette = 0;
- _isPlaying = false;
- _audioVolume = Audio::Mixer::kMaxChannelVolume;
- _audioBalance = 0;
- _pauseLevel = 0;
- _needsUpdate = false;
- _lastTimeChange = 0;
- _endTime = 0;
- _endTimeSet = false;
-
- // Find the best format for output
- _defaultHighColorFormat = g_system->getScreenFormat();
-
- if (_defaultHighColorFormat.bytesPerPixel == 1)
- _defaultHighColorFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0);
-}
-
-void AdvancedVideoDecoder::close() {
- if (isPlaying())
- stop();
for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- delete *it;
-
- _tracks.clear();
- _needsRewind = false;
- _dirtyPalette = false;
- _palette = 0;
- _startTime = 0;
- _audioVolume = Audio::Mixer::kMaxChannelVolume;
- _audioBalance = 0;
- _pauseLevel = 0;
- _needsUpdate = false;
- _lastTimeChange = 0;
- _endTime = 0;
- _endTimeSet = false;
+ if ((*it)->getTrackType() == Track::kTrackTypeAudio)
+ ((AudioTrack *)*it)->setBalance(_audioBalance);
}
-bool AdvancedVideoDecoder::isVideoLoaded() const {
+bool VideoDecoder::isVideoLoaded() const {
return !_tracks.empty();
}
-uint16 AdvancedVideoDecoder::getWidth() const {
+uint16 VideoDecoder::getWidth() const {
for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
if ((*it)->getTrackType() == Track::kTrackTypeVideo)
return ((VideoTrack *)*it)->getWidth();
@@ -149,7 +149,7 @@ uint16 AdvancedVideoDecoder::getWidth() const {
return 0;
}
-uint16 AdvancedVideoDecoder::getHeight() const {
+uint16 VideoDecoder::getHeight() const {
for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
if ((*it)->getTrackType() == Track::kTrackTypeVideo)
return ((VideoTrack *)*it)->getHeight();
@@ -157,7 +157,7 @@ uint16 AdvancedVideoDecoder::getHeight() const {
return 0;
}
-Graphics::PixelFormat AdvancedVideoDecoder::getPixelFormat() const {
+Graphics::PixelFormat VideoDecoder::getPixelFormat() const {
for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
if ((*it)->getTrackType() == Track::kTrackTypeVideo)
return ((VideoTrack *)*it)->getPixelFormat();
@@ -165,7 +165,7 @@ Graphics::PixelFormat AdvancedVideoDecoder::getPixelFormat() const {
return Graphics::PixelFormat();
}
-const Graphics::Surface *AdvancedVideoDecoder::decodeNextFrame() {
+const Graphics::Surface *VideoDecoder::decodeNextFrame() {
_needsUpdate = false;
readNextPacket();
@@ -184,12 +184,12 @@ const Graphics::Surface *AdvancedVideoDecoder::decodeNextFrame() {
return frame;
}
-const byte *AdvancedVideoDecoder::getPalette() {
+const byte *VideoDecoder::getPalette() {
_dirtyPalette = false;
return _palette;
}
-int AdvancedVideoDecoder::getCurFrame() const {
+int VideoDecoder::getCurFrame() const {
int32 frame = -1;
for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
@@ -199,7 +199,7 @@ int AdvancedVideoDecoder::getCurFrame() const {
return frame;
}
-uint32 AdvancedVideoDecoder::getFrameCount() const {
+uint32 VideoDecoder::getFrameCount() const {
int count = 0;
for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
@@ -209,7 +209,7 @@ uint32 AdvancedVideoDecoder::getFrameCount() const {
return count;
}
-uint32 AdvancedVideoDecoder::getTime() const {
+uint32 VideoDecoder::getTime() const {
if (!isPlaying())
return _lastTimeChange.msecs();
@@ -230,7 +230,7 @@ uint32 AdvancedVideoDecoder::getTime() const {
return g_system->getMillis() - _startTime;
}
-uint32 AdvancedVideoDecoder::getTimeToNextFrame() const {
+uint32 VideoDecoder::getTimeToNextFrame() const {
if (endOfVideo() || _needsUpdate)
return 0;
@@ -248,9 +248,7 @@ uint32 AdvancedVideoDecoder::getTimeToNextFrame() const {
return nextFrameStartTime - elapsedTime;
}
-bool AdvancedVideoDecoder::endOfVideo() const {
- // TODO: Bring _isPlaying into account?
-
+bool VideoDecoder::endOfVideo() const {
if (!isVideoLoaded())
return true;
@@ -268,7 +266,7 @@ bool AdvancedVideoDecoder::endOfVideo() const {
return true;
}
-bool AdvancedVideoDecoder::isRewindable() const {
+bool VideoDecoder::isRewindable() const {
if (!isVideoLoaded())
return false;
@@ -279,7 +277,7 @@ bool AdvancedVideoDecoder::isRewindable() const {
return true;
}
-bool AdvancedVideoDecoder::rewind() {
+bool VideoDecoder::rewind() {
if (!isRewindable())
return false;
@@ -303,7 +301,7 @@ bool AdvancedVideoDecoder::rewind() {
return true;
}
-bool AdvancedVideoDecoder::isSeekable() const {
+bool VideoDecoder::isSeekable() const {
if (!isVideoLoaded())
return false;
@@ -314,7 +312,7 @@ bool AdvancedVideoDecoder::isSeekable() const {
return true;
}
-bool AdvancedVideoDecoder::seek(const Audio::Timestamp &time) {
+bool VideoDecoder::seek(const Audio::Timestamp &time) {
if (!isSeekable())
return false;
@@ -342,7 +340,7 @@ bool AdvancedVideoDecoder::seek(const Audio::Timestamp &time) {
return true;
}
-void AdvancedVideoDecoder::start() {
+void VideoDecoder::start() {
if (isPlaying() || !isVideoLoaded())
return;
@@ -360,7 +358,7 @@ void AdvancedVideoDecoder::start() {
startAudio();
}
-void AdvancedVideoDecoder::stop() {
+void VideoDecoder::stop() {
if (!isPlaying())
return;
@@ -386,7 +384,7 @@ void AdvancedVideoDecoder::stop() {
}
}
-Audio::Timestamp AdvancedVideoDecoder::getDuration() const {
+Audio::Timestamp VideoDecoder::getDuration() const {
Audio::Timestamp maxDuration(0, 1000);
for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) {
@@ -399,42 +397,23 @@ Audio::Timestamp AdvancedVideoDecoder::getDuration() const {
return maxDuration;
}
-void AdvancedVideoDecoder::pauseVideoIntern(bool pause) {
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- (*it)->pause(pause);
-}
-
-void AdvancedVideoDecoder::updateVolume() {
- // For API compatibility only
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeAudio)
- ((AudioTrack *)*it)->setVolume(_audioVolume);
-}
-
-void AdvancedVideoDecoder::updateBalance() {
- // For API compatibility only
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
- if ((*it)->getTrackType() == Track::kTrackTypeAudio)
- ((AudioTrack *)*it)->setBalance(_audioBalance);
-}
-
-AdvancedVideoDecoder::Track::Track() {
+VideoDecoder::Track::Track() {
_paused = false;
}
-bool AdvancedVideoDecoder::Track::isRewindable() const {
+bool VideoDecoder::Track::isRewindable() const {
return isSeekable();
}
-bool AdvancedVideoDecoder::Track::rewind() {
+bool VideoDecoder::Track::rewind() {
return seek(Audio::Timestamp(0, 1000));
}
-Audio::Timestamp AdvancedVideoDecoder::Track::getDuration() const {
+Audio::Timestamp VideoDecoder::Track::getDuration() const {
return Audio::Timestamp(0, 1000);
}
-uint32 AdvancedVideoDecoder::FixedRateVideoTrack::getNextFrameStartTime() const {
+uint32 VideoDecoder::FixedRateVideoTrack::getNextFrameStartTime() const {
if (endOfTrack() || getCurFrame() < 0)
return 0;
@@ -443,11 +422,11 @@ uint32 AdvancedVideoDecoder::FixedRateVideoTrack::getNextFrameStartTime() const
return time.toInt();
}
-bool AdvancedVideoDecoder::FixedRateVideoTrack::endOfTrack() const {
+bool VideoDecoder::FixedRateVideoTrack::endOfTrack() const {
return getCurFrame() >= (getFrameCount() - 1);
}
-Audio::Timestamp AdvancedVideoDecoder::FixedRateVideoTrack::getDuration() const {
+Audio::Timestamp VideoDecoder::FixedRateVideoTrack::getDuration() const {
// Since Audio::Timestamp doesn't support a fractional frame rate, we're currently
// just converting to milliseconds.
Common::Rational time = getFrameCount() * 1000;
@@ -455,26 +434,26 @@ Audio::Timestamp AdvancedVideoDecoder::FixedRateVideoTrack::getDuration() const
return time.toInt();
}
-bool AdvancedVideoDecoder::AudioTrack::endOfTrack() const {
+bool VideoDecoder::AudioTrack::endOfTrack() const {
Audio::AudioStream *stream = getAudioStream();
return !stream || !g_system->getMixer()->isSoundHandleActive(_handle) || stream->endOfData();
}
-void AdvancedVideoDecoder::AudioTrack::setVolume(byte volume) {
+void VideoDecoder::AudioTrack::setVolume(byte volume) {
_volume = volume;
if (g_system->getMixer()->isSoundHandleActive(_handle))
g_system->getMixer()->setChannelVolume(_handle, _volume);
}
-void AdvancedVideoDecoder::AudioTrack::setBalance(int8 balance) {
+void VideoDecoder::AudioTrack::setBalance(int8 balance) {
_balance = balance;
if (g_system->getMixer()->isSoundHandleActive(_handle))
g_system->getMixer()->setChannelBalance(_handle, _balance);
}
-void AdvancedVideoDecoder::AudioTrack::start() {
+void VideoDecoder::AudioTrack::start() {
stop();
Audio::AudioStream *stream = getAudioStream();
@@ -487,11 +466,11 @@ void AdvancedVideoDecoder::AudioTrack::start() {
g_system->getMixer()->pauseHandle(_handle, true);
}
-void AdvancedVideoDecoder::AudioTrack::stop() {
+void VideoDecoder::AudioTrack::stop() {
g_system->getMixer()->stopHandle(_handle);
}
-void AdvancedVideoDecoder::AudioTrack::start(const Audio::Timestamp &limit) {
+void VideoDecoder::AudioTrack::start(const Audio::Timestamp &limit) {
stop();
Audio::AudioStream *stream = getAudioStream();
@@ -506,60 +485,60 @@ void AdvancedVideoDecoder::AudioTrack::start(const Audio::Timestamp &limit) {
g_system->getMixer()->pauseHandle(_handle, true);
}
-uint32 AdvancedVideoDecoder::AudioTrack::getRunningTime() const {
+uint32 VideoDecoder::AudioTrack::getRunningTime() const {
if (g_system->getMixer()->isSoundHandleActive(_handle))
return g_system->getMixer()->getSoundElapsedTime(_handle);
return 0;
}
-void AdvancedVideoDecoder::AudioTrack::pauseIntern(bool shouldPause) {
+void VideoDecoder::AudioTrack::pauseIntern(bool shouldPause) {
if (g_system->getMixer()->isSoundHandleActive(_handle))
g_system->getMixer()->pauseHandle(_handle, shouldPause);
}
-Audio::AudioStream *AdvancedVideoDecoder::RewindableAudioTrack::getAudioStream() const {
+Audio::AudioStream *VideoDecoder::RewindableAudioTrack::getAudioStream() const {
return getRewindableAudioStream();
}
-bool AdvancedVideoDecoder::RewindableAudioTrack::rewind() {
+bool VideoDecoder::RewindableAudioTrack::rewind() {
Audio::RewindableAudioStream *stream = getRewindableAudioStream();
assert(stream);
return stream->rewind();
}
-Audio::Timestamp AdvancedVideoDecoder::SeekableAudioTrack::getDuration() const {
+Audio::Timestamp VideoDecoder::SeekableAudioTrack::getDuration() const {
Audio::SeekableAudioStream *stream = getSeekableAudioStream();
assert(stream);
return stream->getLength();
}
-Audio::AudioStream *AdvancedVideoDecoder::SeekableAudioTrack::getAudioStream() const {
+Audio::AudioStream *VideoDecoder::SeekableAudioTrack::getAudioStream() const {
return getSeekableAudioStream();
}
-bool AdvancedVideoDecoder::SeekableAudioTrack::seek(const Audio::Timestamp &time) {
+bool VideoDecoder::SeekableAudioTrack::seek(const Audio::Timestamp &time) {
Audio::SeekableAudioStream *stream = getSeekableAudioStream();
assert(stream);
return stream->seek(time);
}
-AdvancedVideoDecoder::StreamFileAudioTrack::StreamFileAudioTrack() {
+VideoDecoder::StreamFileAudioTrack::StreamFileAudioTrack() {
_stream = 0;
}
-AdvancedVideoDecoder::StreamFileAudioTrack::~StreamFileAudioTrack() {
+VideoDecoder::StreamFileAudioTrack::~StreamFileAudioTrack() {
delete _stream;
}
-bool AdvancedVideoDecoder::StreamFileAudioTrack::loadFromFile(const Common::String &baseName) {
+bool VideoDecoder::StreamFileAudioTrack::loadFromFile(const Common::String &baseName) {
// TODO: Make sure the stream isn't being played
delete _stream;
_stream = Audio::SeekableAudioStream::openStreamFile(baseName);
return _stream != 0;
}
-void AdvancedVideoDecoder::addTrack(Track *track) {
+void VideoDecoder::addTrack(Track *track) {
_tracks.push_back(track);
// Update volume settings if it's an audio track
@@ -577,7 +556,7 @@ void AdvancedVideoDecoder::addTrack(Track *track) {
((AudioTrack *)track)->start();
}
-bool AdvancedVideoDecoder::addStreamFileTrack(const Common::String &baseName) {
+bool VideoDecoder::addStreamFileTrack(const Common::String &baseName) {
// Only allow adding external tracks if a video is already loaded
if (!isVideoLoaded())
return false;
@@ -592,7 +571,7 @@ bool AdvancedVideoDecoder::addStreamFileTrack(const Common::String &baseName) {
return result;
}
-void AdvancedVideoDecoder::setEndTime(const Audio::Timestamp &endTime) {
+void VideoDecoder::setEndTime(const Audio::Timestamp &endTime) {
Audio::Timestamp startTime = 0;
if (isPlaying()) {
@@ -615,21 +594,21 @@ void AdvancedVideoDecoder::setEndTime(const Audio::Timestamp &endTime) {
}
}
-AdvancedVideoDecoder::Track *AdvancedVideoDecoder::getTrack(uint track) {
+VideoDecoder::Track *VideoDecoder::getTrack(uint track) {
if (track > _tracks.size())
return 0;
return _tracks[track];
}
-const AdvancedVideoDecoder::Track *AdvancedVideoDecoder::getTrack(uint track) const {
+const VideoDecoder::Track *VideoDecoder::getTrack(uint track) const {
if (track > _tracks.size())
return 0;
return _tracks[track];
}
-bool AdvancedVideoDecoder::endOfVideoTracks() const {
+bool VideoDecoder::endOfVideoTracks() const {
for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++)
if ((*it)->getTrackType() == Track::kTrackTypeVideo && !(*it)->endOfTrack())
return false;
@@ -637,7 +616,7 @@ bool AdvancedVideoDecoder::endOfVideoTracks() const {
return true;
}
-AdvancedVideoDecoder::VideoTrack *AdvancedVideoDecoder::findNextVideoTrack() {
+VideoDecoder::VideoTrack *VideoDecoder::findNextVideoTrack() {
VideoTrack *bestTrack = 0;
uint32 bestTime = 0xFFFFFFFF;
@@ -656,7 +635,7 @@ AdvancedVideoDecoder::VideoTrack *AdvancedVideoDecoder::findNextVideoTrack() {
return bestTrack;
}
-const AdvancedVideoDecoder::VideoTrack *AdvancedVideoDecoder::findNextVideoTrack() const {
+const VideoDecoder::VideoTrack *VideoDecoder::findNextVideoTrack() const {
const VideoTrack *bestTrack = 0;
uint32 bestTime = 0xFFFFFFFF;
@@ -675,7 +654,7 @@ const AdvancedVideoDecoder::VideoTrack *AdvancedVideoDecoder::findNextVideoTrack
return bestTrack;
}
-void AdvancedVideoDecoder::startAudio() {
+void VideoDecoder::startAudio() {
if (_endTimeSet) {
// HACK: Timestamp's subtraction asserts out when subtracting two times
// with different rates.
@@ -688,13 +667,13 @@ void AdvancedVideoDecoder::startAudio() {
((AudioTrack *)*it)->start();
}
-void AdvancedVideoDecoder::stopAudio() {
+void VideoDecoder::stopAudio() {
for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
if ((*it)->getTrackType() == Track::kTrackTypeAudio)
((AudioTrack *)*it)->stop();
}
-void AdvancedVideoDecoder::startAudioLimit(const Audio::Timestamp &limit) {
+void VideoDecoder::startAudioLimit(const Audio::Timestamp &limit) {
for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
if ((*it)->getTrackType() == Track::kTrackTypeAudio)
((AudioTrack *)*it)->start(limit);
diff --git a/video/video_decoder.h b/video/video_decoder.h
index d6cfcde0b4..abb9f8df20 100644
--- a/video/video_decoder.h
+++ b/video/video_decoder.h
@@ -48,7 +48,6 @@ namespace Video {
/**
* Generic interface for video decoder classes.
- * @note This class is now deprecated in favor of AdvancedVideoDecoder.
*/
class VideoDecoder {
public:
@@ -77,53 +76,51 @@ public:
/**
* Close the active video stream and free any associated resources.
*/
- virtual void close() = 0;
+ virtual void close();
/**
* Returns if a video stream is currently loaded or not.
*/
- virtual bool isVideoLoaded() const = 0;
-
-
+ bool isVideoLoaded() const;
/**
* Returns the width of the video's frames.
* @return the width of the video's frames
*/
- virtual uint16 getWidth() const = 0;
+ virtual uint16 getWidth() const;
/**
* Returns the height of the video's frames.
* @return the height of the video's frames
*/
- virtual uint16 getHeight() const = 0;
+ virtual uint16 getHeight() const;
/**
* Get the pixel format of the currently loaded video.
*/
- virtual Graphics::PixelFormat getPixelFormat() const = 0;
+ virtual Graphics::PixelFormat getPixelFormat() const;
/**
* Get the palette for the video in RGB format (if 8bpp or less).
*/
- virtual const byte *getPalette() { return 0; }
+ const byte *getPalette();
/**
* Returns if the palette is dirty or not.
*/
- virtual bool hasDirtyPalette() const { return false; }
+ bool hasDirtyPalette() const { return _dirtyPalette; }
/**
* Returns the current frame number of the video.
* @return the last frame decoded by the video
*/
- virtual int32 getCurFrame() const = 0;
+ int32 getCurFrame() const;
/**
* Returns the number of frames in the video.
* @return the number of frames in the video
*/
- virtual uint32 getFrameCount() const = 0;
+ uint32 getFrameCount() const;
/**
* Returns the time position (in ms) of the current video.
@@ -139,12 +136,12 @@ public:
* completely accurate (since our mixer does not have precise
* timing).
*/
- virtual uint32 getTime() const;
+ uint32 getTime() const;
/**
* Return the time (in ms) until the next frame should be displayed.
*/
- virtual uint32 getTimeToNextFrame() const = 0;
+ uint32 getTimeToNextFrame() const;
/**
* Check whether a new frame should be decoded, i.e. because enough
@@ -160,13 +157,13 @@ public:
* hence the caller must *not* free it.
* @note this may return 0, in which case the last frame should be kept on screen
*/
- virtual const Graphics::Surface *decodeNextFrame() = 0;
+ virtual const Graphics::Surface *decodeNextFrame();
/**
* Returns if the video has finished playing or not.
* @return true if the video has finished playing or if none is loaded, false otherwise
*/
- virtual bool endOfVideo() const = 0;
+ bool endOfVideo() const;
/**
* Pause or resume the video. This should stop/resume any audio playback
@@ -190,7 +187,7 @@ public:
* Get the current volume at which the audio in the video is being played
* @return the current volume at which the audio in the video is being played
*/
- virtual byte getVolume() const { return _audioVolume; }
+ byte getVolume() const { return _audioVolume; }
/**
* Set the volume at which the audio in the video should be played.
@@ -201,13 +198,13 @@ public:
*
* @param volume The volume at which to play the audio in the video
*/
- virtual void setVolume(byte volume);
+ void setVolume(byte volume);
/**
* Get the current balance at which the audio in the video is being played
* @return the current balance at which the audio in the video is being played
*/
- virtual int8 getBalance() const { return _audioBalance; }
+ int8 getBalance() const { return _audioBalance; }
/**
* Set the balance at which the audio in the video should be played.
@@ -218,72 +215,8 @@ public:
*
* @param balance The balance at which to play the audio in the video
*/
- virtual void setBalance(int8 balance);
-
-protected:
- /**
- * Actual implementation of pause by subclasses. See pause()
- * for details.
- * @note This function is now deprecated. There is no replacement.
- */
- virtual void pauseVideoIntern(bool pause) {}
-
- /**
- * Reset the pause start time (which should be called when seeking)
- */
- void resetPauseStartTime();
-
- /**
- * Update currently playing audio tracks with the new volume setting
- * @note This function is now deprecated. There is no replacement.
- */
- virtual void updateVolume() {}
-
- /**
- * Update currently playing audio tracks with the new balance setting
- * @note This function is now deprecated. There is no replacement.
- */
- virtual void updateBalance() {}
-
- int32 _startTime;
-
-// FIXME: These are protected until the new API takes over this one
-//private:
- uint32 _pauseLevel;
- uint32 _pauseStartTime;
- byte _audioVolume;
- int8 _audioBalance;
-};
-
-/**
- * Improved interface for video decoder classes.
- */
-class AdvancedVideoDecoder : public VideoDecoder {
-public:
- AdvancedVideoDecoder();
- virtual ~AdvancedVideoDecoder() {}
-
- // Old API Non-changing
- // loadFile()
- // loadStream()
- // needsUpdate()
-
- // Old API Changing
- virtual void close();
- bool isVideoLoaded() const;
- virtual uint16 getWidth() const;
- virtual uint16 getHeight() const;
- virtual Graphics::PixelFormat getPixelFormat() const;
- virtual const Graphics::Surface *decodeNextFrame();
- const byte *getPalette();
- bool hasDirtyPalette() const { return _dirtyPalette; }
- int getCurFrame() const;
- uint32 getFrameCount() const;
- uint32 getTime() const;
- uint32 getTimeToNextFrame() const;
- bool endOfVideo() const;
+ void setBalance(int8 balance);
- // New API
/**
* Returns if a video is rewindable or not. The default implementation
* polls each track for rewindability.
@@ -352,7 +285,7 @@ public:
/**
* Set the default high color format for videos that convert from YUV.
*
- * By default, AdvancedVideoDecoder will attempt to use the screen format
+ * By default, VideoDecoder will attempt to use the screen format
* if it's >8bpp and use a 32bpp format when not.
*
* This must be set before calling loadStream().
@@ -375,13 +308,6 @@ public:
//Common::Rational getRate() const;
protected:
- // Old API
- void pauseVideoIntern(bool pause);
- void updateVolume();
- void updateBalance();
-
- // New API
-
/**
* An abstract representation of a track in a movie.
*/
@@ -680,6 +606,11 @@ protected:
};
/**
+ * Reset the pause start time (which should be called when seeking)
+ */
+ void resetPauseStartTime();
+
+ /**
* Decode enough data for the next frame and enough audio to last that long.
*
* This function is used by the default decodeNextFrame() function. A subclass
@@ -756,7 +687,7 @@ protected:
TrackListIterator getTrackListEnd() { return _tracks.end(); }
private:
- // Tracks owned by this AdvancedVideoDecoder
+ // Tracks owned by this VideoDecoder
TrackList _tracks;
// Current playback status
@@ -775,6 +706,12 @@ private:
void stopAudio();
void startAudio();
void startAudioLimit(const Audio::Timestamp &limit);
+
+ int32 _startTime;
+ uint32 _pauseLevel;
+ uint32 _pauseStartTime;
+ byte _audioVolume;
+ int8 _audioBalance;
};
} // End of namespace Video