diff options
author | Matthew Hoops | 2012-08-16 14:00:14 -0400 |
---|---|---|
committer | Matthew Hoops | 2012-08-16 14:00:14 -0400 |
commit | 18823198ad4e7dedd0ca33760eb453e9fe673551 (patch) | |
tree | 6a4ef578a74c5ffd616101f686a2f3b7248406d4 /video | |
parent | 7569ec7dc00e95e0643cde7f413a7cf46a4770f0 (diff) | |
download | scummvm-rg350-18823198ad4e7dedd0ca33760eb453e9fe673551.tar.gz scummvm-rg350-18823198ad4e7dedd0ca33760eb453e9fe673551.tar.bz2 scummvm-rg350-18823198ad4e7dedd0ca33760eb453e9fe673551.zip |
VIDEO: Merge AdvancedVideoDecoder into VideoDecoder
Diffstat (limited to 'video')
-rw-r--r-- | video/avi_decoder.cpp | 2 | ||||
-rw-r--r-- | video/avi_decoder.h | 2 | ||||
-rw-r--r-- | video/bink_decoder.cpp | 2 | ||||
-rw-r--r-- | video/bink_decoder.h | 2 | ||||
-rw-r--r-- | video/coktel_decoder.cpp | 2 | ||||
-rw-r--r-- | video/coktel_decoder.h | 4 | ||||
-rw-r--r-- | video/dxa_decoder.h | 2 | ||||
-rw-r--r-- | video/flic_decoder.h | 2 | ||||
-rw-r--r-- | video/psx_decoder.cpp | 2 | ||||
-rw-r--r-- | video/psx_decoder.h | 2 | ||||
-rw-r--r-- | video/qt_decoder.cpp | 6 | ||||
-rw-r--r-- | video/qt_decoder.h | 2 | ||||
-rw-r--r-- | video/smk_decoder.cpp | 4 | ||||
-rw-r--r-- | video/smk_decoder.h | 2 | ||||
-rw-r--r-- | video/theora_decoder.cpp | 2 | ||||
-rw-r--r-- | video/theora_decoder.h | 2 | ||||
-rw-r--r-- | video/video_decoder.cpp | 219 | ||||
-rw-r--r-- | video/video_decoder.h | 123 |
18 files changed, 149 insertions, 233 deletions
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 |