diff options
author | Bastien Bouclet | 2017-10-01 09:51:41 +0200 |
---|---|---|
committer | Bastien Bouclet | 2017-11-02 19:49:43 +0100 |
commit | 9b9600a50f10cdc5dcfc1d43c0ff27a5728a98ef (patch) | |
tree | 49f6ae0f232340227d6c68a8e6f2d20cf3bfc85e /video | |
parent | 174276455f58b628d7642c66b1a6c9cf3a6ffde0 (diff) | |
download | scummvm-rg350-9b9600a50f10cdc5dcfc1d43c0ff27a5728a98ef.tar.gz scummvm-rg350-9b9600a50f10cdc5dcfc1d43c0ff27a5728a98ef.tar.bz2 scummvm-rg350-9b9600a50f10cdc5dcfc1d43c0ff27a5728a98ef.zip |
VIDEO: Express VideoDecoder::endOfVideo using easier to understand logic
Diffstat (limited to 'video')
-rw-r--r-- | video/video_decoder.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp index 980138c13e..6e408ba3d3 100644 --- a/video/video_decoder.cpp +++ b/video/video_decoder.cpp @@ -293,9 +293,14 @@ uint32 VideoDecoder::getTimeToNextFrame() const { } bool VideoDecoder::endOfVideo() const { - for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) - if (!(*it)->endOfTrack() && (!isPlaying() || (*it)->getTrackType() != Track::kTrackTypeVideo || !_endTimeSet || ((VideoTrack *)*it)->getNextFrameStartTime() < (uint)_endTime.msecs())) + for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) { + const Track *track = *it; + + bool videoEndTimeReached = _endTimeSet && track->getTrackType() == Track::kTrackTypeVideo && ((const VideoTrack *)track)->getNextFrameStartTime() >= (uint)_endTime.msecs(); + bool endReached = track->endOfTrack() || (isPlaying() && videoEndTimeReached); + if (!endReached) return false; + } return true; } @@ -910,9 +915,17 @@ 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() && (!isPlaying() || !_endTimeSet || ((VideoTrack *)*it)->getNextFrameStartTime() < (uint)_endTime.msecs())) + for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) { + if ((*it)->getTrackType() != Track::kTrackTypeVideo) + continue; + + const VideoTrack *track = (const VideoTrack *)*it; + + bool videoEndTimeReached = _endTimeSet && track->getNextFrameStartTime() >= (uint)_endTime.msecs(); + bool endReached = track->endOfTrack() || (isPlaying() && videoEndTimeReached); + if (!endReached) return true; + } return false; } |