diff options
author | Matthew Hoops | 2012-08-31 21:47:52 -0400 |
---|---|---|
committer | Matthew Hoops | 2012-08-31 21:47:52 -0400 |
commit | ddffd74094768fe7c992c568d484de06f389b7a0 (patch) | |
tree | 4608e14cf9f5c25b7ff7cc38418ea1681aa00b17 | |
parent | bf882b77c4fdebde862771c0d1df0aea0081dc00 (diff) | |
download | scummvm-rg350-ddffd74094768fe7c992c568d484de06f389b7a0.tar.gz scummvm-rg350-ddffd74094768fe7c992c568d484de06f389b7a0.tar.bz2 scummvm-rg350-ddffd74094768fe7c992c568d484de06f389b7a0.zip |
VIDEO: Improve setEndTime()
endOfVideo() and needsUpdate() are now more accurate
-rw-r--r-- | video/video_decoder.cpp | 25 | ||||
-rw-r--r-- | video/video_decoder.h | 1 |
2 files changed, 14 insertions, 12 deletions
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp index 559880acee..e79043629c 100644 --- a/video/video_decoder.cpp +++ b/video/video_decoder.cpp @@ -87,7 +87,7 @@ bool VideoDecoder::loadFile(const Common::String &filename) { } bool VideoDecoder::needsUpdate() const { - return !endOfVideo() && getTimeToNextFrame() == 0; + return hasFramesLeft() && getTimeToNextFrame() == 0; } void VideoDecoder::pauseVideo(bool pause) { @@ -249,18 +249,8 @@ uint32 VideoDecoder::getTimeToNextFrame() const { } bool VideoDecoder::endOfVideo() const { - if (!isVideoLoaded()) - return true; - - if (_endTimeSet) { - const VideoTrack *track = findNextVideoTrack(); - - if (track && track->getNextFrameStartTime() >= (uint)_endTime.msecs()) - return true; - } - for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) - if (!(*it)->endOfTrack()) + if (!(*it)->endOfTrack() && ((*it)->getTrackType() != Track::kTrackTypeVideo || !_endTimeSet || ((VideoTrack *)*it)->getNextFrameStartTime() < (uint)_endTime.msecs())) return false; return true; @@ -679,4 +669,15 @@ void VideoDecoder::startAudioLimit(const Audio::Timestamp &limit) { ((AudioTrack *)*it)->start(limit); } +bool VideoDecoder::hasFramesLeft() const { + // This is similar to endOfVideo(), except it doesn't take Audio into account (and returns true if not the end of the video) + // This is only used for needsUpdate() atm so that setEndTime() works properly + // And unlike endOfVideoTracks(), this takes into account _endTime + for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) + if ((*it)->getTrackType() == Track::kTrackTypeVideo && !(*it)->endOfTrack() && (!_endTimeSet || ((VideoTrack *)*it)->getNextFrameStartTime() < (uint)_endTime.msecs())) + return true; + + return false; +} + } // End of namespace Video diff --git a/video/video_decoder.h b/video/video_decoder.h index 5abe1d917c..7ccf49a0af 100644 --- a/video/video_decoder.h +++ b/video/video_decoder.h @@ -777,6 +777,7 @@ private: void stopAudio(); void startAudio(); void startAudioLimit(const Audio::Timestamp &limit); + bool hasFramesLeft() const; int32 _startTime; uint32 _pauseLevel; |